Received: from ZOOstation.cc (IDENT:root@p778.nzwide.ihug.co.nz [203.109.254.13]) by hub.org (8.9.3/8.9.3) with ESMTP id EAA15006 for ; Mon, 6 Mar 2000 04:23:25 -0500 (EST) (envelope-from rob@ZOOstation.cc) Received: (from rob@localhost) by ZOOstation.cc (8.9.3/8.8.7) id WAA09256 for pgsql-interfaces@postgreSQL.org; Mon, 6 Mar 2000 22:19:08 +1300 Date: Mon, 6 Mar 2000 22:17:47 +1300 From: Rob Brown-Bayliss To: PostgreSQL Subject: Basic beginner question Message-ID: <20000306221747.A9242@ZOOstation.cc> Reply-To: Rob Brown-Bayliss Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Mailer: Balsa 0.6.0 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