Re: dynamic sql: need help in executing stored procedure
Posted in 1995
Srini Raman (srini@netcom.com!anl.liv.usw.com) wrote: : Hello, : I am trying to execute a stored procedure using dynamic : sql. : I did the following: : ------------------ x.ec : $char spstr[1024]; : sprintf(spstr, "execute procedure sp(%s) into %s", : "?,?", "?"); : $prepare sid from :spstr; : $execute sid using :x, :y, :z; : -------------------- : When I run my program, I get sqlerror #201 (syntax error) : on prepare statement. : : If I don't use the "into" in the execute procedure, : like this: : : sprintf(spstr, "execute procedure sp(%s)", "?,?"); : $prepare sid from :spstr; : $execute sid using :x, :y; : : it works fine. : Can somebody help me in finding why I get this error : when I use "into". I believe this is because the compiler has no way of knowing that your procedure will not RETURN ... WITH RESUME, and so it prohibits the PREPARation of a statement that could not be EXECUTEd. You should use a procedure CURSOR instead. -- graeme -- Disclaimer: The author's opinions are his own, and not necessarily those of Pyramid Technology Ltd. or Pyramid Technology Inc. --------------------------------------------------------------------------- -m------- Graeme Sargent Voice: +44 (0)252 373035 ---mmm----- Senior Database Consultant Fax : +44 (0)252 373135 -----mmmmm--- Pyramid Technology Ltd. Telex: Tell who??? -------mmmmmmm- Farnborough, Hants GU14 7PL Email: graeme@pyra.co.uk --------------------------------------------------------------------------- We have the technology. The tricky bit is learning how to use it.