Search Postgresql Archives

PQexecParams and CURSOR

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux