pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Brown-Bayliss <rob@ZOOstation.cc>
To: PostgreSQL <pgsql-interfaces@postgreSQL.org>
Subject: useing strings for cursors with libpq
Date: Tue, 29 Feb 2000 22:45:54 +1300
Message-ID: <20000229224554.A9931@ZOOstation.cc> (raw)

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



Message-ID: <20000229224554.A9931@ZOOstation.cc>
Permalink:  ../20000229224554.A9931@ZOOstation.cc/
Also on:    postgresql.org/message-id/20000229224554.A9931@ZOOstation.cc

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: rob@ZOOstation.cc
  Subject: Re: useing strings for cursors with libpq
  In-Reply-To: <20000229224554.A9931@ZOOstation.cc>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox