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: Status question
Date: Wed, 26 Oct 2005 07:46:31 -0500
Message-ID: <435F7AA7.3060508@e9.com> (raw)

I'm confused about something and need some help.  I wrote a c routine 
that uses libpq.    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 
successful 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;                                               
}                                                                              

}

-- 



            Louis  Castoria  -  ADSI
            Software Engineer
            1930 First Commercial  Drive
            Southaven MS,  38671
            Phone: 662-393-2046
            WEB: http://www.e9.com
                 






Message-ID: <435F7AA7.3060508@e9.com>
Permalink:  ../435F7AA7.3060508@e9.com/
Also on:    postgresql.org/message-id/435F7AA7.3060508@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: Status question
  In-Reply-To: <435F7AA7.3060508@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