Received: from ZOOstation.cc (IDENT:root@p998.nzwide.ihug.co.nz [203.109.254.233]) by hub.org (8.9.3/8.9.3) with ESMTP id EAA80491 for ; Tue, 29 Feb 2000 04:47:58 -0500 (EST) (envelope-from rob@ZOOstation.cc) Received: (from rob@localhost) by ZOOstation.cc (8.9.3/8.8.7) id WAA09945 for pgsql-interfaces@postgreSQL.org; Tue, 29 Feb 2000 22:47:01 +1300 Date: Tue, 29 Feb 2000 22:45:54 +1300 From: Rob Brown-Bayliss To: PostgreSQL Subject: useing strings for cursors with libpq Message-ID: <20000229224554.A9931@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 Hi all. I am trying to pass a cursor to a function like so: void Begin_DB(gchar *cursor) { GString *tempstring; gchar *thecursor; tempstring = g_string_new("DECLARE mycursor CURSOR FOR "); g_string_append(tempstring, cursor); thecursor = tempstring->str; g_string_free(tempstring, FALSE); printf("%s",thecursor); res = PQexec(conn, "BEGIN"); if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr, "BEGIN command failed\n"); PQclear(res); exit_nicely(conn); } PQclear(res); /* * fetch instances from the players. */ res = PQexec(conn, thecursor); if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr, "DECLARE CURSOR command failed\n"); PQclear(res); exit_nicely(conn); } PQclear(res); } but it always fails. Is it possible to pass a cursor like this? (I am a long way from being a C expert but it appears to me that thecursor has the string I am looking for) Rob Brown-Bayliss ---====<*>====--- live from ZOOstation http://www.ZOOstation.cc