pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
libpq status question
2+ messages / 2 participants
[nested] [flat]

* libpq status question
@ 2005-10-25 17:04  Louis Castoria <louisc@e9.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Louis Castoria @ 2005-10-25 17:04 UTC (permalink / raw)
  To: pgsql-interfaces

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;                                               
}                                                                              








^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: libpq status question
@ 2005-10-26 14:08  Volkan YAZICI <volkan.yazici@gmail.com>
  parent: Louis Castoria <louisc@e9.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Volkan YAZICI @ 2005-10-26 14:08 UTC (permalink / raw)
  To: Louis Castoria <louisc@e9.com>; +Cc: pgsql-interfaces

Hi,

On 10/25/05, Louis Castoria <louisc@e9.com> wrote:
> How can I tell if the update was successfully or not.

You can use PQcmdTuples() function to learn the number of rows
affected by the SQL command.

Regards.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-10-26 14:08 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-10-25 17:04 libpq status question Louis Castoria <louisc@e9.com>
2005-10-26 14:08 ` Volkan YAZICI <volkan.yazici@gmail.com>

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