Creating C UDR
Posted in 2000
Topics: Stored Procedures & SPL, Data Types & Schema Design
I am trying to write a C UDR but my routine is not resolving the UDR.
Below is the C UDR, the compiler/linker statements, SPL routines, and
the error
message.
The questions I would have are:
Q: How do I verify the integrity of my .so?
Q: Am I using the correct compiler/linker options?
Q: Am I referencing the EXTERNAL NAME correctly?
TIA
Steve Romankiw
Environment:
Solaris 2.6
cc: WorkShop Compilers 4.2 30 Oct 1996 C 4.2
IDS.2000 UC2-2
=========--------- C UDR --------==========
C code: hello.c
print_hello()
{
printf("Hello");
}
=========--------- Compiler/Linker Statement --------==========
cc -KPIC -c hello.c
ld -G -z text -o say_hello.so hello.o
#-- I chown to informix for the .so, but that did not help. --#
=========--------- SPL Routines --------==========
DROP FUNCTION say_udr;
CREATE FUNCTION say_udr() RETURNS VARCHAR(10); EXTERNAL NAME
"/home/romankis/IIF.2000/UDR/say_hello.so(print_hello)"
LANGUAGE C
END FUNCTION;
DROP FUNCTION show_say_hello;
CREATE FUNCTION show_say_hello() RETURNS VARCHAR(10)
RETURN(say_udr());END FUNCTION;
EXECUTE FUNCTION show_say_hello();
=========--------- Error Mesage --------==========
-9794 User-defined-routine load failed.
The following error message appears in the log:
Loading Routine routine_name procid = process_ID_number
The routine routine_name is not found in the module, possibly because
of a bad external name or the wrong module. The log message
log_message_number is probably -1, and error_message_string is the
database routine name as opposed to the symbol that was not found.
i think you need to have the api data types defined in your parameters,
and the cast for the
function as well - in this case probably mi_lvarchar * say_hello( ) or
something like that.
look at the how to example for soundex to get a cleaner picture of the
data types you must
use.
i cannot vouch for the compile line, im using an hp. i did write an upper
function tho, based
on what i saw for the soundex example.
Steve Romankiw wrote:
> I am trying to write a C UDR but my routine is not resolving the UDR.
> Below is the C UDR, the compiler/linker statements, SPL routines, and
> the error
> message.
>
> The questions I would have are:
>
> Q: How do I verify the integrity of my .so?
>
> Q: Am I using the correct compiler/linker options?
>
> Q: Am I referencing the EXTERNAL NAME correctly?
>
> TIA
>
> Steve Romankiw
>
> Environment:
> Solaris 2.6
> cc: WorkShop Compilers 4.2 30 Oct 1996 C 4.2
> IDS.2000 UC2-2
>
> =========--------- C UDR --------==========
> C code: hello.c
>
> print_hello()
> {
> printf("Hello");
> }
>
> =========--------- Compiler/Linker Statement --------==========
> cc -KPIC -c hello.c
> ld -G -z text -o say_hello.so hello.o
>
> #-- I chown to informix for the .so, but that did not help. --#
>
> =========--------- SPL Routines --------==========
> DROP FUNCTION say_udr;
> CREATE FUNCTION say_udr() RETURNS VARCHAR(10);> EXTERNAL NAME
> "/home/romankis/IIF.2000/UDR/say_hello.so(print_hello)"
> LANGUAGE C
> END FUNCTION;
>
> DROP FUNCTION show_say_hello;
> CREATE FUNCTION show_say_hello() RETURNS VARCHAR(10)
> RETURN(say_udr());> END FUNCTION;
>
> EXECUTE FUNCTION show_say_hello();>
> =========--------- Error Mesage --------==========
> -9794 User-defined-routine load failed.
>
> The following error message appears in the log:
>
> Loading Routine routine_name procid = process_ID_number
>
> The routine routine_name is not found in the module, possibly because
> of a bad external name or the wrong module. The log message
> log_message_number is probably -1, and error_message_string is the
> database routine name as opposed to the symbol that was not found.