Simple Informix C UDR on Centos 6.6
Posted: April 26, 2015 Filed under: Informix, Informix 12 | Tags: Informix, Informix 12 Leave a commentSimple Informix C UDR on Centos 6.
#include "dmi/mi.h" mi_integer bigger_int(mi_integer left,mi_integer right) { if ( left > right ) return(left); else return(right); }
To compile
gcc -I$INFORMIXDIR/incl -I $INFORMIXDIR/incl/esql -c -fPIC -DMI_SERVBUILD -g bigger_int.c gcc -shared -fPIC -o /home/informix/bigger_int.so bigger_int.o
To load and run
dbaccess sysmaster create database justdave; CREATE FUNCTION bigger_int (arg1 integer, arg2 integer) RETURNING integer EXTERNAL NAME '/home/informix/bigger_int.so(bigger_int)' LANGUAGE C; select bigger_int(1,2) from systables where tabid=1; DROP FUNCTION bigger_int;
Only when you execute the function is the shared library loaded
05:20:41 Loading Module
05:20:41 pid 3217: ELF .eh_frame section missing in /opt/IDS.12.10.FC5/gls/dll/64-libicudata.so.48
05:20:41 The C Language Module loaded