Subject Re: [firebird-support] UDF Writing On Ubuntu
Author R. S. Patil
On Mon, Jul 28, 2008 at 5:02 PM, Milan Babuskov <milanb@...> wrote:
>
> R. S. Patil wrote:
> > With flame robin I created a new DATABASE for Testing and RAN the script
> > But it gave error for SET SQL DIALECT 3; statement so I commented it out
> > then Installation went smooth.
>
> That is normal since you select dialect in Database Registration Dialog.

OK

>
> BTW, when you run large scripts generated by ISQL or some other tool,
> make sure you use automatic DDL commit or add
>
> SET AUTODDL ON;
>
> at the start of your script.

I did that
>
> Now, regarding your problem: Do you use RestrictUDF setting in
> firebird.conf and how is it set? What does the DECLARE EXTERNAL FUNCTION
> for F_CDOWLONG look likt?
>

Restrict UDF was commented i removed the # and restarted FB server.

DECLARE EXTERNAL FUNCTION F_CDOWLONG
TIMESTAMP
RETURNS CSTRING(16) FREE_IT
ENTRY_POINT 'cdowlong' MODULE_NAME 'FreeAdhocUDF';

This time I used only this query and committed the transaction

Result is as follows

Starting transaction...
Preparing query: DECLARE EXTERNAL FUNCTION F_CDOWLONG
TIMESTAMP
RETURNS CSTRING(16) FREE_IT
ENTRY_POINT 'cdowlong' MODULE_NAME 'FreeAdhocUDF'
Prepare time: 00:00:00.
Plan not available.


Executing...
Done.
21 fetches, 6 marks, 6 reads, 0 writes.
3 inserts, 0 updates, 0 deletes, 0 index, 1 seq.
Delta memory: 9556 bytes.
RDB$FUNCTIONS: 1 inserts.
RDB$FUNCTION_ARGUMENTS: 2 inserts.
Execute time: 00:00:01.
Commiting transaction...
Done.
Starting transaction...
Preparing query: select F_CDOWLONG(current_timestamp)
from RDB$DATABASE
*** IBPP::SQLException ***
Context: Statement::Prepare( select F_CDOWLONG(current_timestamp)
from RDB$DATABASE )
Message: isc_dsql_prepare failed

SQL Message : -104
Invalid token

Engine Code : 335544343
Engine Message :
invalid request BLR at offset 63
function F_CDOWLONG is not defined
module name or entrypoint could not be found


Execute time: 00:00:00.

BTW meanwhile with Restrict UDF commented i tried installing fbudf UDF
by running the default script provided with FB package and I found
that Function works.

I feel there is something wrong with UDF compilation or declaration itself
the function I used from fbudf was

declare external function dow
timestamp,
varchar(15) returns parameter 2
entry_point 'DOW' module_name 'fbudf';

both declarations vary a bit but this one works fine

I also tried on these lines with FreeAdhocUDF but it also fails

can u extend ur help further ?
May be regarding Compiling UDFs in C on Ubuntu ?

Thanks and Best Regards

R. S. Patil