pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: sandhya <sandhyar@amiindia.co.in>
To: Sivakumar K <sivakumark@aztec.soft.net>
Cc: postgre <pgsql-admin@postgresql.org>
Subject: Re: error codes in postgresql
Date: Wed, 17 Aug 2005 18:16:01 +0530
Message-ID: <010701c5a329$a89e7230$cd00000a@amiindiahjwbgh> (raw)
References: <584DE893B0E08F4B9748E295029F1E9702C1114A@maya.aztec.soft.net>

Thank you Sivakumar.
ExecStatusType PQresultStatus(const PGresult *res);
Will it return code or message.If i want to use this what should be the return value of my function?

Onemore doubt..
char *PQresultErrorField(const PGresult *res, int fieldcode);
What is the use of this?What is the difference between the previous one and this?
PG_DIAG_SQLSTATE--If i use this as my fieldcode will it take care of all my error values.
Sorry for my basic questions.As i am very new to this i don't know how to handle errors in 
this.
Normally we will be defining some errormessages according to the error codes return by the PQErrorMessage function.
When i am using this even i declare my function as void..it is returning the errormessage.
So..what iam planning is if i have some error codes returning from any of my postgresql function i can define myown message for that and i can send it as a return value to the main right!
Please tell me how can i handle this?

Thanks&Regards,
Sandhya





  ----- Original Message ----- 
  From: Sivakumar K 
  To: sandhya 
  Cc: Shashi Gireddy ; postgre 
  Sent: Wednesday, August 17, 2005 5:49 PM
  Subject: RE: [ADMIN] error codes in postgresql


  Hi sandhya,

        You can use PQresultStatus API to get the result status of the command execution

        And PQresStatus to convert the enumerated type returned by PQresultStatus to a string constant.

        For more information you can check the libpq API documentation

        http://www.postgresql.org/docs/8.0/static/libpq-exec.html



        Is this what you want?





  Regards,

  Siva Kumar.K

  -----Original Message-----
  From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of sandhya
  Sent: Wednesday, August 17, 2005 3:49 PM
  To: Tom Lane
  Cc: Shashi Gireddy; postgre
  Subject: [ADMIN] error codes in postgresql







  Hi,

     

     I want to know ,if there is any way to return  error codes/numbers as  a return value from the postgresql functions.

  For ex:



  If i am using my connection function say,

  DbConnect(dname,uname,.........)

  {

  //here i use postgres connection function

  pg_conn *conn;

  conninfo="dbname=example(dname) user=postgres(uname)";

  conn=PQConnectdb(conninfo)

  //After connecting i need to create a table..and if the table exists 

  PQerrormessage(conn) will return error message...

  But what i need is ..

  Is there any other way of returning error number to my main program.

  Can you please tell me how to handle these errors in my application.

  I referred posgresql site..I didn't get any clear idea of it.

  Any help please......



  Thank you...

  Regards,

  Sandhya R

view thread (5+ messages)  latest in thread

Message-ID: <010701c5a329$a89e7230$cd00000a@amiindiahjwbgh>
Permalink:  ../010701c5a329$a89e7230$cd00000a@amiindiahjwbgh/
Also on:    postgresql.org/message-id/010701c5a329$a89e7230$cd00000a@amiindiahjwbgh

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: sandhyar@amiindia.co.in, sivakumark@aztec.soft.net
  Subject: Re: error codes in postgresql
  In-Reply-To: <010701c5a329$a89e7230$cd00000a@amiindiahjwbgh>
  References: <584DE893B0E08F4B9748E295029F1E9702C1114A@maya.aztec.soft.net> <010701c5a329$a89e7230$cd00000a@amiindiahjwbgh>

* 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