Subject Re: [firebird-support] Firebird 2.1.1, error when execute an Select statment with UDF function under Windows 2008 x64
Author Helen Borrie
At 10:40 AM 14/01/2009, you wrote:
>Hello,
>I have installed an Windows x64 with the Firebird 2.1.1 32 bits version (because I haven't compiled my udf under 64 bits now)
>when I use Ibexpert for send this command to Firebird "select * from abs(-2.3)" I obtain an error :
>
>Undefined name.
>Dynamic SQL Error.
>SQL error code = -204.
>Procedure unknown.
>ABS.
>At line 1, column 20.
>
>the same function used in a compiled stored procedure work fine .... this error is same for all udf I want to use directly

Of course. It is totally invalid. You seem to be confusing UDFs with selectable stored procedures...or something...

The FROM part of a SELECT statement must be a table object of some some kind (table, view, selectable stored procedure, derived table).

If you want to get a result from a UDF call returned as a value to an application, you can use a SELECT from the single-row system table, RDB$DATABASE. To use your example:

select abs(-2.3) from rdb$database as retvalue

or, if you encounter a problem with the data typing of the output:

select cast(abs(-2.3) as decimal(9,1)) from rdb$database as retvalue

>this error is the same trhough my application when I wan to call directly an select with an UDF inside not only
>from Ibexpert

Inside a stored procedure or trigger (or in an EXECUTE BLOCK construct) you can invoke the result of a UDF directly into a variable, e.g.
...
declare myVar decimal(9,1);
...
begin
...
myVar = cast(abs(-2.3) as decimal(9,1))
...
end

./hb