13. Datablades:

13.1 How do I write a simple datablade?

On 6th December 2000 cosmo@informix.com (Cosmo) wrote:-

If you want a simple UDR example try this.


#include "mi.h"

mi_lvarchar *
hello ()
  mi_lvarchar *v;

  if ((v = mi_string_to_lvarchar ("Hello World")) == NULL)
    mi_db_error_raise (NULL, MI_EXCEPTION, "could not convert string");

  return (v);

Compile with:

gcc -fpic -c -DLINUX -I$(INFORMIXDIR)/incl/public hello.c
ld -shared hello.o -o hello.so

Register with the following SQL (change the path name as appropriate):

create function hello () returning lvarchar
with (not variant)
external name '/home/informix/9.21/blades/hello/hello.so(hello)'
language c;

Then test with:

execute function hello();