Subject | Re: [ib-support] Use of UDF in IB Procedure |
---|---|
Author | Martijn Tonies |
Post date | 2002-07-25T10:03:54Z |
Hi,
server knows what function in what dynamic library to call when you
use it.
Second, you simply use it with the right number of parameters!
Here's an example:
DECLARE EXTERNAL FUNCTION SUBSTR
CSTRING(80), SMALLINT, SMALLINT
RETURNS CSTRING(80) FREE_IT
ENTRY_POINT 'IB_UDF_substr' MODULE_NAME 'ib_udf'
Of course, you need to look up the right declaration for FLOOR in the
InterBase manuals.
Then, you can use it (this is inside a trigger):
new.LEVERVAN = substr(new.DATUM1, 3, 4) || '/' || substr(new.DATUM1, 1, 2)
|| '/' ||
substr(new.DATUM1, 5, 8);
new.LEVERTOT = substr(new.DATUM2, 3, 4) || '/' || substr(new.DATUM2, 1, 2)
|| '/' ||
substr(new.DATUM2, 5, 8);
Hope this helps,
Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird
http://www.interbaseworkbench.com
Upscene Productions
http://www.upscene.com
"This is an object-oriented system.
If we change anything, the users object."
> This may look like a stupid question, but I would like to use a UDFFirst, you "register" the UDF with your database. This way, the InterBase
> in a procedure. I don't know how to code it. The procedure I would
> like to use is the standard FLOOR UDF on a local variable in the
> procedure.
> Can someone explain me how to do this ?
server knows what function in what dynamic library to call when you
use it.
Second, you simply use it with the right number of parameters!
Here's an example:
DECLARE EXTERNAL FUNCTION SUBSTR
CSTRING(80), SMALLINT, SMALLINT
RETURNS CSTRING(80) FREE_IT
ENTRY_POINT 'IB_UDF_substr' MODULE_NAME 'ib_udf'
Of course, you need to look up the right declaration for FLOOR in the
InterBase manuals.
Then, you can use it (this is inside a trigger):
new.LEVERVAN = substr(new.DATUM1, 3, 4) || '/' || substr(new.DATUM1, 1, 2)
|| '/' ||
substr(new.DATUM1, 5, 8);
new.LEVERTOT = substr(new.DATUM2, 3, 4) || '/' || substr(new.DATUM2, 1, 2)
|| '/' ||
substr(new.DATUM2, 5, 8);
Hope this helps,
Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird
http://www.interbaseworkbench.com
Upscene Productions
http://www.upscene.com
"This is an object-oriented system.
If we change anything, the users object."