Re: Prepared cursor with matches
Posted in 1997
jna@carmenta.se (Johan Andersson) wrote: :In article <5bj7tm$5j@cssun.mathcs.emory.edu>, wyang@aerotek.com says... :> :>} } I'm trying to prepare a cursor using :>} } :>} } PREPARE thingy FROM :>} } "SELECT * \\ :>} } FROM table \\ :>} } WHERE col1 = ? \\ :>} } AND col2 MATCHES ?" :> :> :>You need to put quotes around the second variable, like :> :>AND col2 MATCHES '?'" :> This will not work in any version of 4GL that I know of. It will make the ? a literal character. :>HTH :> :I might be wrong but will that not forfeit the purpose? : :What Davin wanted in the first place was to have a placeholder after matches :not a character constant. : :As I read the Informix syntax, this is actually not possible! : :Informix only allows literal constants after 'like' and 'matches' whereas :it allows a placeholder after normal operators. : :I wish to do the same thing but have had to resort to reparsing the SQL :statement each time the user changes the 'matching criteria' :-( : :Small non-intuitive restrictions like this is really irritating. The problem is that it does work, so this isn't a non-intuitive restriction. I do seem to remember though that there was a time when you had to include the quotes in the program variable (not the prepared statement) but the above does work on both version 4.10.UC3 and 6.00.UE3 which are the once I have available right now. As Davin stated in another post he had even solved it: Davin_Harvey_at_LLCS-MAXIM@lendlease.com.au ("Davin Harvey") wrote: : Aha - found the problem. I didn't realise you could use FOREACH ... : USING, so I was doing an OPEN ... USING, followed by a FOREACH. It : would appear that the OPEN wasn't the problem, it was the FOREACH. Be aware that foreach actually gets translated into something like: open ... while true fetch ... if status <> 0 then close cursor exit while end if end while Which was what you had to do for yourself before foreach got the using option. This means you do either open/fetch or foreach, never both. Nils.Myklebust@idg.no NM Data AS, P.O.Box 9090 Gronland, N-0133 Oslo, Norway My opinions are those of my company The Informix FAQ is at http://www.iiug.org