I am newbie in postgresql and trying to insert the values in db with PQexecparams. When i bind two parameters in values array it works perfectly but when i move to three it shows an error "INSERT failed: cannot allocate memory for output buffer" Here is my code:
void InsertBinaryRec(PGconn *conn, double *valueX, char *nameString, double *valueY)
{
int paramLengths[10];
int paramFormats[3] = { 1, 0, 1 };
const char* values[3] = {(const char *) valueX, nameString, (const char *) valueY };
cout << "ya phr gya????" << endl;
paramLengths[3] = 10 ;
PGresult *res = PQexecParams(conn,
"INSERT INTO testData (X, NAME, Y) VALUES ($1::bytea, $2::TEXT, $3::bytea)",
3,
NULL,
values,
paramLengths,
paramFormats,
3);
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
fprintf(stderr, "INSERT failed: %s\n", PQerrorMessage(conn));
PQclear(res);
CloseConn(conn);
}
cout << "Insert testData record - OK\n";
PQclear(res);
}
bytea?