Subject | Re: [firebird-support] date function |
---|---|
Author | Helen Borrie |
Post date | 2004-10-04T09:34:59Z |
At 11:09 AM 4/10/2004 +0700, you wrote:
SQL, if you need a field name for a derived field, us the AS clause:
SELECT CURRENT_DATE FROM RDB$DATABASE AS CurrentDate
NB you can optionally omit the keyword "AS" and just provide the fieldname.
"user-defined functions", or UDFs.
DOCUMENTATION!!!
you some misleading results. Consider consulting an SQL manual to solve
some of these problems.
want to use with that database. There is no such thing as "installing" udf
libraries. They are EXTERNAL function libraries. To use a function, you
use DECLARE EXTERNAL FUNCTION to tell the server the entry point of the
function and the name of the library ("module_name").
language reference.
./heLen
>Thanks Helen... but the problem still persist...That is not a Firebird engine error, but an error from your program. In
>
> > CURRENT_DATE
> >
> > insert into aTable (aDate)
> > values (CURRENT_DATE)
>
>This works fine.
>
> > and
> > SELECT CURRENT_DATE FROM RDB$DATABASE
>
>But, this doesn't. "Field name missing" error arise.
SQL, if you need a field name for a derived field, us the AS clause:
SELECT CURRENT_DATE FROM RDB$DATABASE AS CurrentDate
NB you can optionally omit the keyword "AS" and just provide the fieldname.
> > UPDATE aTableGet hold of some documentation and read about external functions, a.k.a.
> > set blah = CURRENT_DATE + 1
> >
> > DELETE from aTable
> > where date between CURRENT_DATE - 30 and CURRENT_DATE - 15
>
>This works fine too.
>
> > Operating with months isn't so simple - work out what you want and use
> > either an expression or a UDF.
>
>Alright then. I know it's not so simple, but database engine should help
>rather
>than giving it up to the users. That's what computer is all about, right?
>:) I
>hope the next minor version release (1.6?) will support DB2's date/time style
>syntax. Believe me, it'll help us a lot. :)
"user-defined functions", or UDFs.
> > SELECT CURRENT_DATE, FIELD_NAME FROM ATABLESame solution: if your program needs a fieldname, provide one.
>
>This doesn't work, same error as above.
> > See also CURRENT_TIMESTAMP (to include time) and the predefined dateIt works - just doesn't work with your utility program. READ SOME SQL
> > literals 'TODAY', 'TOMORROW', 'YESTERDAY' and 'NOW'. PDDLs have to be
> cast.
> >
> > So, these are the same:
> >
> > SELECT CURRENT_DATE + 1 FROM RDB$DATABASE
>
>This doesn't work.
DOCUMENTATION!!!
> > andThink it over.
> > SELECT CAST('TOMORROW' AS DATE) FROM RDB$DATABASE
>
>This works.
>
>I don't know why some of the syntaxes above raise an error. FYI, I use
>Firebird
>1.5 on WindowsXP SP1 using dbExpress (Delphi 7). I believe the problem isn't
>with the OS or the client application since other queries work fine.
>It seems that predefined date literals are considered just like ordinaryIt looks as though some bad experiences with utility programs are giving
>internal database variables/constants, not as special identifiers that the
>database would automagically understand what the user want from its
>position in
>the query.
you some misleading results. Consider consulting an SQL manual to solve
some of these problems.
>Oh, one more question... it seems that default udf (ib_udf and fbudf) is notThat's exactly it. You must declare *in the database* any functions you
>automatically included in the database. Am I right? Or did I do something
>wrong
>in the installation? Because, I can't use ABS() without registering the udf.
want to use with that database. There is no such thing as "installing" udf
libraries. They are EXTERNAL function libraries. To use a function, you
use DECLARE EXTERNAL FUNCTION to tell the server the entry point of the
function and the name of the library ("module_name").
>For any kind of help, I thank you all in advanced.Get equipped with some documentation. You won't get far without at least a
language reference.
./heLen