pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Louis Castoria <louisc@e9.com>
To: pgsql-interfaces@postgresql.org
Subject: libpq status question
Date: Tue, 25 Oct 2005 12:04:33 -0500
Message-ID: <435E65A1.7030907@e9.com> (raw)

I'm confused about something and need some help.  I wrote a c routine 
that uses libpq.  The result codes  are good when I use a select or 
insert.  if  I use an update  sql command  string like "update 
largetable set t01='update1', t02='update2' where mainkey='12'" and the 
mainkey of 12 does not exist the result code is a 0 if the mainkey 
exists I get a result of 0.  How can I tell if the update was 
successfully or not.  Here is the code.

void                                                                           

pgsql_exec_query( int *dbhandle, char *query, int *qryhandle, int 
*status ) { 
        char 
*r,*n=query;                                                     
        int nfields, i, 
j;                                                    
        PGconn *conn = (PGconn 
*)*dbhandle;                                   
        PGresult 
*res;                                                        
        while ( *n != ';' || *(n+1) != ';' ) 
n++;                             
        
*n=0;                                                                 
        res = 
0;                                                              
        res = PQexec(conn, 
query);                                            
        printf("Result = %d ", (int) 
res);                                    
        *status = 
PQresultStatus(res);                                        
        printf("status = %f", (int) 
status);                                  
        *qryhandle = (int) 
res;                                               
}                                                                              








view thread (2+ messages)  latest in thread

Message-ID: <435E65A1.7030907@e9.com>
Permalink:  ../435E65A1.7030907@e9.com/
Also on:    postgresql.org/message-id/435E65A1.7030907@e9.com

 · 

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: louisc@e9.com
  Subject: Re: libpq status question
  In-Reply-To: <435E65A1.7030907@e9.com>

* 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