pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
error codes in postgresql
5+ messages / 3 participants
[nested] [flat]

* error codes in postgresql
@ 2005-08-17 10:19  sandhya <sandhyar@amiindia.co.in>
  0 siblings, 0 replies; 5+ messages in thread

From: sandhya @ 2005-08-17 10:19 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Shashi Gireddy <gireddy@gmail.com>; pgsql-admin



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

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

* Re: error codes in postgresql
@ 2005-08-17 12:19  Sivakumar K <sivakumark@aztec.soft.net>
  0 siblings, 1 reply; 5+ messages in thread

From: Sivakumar K @ 2005-08-17 12:19 UTC (permalink / raw)
  To: sandhya <sandhyar@amiindia.co.in>; +Cc: Shashi Gireddy <gireddy@gmail.com>; pgsql-admin

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

 

 

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

* Re: error codes in postgresql
@ 2005-08-17 12:46  sandhya <sandhyar@amiindia.co.in>
  parent: Sivakumar K <sivakumark@aztec.soft.net>
  0 siblings, 0 replies; 5+ messages in thread

From: sandhya @ 2005-08-17 12:46 UTC (permalink / raw)
  To: Sivakumar K <sivakumark@aztec.soft.net>; +Cc: pgsql-admin

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

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

* Re: error codes in postgresql
@ 2005-08-17 14:03  Sivakumar K <sivakumark@aztec.soft.net>
  0 siblings, 0 replies; 5+ messages in thread

From: Sivakumar K @ 2005-08-17 14:03 UTC (permalink / raw)
  To: sandhya <sandhyar@amiindia.co.in>; +Cc: pgsql-admin

-----Original Message-----
From: sandhya [mailto:sandhyar@amiindia.co.in] 
Sent: Wednesday, August 17, 2005 6:16 PM
To: Sivakumar K
Cc: postgre; sandhya
Subject: Re: [ADMIN] error codes in postgresql

 

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?

 

            This will return whether your query was executed successfully or
not.

 

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.

This will return more detailed info regarding why the query execution was
not successful based on the fieldcode.

 

            For example

            If I execute select * from pg_databasesas (table does not exist)

 

            PQresStatus (PQresultStatus (res)) will return PGRES_FATAL_ERROR

 

            Whereas 

            

            PQresultErrorField (res, PG_DIAG_SQLSTATE) will return 42P01
which corresponds to "undefined table".

            PQresultErrorField (res, PG_ DIAG_MESSAGE_PRIMARY) will return
relation "pg_databasesa" does not exist.

 

            Note that the above API's will return information regarding
result set object only.

 

Normally we will be defining some errormessages according to the error codes
return by the PQErrorMessage function.

            

            I really wonder if PQErrorMessage returns error codes. AFAIK it
returns error messages.

 

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?

 

            Why do you want to define your own error messages when the
appropriate error message is returned from PostgreSQL Server?

 

            Please feel free to correct me

 

Thanks&Regards,

Sandhya

 

 

 

 

 

----- Original Message ----- 

From: Sivakumar <mailto:sivakumark@aztec.soft.net>  K 

To: sandhya <mailto:sandhyar@amiindia.co.in>  

Cc: Shashi Gireddy <mailto:gireddy@gmail.com>  ; postgre
<mailto:pgsql-admin@postgresql.org>  

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
<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>
[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

 

 

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

* Re: error codes in postgresql
@ 2005-08-23 04:24  Sivakumar K <sivakumark@pervasive-postgres.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Sivakumar K @ 2005-08-23 04:24 UTC (permalink / raw)
  To: sandhyar@amiindia.co.in; +Cc: pgsql-admin

 

Hi sandhya,

            I really wonder if the function name is pg_field_type (res,
col_no). 

The function name which returns the field type of a particular column is
PQftype (res, col_no).

This returns the field type as oid.The oid of the built-in data types
can be found in src/include/catalog/pg_type.h

 

When using libpq API's you need to include only "libpq-fe.h".

 

 

Is pg_field_type (res, col_no) an abstraction over PQftype (res, col_no)
in your case?

 

Regards,

Siva Kumar.K

 

 

 

-----Original Message-----
From: sandhya [mailto:sandhyar@amiindia.co.in] 
Sent: Monday, August 22, 2005 7:12 PM
To: Sivakumar K
Cc: postgre; sandhya
Subject: Re: [ADMIN] error codes in postgresql

 

Hi,

I have one doubt,

 

Inorder to get the field type in a table i am using
pg_field_type(res,col_no)

 

Col_no : Is the field no. for which i have to know the field type.

 

When i am using the above declaration, i am getting the error as,

pg_field_type undeclared(First use this function)

 

What i have to include?

I am unable to get.Pls Help me.

I have included 'libpq-fe.h".Otherthan this what i should include.

Pls help me in this regard,

 

Thanks&Regards,

Sandhya R

 

 

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


end of thread, other threads:[~2005-08-23 04:24 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-08-17 10:19 error codes in postgresql sandhya <sandhyar@amiindia.co.in>
2005-08-17 12:19 Re: error codes in postgresql Sivakumar K <sivakumark@aztec.soft.net>
2005-08-17 12:46 ` sandhya <sandhyar@amiindia.co.in>
2005-08-17 14:03 Re: error codes in postgresql Sivakumar K <sivakumark@aztec.soft.net>
2005-08-23 04:24 Re: error codes in postgresql Sivakumar K <sivakumark@pervasive-postgres.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