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

Status question

From: Louis Castoria <louisc(at)e9(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Status question
Date: 2005-10-26 12:46:31
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
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.


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) != ';' )
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

pgsql-interfaces by date

Next:From: Volkan YAZICIDate: 2005-10-26 14:08:26
Subject: Re: libpq status question
Previous:From: Tom LaneDate: 2005-10-26 03:34:21
Subject: Re: Interpreting PostgreSQL error messages

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