Re: calling stored procedures
Posted in 1996
Dennis McCarthy wrote: > > I need to write a program which will call a stored procedure > without compiling the name of the stored procedure into the > program. The program will get the name of the stored procedure > at run time. Can this be done with Informix? There are ways > to do this with Oracle (OCI API) and Sybase (rpc API) that use > proprietary API's rather than embedded SQL. > > Thanks, > Dennis McCarthy Dennis, Sounds like a non-4GL programmer asking a question. ;-) Using 4GL, which more closely resembles pseudo-code: let procname = get_procname() # Get name of procedure by obscure means let sqlstring = "execute procedure ", procname, "()" # ABove pieces together the statement prepare sqprep from sqlstring # Have the engine parse the string declare sqcurs cursor for sqprep # Set up structure for fetching data open sqcurs # last-moment optimize fetch sqcurs into var_1, var_2 # Get two columns of data from cursor close sqcurs This is, of course, grossly simplistic. You could have put "?" placeholders between the parentheses for parameters to the stored procedure. The you would open the cursor with the usage: open sqcurs using p1, p2, p3 etc.. The Informix classes on Stored Procedures and on 4GL discuss this. Good luck. -- Jake Salomon