X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AE3C652938 for ; Wed, 17 Aug 2005 09:39:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 75593-04 for ; Wed, 17 Aug 2005 12:39:49 +0000 (GMT) Received: from amiindia.co.in (unknown [203.199.198.234]) by svr1.postgresql.org (Postfix) with ESMTP id DC7D9528DB for ; Wed, 17 Aug 2005 09:39:32 -0300 (ADT) Received: from venus.amiindia.co.in (localhost.localdomain [127.0.0.1]) by amiindia.co.in (8.12.10/8.12.11) with ESMTP id j7HCFirh017556; Wed, 17 Aug 2005 17:45:49 +0530 Received: from amiindiahjwbgh (unknown [10.0.0.205])by venus.amiindia.co.in (Postfix) with ESMTPid AA6D04FC060; Wed, 17 Aug 2005 17:45:33 +0530 (IST) Message-ID: <010701c5a329$a89e7230$cd00000a@amiindiahjwbgh> From: "sandhya" To: "Sivakumar K" Cc: "postgre" References: <584DE893B0E08F4B9748E295029F1E9702C1114A@maya.aztec.soft.net> Subject: Re: error codes in postgresql Date: Wed, 17 Aug 2005 18:16:01 +0530 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00FB_01C5A357.B9226B10" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-imss-version: 2.5 X-imss-result: Passed X-imss-scores: Clean:99.90000 C:21 M:3 S:5 R:5 X-imss-settings: Baseline:1 C:1 M:1 S:1 R:1 (0.0000 0.0000) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.051 required=5 tests=[AWL=-0.000, FORGED_RCVD_HELO=0.05, HTML_MESSAGE=0.001] X-Spam-Level: X-Archive-Number: 200508/213 X-Sequence-Number: 18532 This is a multi-part message in MIME format. ------=_NextPart_000_00FB_01C5A357.B9226B10 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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=20 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 -----=20 From: Sivakumar K=20 To: sandhya=20 Cc: Shashi Gireddy ; postgre=20 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, =20 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=3D"dbname=3Dexample(dname) user=3Dpostgres(uname)"; conn=3DPQConnectdb(conninfo) //After connecting i need to create a table..and if the table exists=20 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 ------=_NextPart_000_00FB_01C5A357.B9226B10 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Thank you Sivakumar.
ExecStatusType PQresultStatus(const PGresult *res);
Will it return code or message.If i want to use this what should be = the=20 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=20 this?
PG_DIAG_SQLSTATE--If i use this as my fieldcode = will it=20 take care of all my error values.
Sorry for my basic questions.As i am very new to = this i=20 don't know how to handle errors in
this.
Normally we will be defining some errormessages = according=20 to the error codes return by the PQErrorMessage function.
When i am using this even i declare my function = as=20 void..it is returning the errormessage.
So..what iam planning is if i have some error = codes=20 returning from any of my postgresql function i can define myown message = for that=20 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 -----
To: sandhya
Cc: Shashi Gireddy ; postgre
Sent: Wednesday, August 17, = 2005 5:49=20 PM
Subject: RE: [ADMIN] error = codes in=20 postgresql

Hi sandhya,

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

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

      For more = information=20 you can check the libpq API documentation

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

 

      Is this what = you=20 want?

 

 

Regards,

Siva=20 Kumar.K

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

 

 

 

Hi,

  =20

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

For = ex:

 

If i am using my = connection=20 function say,

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

{

//here i use postgres = connection=20 function

pg_conn=20 *conn;

conninfo=3D"dbname=3Dexample(dname)=20 user=3Dpostgres(uname)";

conn=3DPQConnectdb(conninfo)

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

PQerrormessage(conn) = will return=20 error message...

But what i need is=20 ..

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

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

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

Any help=20 please......

 

Thank=20 you...

Regards,

Sandhya = R

 

 

------=_NextPart_000_00FB_01C5A357.B9226B10--