Basic beginner question

From: Rob Brown-Bayliss <rob(at)ZOOstation(dot)cc>
To: PostgreSQL <pgsql-interfaces(at)postgreSQL(dot)org>
Subject: Basic beginner question
Date: 2000-03-06 09:17:47
Message-ID: 20000306221747.A9242@ZOOstation.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces


Could some one tell me why this does not work? The second Cursor_DB()
fails. Also, is there a nicer way to output " to strings? The method I
have used is ugly!

Thanks

gint GetSync_DB(void)
{
gint sync_return=0;
char *updatekey;

Begin_DB();
Cursor_DB("DECLARE mycursor CURSOR FOR select * from sync_key");
FetchAll_DB();
/*
* The sync_key is a single field in a single row.
* That is the table has only a single peice of data, the key
*/
sync_return = atol(PQgetvalue(res, 0, 0));
printf("Sync_Key is %d\n",sync_return);
PQclear(res);
Commit_DB();
sprintf(updatekey,"DECLARE mycursor CURSOR FOR update %csync_key%c
set %ckey%c='%i' where oid=20565",34,34,34,34,sync_return+1);
printf("%s\n",updatekey);
Cursor_DB(updatekey);
Commit_DB();

return (sync_return);
}

void Cursor_DB(char *string)
{
res = PQexec(conn,string);
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
{
fprintf(stderr, "DECLARE CURSOR command failed\n");
PQclear(res);
exit_nicely(conn);
}
PQclear(res);
}

Rob Brown-Bayliss
---====<*>====---

live from ZOOstation
http://www.ZOOstation.cc

Browse pgsql-interfaces by date

  From Date Subject
Next Message Karan Bhalla 2000-03-06 11:37:47 Re: [INTERFACES] Quick perl question
Previous Message Ed Loehr 2000-03-05 20:01:38 [INTERFACES] RFC: server-side perl for pgsql?