Subject Re: [firebird-support] UDF problem
Author Martijn Tonies
Hi,

> I translated my database FireBird 1.5 to 2.0, but sometime when I use
certain functions give me error "Error reading data from the conection". One
of the failing functions is
>

"error reading data from connection" means the server has crashed.

> Code function in Delphi
>
> function fnOnlyDate(F1 : PISC_QUAD): PISC_QUAD; stdcall;
> begin
> F1.gds_quad_low := 0;
> Result := F1;
> end;
>
> Declaration function
>
> declare external function fnOnlyDate
> date returns date free_it
> entry_point 'fnOnlyDate' module_name 'X.dll';

well, I'm not sure what's wrong, but "free_it" only applies to
characterdata AND should be used in conjuction with ib_getmem (or
something like that).

You are returning a pointer to PISC_QUAD, the same as the input.
Is this even possible? Or should you allocate a TISC_Quad record?

> SQL example
>
> SELECT FIRST 1 CON_ID
> FROM DOC_CONSULTAS
> WHERE (CON_TIPOCONSULTA = 1) AND (CON_ESTADO > 2) AND
> (CON_PACIENTE = 1) AND (CON_ID <> 2) AND
(fnOnlyDate(CON_FECHA) = '1/1/2007')

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com