Re: Calling C code from Informix-SQL Forms
Posted in 1993
Topics: Stored Procedures & SPL, Triggers, Constraints & Referential Integrity
In article <brad.743741628@ss1> brad@adied.oz.au (Bradley Edelman) writes: >I would like to be able to send mail to some appropriate people when certain >tables in our Informix DB are updated or inserted to. > >Now, I've been told I need to create a custom form runner with CPERF and link >in the C routines. How does cperf work? Do the C routines need to be in a >particular format or have particular parameters? > >Brad. Well, you could do it that way, but I would tend (assuming that you have a 5.01 engine) to use an insert/update trigger, calling a stored procedure that has the command "run mail whoever...". If you absolutely want to go the custom runner route, though, the command line for cperf would be 'cperf myfuncs.c -o myrunner'. An example c function is below the .sig, taken from tech info. Good luck, David Coburn coburn@informix.com Informix Software, Inc. ...uunet!infmx!coburn ========================================================================= Any opinions expressed here are not necessarily those of Informix (or for that matter, anybody else). ========================================================================= TechInfo # 955 Short Description: EXAMPLE 36: C subroutine for linking with PERFORM Long Description: EXAMPLE 36: C subroutine for linking with PERFORM ================================================== #include <stdio.h> #include "Perform.h" #include "../rdsterm/rdsterm.h" /* * This is a skeleton user C subroutine for linking with PERFORM. * The structures 'ufunc' and 'userfuncs' must be defined in the user's * data area as shown below. * / extern struct value *help(); extern struct value *help2(); struct ufunc userfuncs[] = { "help", help, "help2", help2, 0,0 }; /* this global will be used as your auxilliary window * if you wish, you could make it local and do newwin each time followed * by delwin when done, but that involves a lot of memory allocation * and freeing, which is slow */ WINDOW *hlpscr = 0; /*---- User Function -----*/ /* this function clears the screen, displays hello, waits for a character, then restores old screen */ struct value *help() { int dummy; WINDOW *tmpscr; tmpscr = stdscr; if (hlpscr == 0) hlpscr = newwin(LINES,COLS,0,0); stdscr = hlpscr; hlpscr = tmpscr; touchwin(stdscr); clear(); move(10,10); addstr("hello"); refresh(); rfetchch(); /*this simply waits for a character (in libdb.a)*/ tmpscr = stdscr; stdscr = hlpscr; hlpscr = tmpscr; touchwin(stdscr); refresh(); } /* this function is about the same as help, except that 2 lines * are displayed in non-curses mode*/ struct value *help2() { int dummy; WINDOW *tmpscr; tmpscr = stdscr; if (hlpscr == 0) hlpscr = newwin(LINES,COLS,0,0); stdscr = hlpscr; hlpscr = tmpscr; touchwin(stdscr); clear(); refresh(); rdspexit(); printf("hello world\\n"); printf("goodbye\\n"); fflush(stdout); sleep(3); clear(); refresh(); rdspenter(); tmpscr = stdscr; stdscr = hlpscr; hlpscr = tmpscr; touchwin(stdscr); refresh(); } ==END==