The following works executed in the query browser:
PREPARE myquery (text) AS INSERT INTO myTable (word) VALUES ($1);
EXECUTE myquery('blah');
The following works in C++, executed as two statements with PQexecParams
using PQEXECPARAM_FORMAT_BINARY
PREPARE myquery AS INSERT INTO myTable (word) VALUES ('blah');
EXECUTE myquery;
The following does not work in C++, executed as above, in another session
using two subsequent calls to PQexecParams
PREPARE myquery (text) AS INSERT INTO myTable (word) VALUES ($1);
EXECUTE myquery($1::text);
The error is:
+lastError0x00dc4232 ERROR: bind message supplies 1
parameters, but prepared statement requires 0
char [1024]
Code is:
PQexecParams(pgConn,
query.C_String(),indices.Size(),0,paramData,paramLength,paramFormat,PQEXECPARAM_FORMAT_BINARY);
Parameters:
+paramData[0]0x00e00208 blahchar *
paramLength[0]4int
paramFormat[0]1int
indices.Size()1unsigned int
The difference between the two C++ calls is that the 2nd call has parameters
passed to the prepared statement, while the first does not.
Any ideas? Note that it is saying that the prepared statement is , rather
than the name of the prepared statement. It also says 0 parameters, although
it takes 1 parameter.