PQexecParams and CURSOR

From: "Laurent Marzullo" <laurent(dot)marzullo(at)atosorigin(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: PQexecParams and CURSOR
Date: 2005-01-14 11:31:24
Message-ID: NDEKIMJLKBNGEIOBDFOJEECADEAA.laurent.marzullo@atosorigin.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I Could not achieve to use CURSOR with PQexecParams ! How to you do ?

Here what I've done:
1)------------------------------------

paramValues[0] = "2"; // This is the parameter for the query

res = PQexec( conn , "DECLARE MY_CURSOR FOR "
"SELECT * FROM GRGL.RANGE_MODIFIER "
"WHERE WEAPON_ID = $1" );

=> ERROR
DECLARE failed: ERROR: There is no parameter 1

2)------------------------------------
then
paramValues[0] = "2"; // This is the parameter for the query

res = PQexecParams( conn ,
"DECLARE MY_CURSOR FOR "
"SELECT * FROM GRGL.RANGE_MODIFIER "
"WHERE WEAPON_ID = $1",
1,
NULL,
paramValues,
NULL,
NULL,
0);

res = PQexec( conn , "FETCH 1 FROM MY_CURSOR" );

=> Error
FETCH failed: ERROR: no value found for parameter 1

3)--------------------------------------
then
paramValues[0] = "2"; // This is the parameter for the query

res = PQexecParams( conn ,
"DECLARE MY_CURSOR FOR "
"SELECT * FROM GRGL.RANGE_MODIFIER "
"WHERE WEAPON_ID = $1" ,
1,
NULL,
paramValues,
NULL,
NULL,
0); );

res = PQexecParams( conn ,
"FETCH 1 FROM MY_CURSOR",
1,
NULL,
paramValues,
NULL,
NULL,
0);

=> Error:
FETCH failed: ERROR: bind message supplies 1 parameters, but prepared
statement "" requires 0

PLEASE, COULD YOU HELP ? THANKS.

Laurent Marzullo

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Roman Neuhauser 2005-01-14 12:06:25 pl/pgsql trigger: syntax error at or near "ELSEIF"
Previous Message mike 2005-01-14 11:28:50 Invalid input for numeric problem