When use cursors..
I'm making a c++ program which insrt data into the database. Therefore
I use 8 different queries..
I use 6 cursors, only for the select querys.
res = PQexec(conn, "DECLARE mycursor CURSOR FOR SELECT * FROM foo
//do something with it..
res = PQexec(conn, "CLOSE mycursor");
For the insert querys i don't use cursors.
res = PQexec(conn, "INSERT INTO foo values(1);");
In the whole program I use 1 transaction, which I close when
everything is done.
I close each cursor after I'm done with it. But when the program runs
for a while, I get an error message
DECLARE CURSOR mycursor command failed.
which is produced by this code:
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
printf("DECLARE CURSOR mycursor command failed\n");
So it's obvious where it went wrong, the problem is, I don't know why.
I guess I'm using the cursors wrong.
But I can't find a good document on how to use them exactly, can
someone explain that to me, or knows a place where i can find
information on cursors..
And if it aren't the cursors that are wrong, can someone tell me
what's the cause then..