Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Vincent Kennedy could not get EXECUTE ... INTO ... USING to work in Informix 4GL version 7 with a prepared select count(*). Carlson@WHSmith suggested DECLARE a cursor, OPEN it USING the value, and FETCH INTO. Jonathan Leffler asked which I4GL sub-version and said 7.30 would be better, suggesting an SQL ... END SQL block with embedded variables. No confirmation of a fix.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
Vincent Kennedy — — source: Informix-list mailing list archive (1991-1998)
I'm using informix4GL version 7 and want to pass a field name as a string
into a prepared statement and execute the result into a variable.
E.g
let p_string1 = "select count(*) from temptable where field1 = ? "
prepare p_sql1 from p_string1
execute p_sql1 into p_count using p_fieldName
It doesn't like the execute line. It seems to be the write sytnax from the
manuals.
Thank you.
↪ replying to Vincent Kennedy
Carlson@WHSmith — — source: Informix-list mailing list archive (1991-1998)
Vincent Kennedy wrote:
>
> I'm using informix4GL version 7 and want to pass a field name as a string
> into a prepared statement and execute the result into a variable.
> E.g
>
> let p_string1 = "select count(*) from temptable where field1 = ? "
> prepare p_sql1 from p_string1
Question is: does I4GL v7 accept this? The examples I've seen in the
manuals are for SQL, not 4GL.
Might need to do:
DECLARE c_sql1 cursor for p_sql1
OPEN c_sql1 using p_fieldName
--
John Carlson
Informix DBA
WHSmith USA
#include std_disclaimer.h /* These are my opinions, not my company's
opinion */
↪ replying to Vincent Kennedy
Carlson@WHSmith — — source: Informix-list mailing list archive (1991-1998)
Vincent Kennedy wrote:
>
> I'm using informix4GL version 7 and want to pass a field name as a string
> into a prepared statement and execute the result into a variable.
> E.g
>
> let p_string1 = "select count(*) from temptable where field1 = ? "
> prepare p_sql1 from p_string1
Question is: does I4GL v7 accept this? The examples I've seen in the
manuals are for SQL, not 4GL.
Might need to do:
DECLARE c_sql1 cursor for p_sql1
OPEN c_sql1 using p_fieldName
FETCH c_sql1 into p_count
--
John Carlson
Informix DBA
WHSmith USA
#include std_disclaimer.h /* These are my opinions, not my company's
opinion */
↪ replying to Vincent Kennedy
Jonathan Leffler — — source: Informix-list mailing list archive (1991-1998)
Vincent Kennedy wrote:
> I'm using informix4GL version 7 and want to pass a field name as a string
> into a prepared statement and execute the result into a variable.
> E.g
>
> let p_string1 = "select count(*) from temptable where field1 = ? "
> prepare p_sql1 from p_string1
> execute p_sql1 into p_count using p_fieldName
>
> It doesn't like the execute line. It seems to be the write sytnax from the
> manuals.
The I4GL manuals or the Informix Guide to SQL: Syntax manuals?
Which sub-version of I4GL (7.20 or 7.30)? You stand a better
chance of it working with 7.30 than with 7.20. However, in 7.30,
I'd expect to write:
SQL
SELECT COUNT(*) INTO $p_count
FROM temptable
WHERE field1 = $p_fieldName
END SQL
This avoids the memory leaks that arise from not freeing p_sql1 as well.
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix v0.95 -- see http://www.perl.com/CPAN
#include <disclaimer.h>
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.