Skip site navigation (1) Skip section navigation (2)

useing strings for cursors with libpq

From: Rob Brown-Bayliss <rob(at)ZOOstation(dot)cc>
To: PostgreSQL <pgsql-interfaces(at)postgreSQL(dot)org>
Subject: useing strings for cursors with libpq
Date: 2000-02-29 09:45:54
Message-ID: 20000229224554.A9931@ZOOstation.cc (view raw or flat)
Thread:
Lists: pgsql-interfaces
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

pgsql-interfaces by date

Next:From: Anjan BorthakurDate: 2000-02-29 10:50:43
Subject: postgres error
Previous:From: Jesper ZachoDate: 2000-02-29 08:01:14
Subject: [INTERFACES] JDBC JAVA Stream support for Large Object

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group