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: Basic beginner question
Date: Mon, 6 Mar 2000 22:17:47 +1300
Message-ID: <20000306221747.A9242@ZOOstation.cc> (raw)


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



Message-ID: <20000306221747.A9242@ZOOstation.cc>
Permalink:  ../20000306221747.A9242@ZOOstation.cc/
Also on:    postgresql.org/message-id/20000306221747.A9242@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: Basic beginner question
  In-Reply-To: <20000306221747.A9242@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