Subject | UDF-Problem |
---|---|
Author | Elmar Haneke |
Post date | 2003-11-11T19:03:11Z |
Hi,
I do have some problems defining an UDF function:
c-File:
#include <string.h>
#include <ib_util.h>
char *HE_concat(char *s1,char *s2) {
char * buf;
buf = (char *) ib_util_malloc(strlen(s1)+strlen(s2)+1);
strcpy(buf,s1);
strcat(buf,s2);
return buf;
}
double HE_abs(double *a)
{
return (*a < 0.0) ? -*a : *a;
}
sql-Definitions:
DECLARE EXTERNAL FUNCTION Concat
CString(255),CString(255)
RETURNS CString(512) FREE_IT
ENTRY_POINT 'HE_concat' MODULE_NAME 'he_udf';
DECLARE EXTERNAL FUNCTION abs
DOUBLE PRECISION
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'HE_abs' MODULE_NAME 'he_udf';
compiler command:
#!/bin/sh
gcc -I/usr/local/firebird/include -c -O9 he_udf.c
ld -L/usr/local/firebird/lib -lib_util -G he_udf.o -o libhe_udf.so
cp libhe_udf.so /usr/local/firebird/UDF/
I'm using FB1.5RC7 on Debian Linux using gcc 3.3.2.
On querying "select abs(-1) from Table" I get "invalid request BLR at
offset 59 function ABS not defined module name or entrypoint could not
be found.
What goes wrong, how can I resolve this.
Elmar
I do have some problems defining an UDF function:
c-File:
#include <string.h>
#include <ib_util.h>
char *HE_concat(char *s1,char *s2) {
char * buf;
buf = (char *) ib_util_malloc(strlen(s1)+strlen(s2)+1);
strcpy(buf,s1);
strcat(buf,s2);
return buf;
}
double HE_abs(double *a)
{
return (*a < 0.0) ? -*a : *a;
}
sql-Definitions:
DECLARE EXTERNAL FUNCTION Concat
CString(255),CString(255)
RETURNS CString(512) FREE_IT
ENTRY_POINT 'HE_concat' MODULE_NAME 'he_udf';
DECLARE EXTERNAL FUNCTION abs
DOUBLE PRECISION
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'HE_abs' MODULE_NAME 'he_udf';
compiler command:
#!/bin/sh
gcc -I/usr/local/firebird/include -c -O9 he_udf.c
ld -L/usr/local/firebird/lib -lib_util -G he_udf.o -o libhe_udf.so
cp libhe_udf.so /usr/local/firebird/UDF/
I'm using FB1.5RC7 on Debian Linux using gcc 3.3.2.
On querying "select abs(-1) from Table" I get "invalid request BLR at
offset 59 function ABS not defined module name or entrypoint could not
be found.
What goes wrong, how can I resolve this.
Elmar