PQexecParams and CURSOR - Mailing list pgsql-general

From Laurent Marzullo
Subject PQexecParams and CURSOR
Date
Msg-id NDEKIMJLKBNGEIOBDFOJEECADEAA.laurent.marzullo@atosorigin.com
Whole thread Raw
Responses Re: PQexecParams and CURSOR
List 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


pgsql-general by date:

Previous
From: mike
Date:
Subject: Invalid input for numeric problem
Next
From: Roman Neuhauser
Date:
Subject: pl/pgsql trigger: syntax error at or near "ELSEIF"