Re: EXECUTE IMMEDIATE - What's wrong ?
Posted in 1995
In article <D6LxnF.D3H@softec.sk> rasto@softec.sk "Rastislav Janac" writes: > Hi everybody, > I've RTFM and there I've found something like this : > > ** MANUAL ** > QUICK EXECUTION > For simple statements thet do not require a cursor or host > variables, you can combine the actions of the PREPARE, the > EXECUTE, and the FREE statements into a single operation. > The EXECUTE IMMEDIATE statement takes a character string > and in one operation prepares it, executes it, and frees > the storage. > -------------------------------------------------------- > $ EXECUTE IMMEDIATE "drop index my_temp_index"; > -------------------------------------------------------- > ************ > > So I tried it and the result was this : > > ** 4gl ** > execute immediate "delete from my_temp_table" > | The cursor "immediate" has not yet been declare in this > | program ... > ********** > > Release : > Manual = version 4.10 > RDS = version 4.1 > 4GL = version 4.1 > > So WHAT'S WRONG WITH IT ? I dont think you can do this in 4gl. 4gl expects execute to be followed by statement-id, where statement id is the result of a previous PREPARE statement. See Informix 4GL reference manual page7-107. If you read Informix guide to SQL reference, page 692, it will give you an example of using execute immediate in 4GL. I think this is a mistake in the guide to SQL manual. You can always: let p_st = "delete from my_temp_table" prepare st from p_st execute st free st -- -------------------------------------------------------------------------- paul sellars,humberside,u.k. ==========================================================================