Thread: Reg : Error Handling

Reg : Error Handling

From
"sandhya"
Date:
In error handling suppose if the database already exists..
 
It is returning : database "sample(say)" doesn't exists.
 
If i want to return general error messages with out specifying names how can i?
Tell me where can i get the error codes for this instead of messages and how can i retrieve error no instead of printing message?

Re: Reg : Error Handling

From
Michael Fuhr
Date:
On Wed, Oct 19, 2005 at 03:56:57PM +0530, sandhya wrote:
> In error handling suppose if the database already exists..
>
> It is returning : database "sample(say)" doesn't exists.

What is "it"?  What error handling are you talking about?  What are
you doing that results in the error, and why does the error message
(database doesn't exist) contradict what you first said (database
already exists)?  Or is that part of what's puzzling you?  What
does your query or function code (or whatever) look like, and what
is the *exact* text of the error message?

> If i want to return general error messages with out specifying names how can i?

Return error messages from where?

> Tell me where can i get the error codes for this instead of
> messages and how can i retrieve error no instead of printing message?

Please tell us more about what you're doing and what problem you're
trying to solve.  We don't have enough information to answer your
questions without a lot of guessing.

Incidentally, I notice that your Subject headers always begin with
the word "Reg".  What's that about?  I've seen it a few other places
but have never known what it meant.  Anybody?

--
Michael Fuhr

Re: Reg : Error Handling

From
"sandhya"
Date:
Reg stands for "regarding"

Error in the sence --->
I have a function to create a database and so on...... using libpqxx
library.
And i have a CLInterfacing program through which i can able to select option
which i want to do.
I am able to get the error messages if anything wrong i give......

But the errors are like below.
Say,If i have created a database called "sample" and when i try to give the
same database name to create againg it is displaying message like:
Database "sample" already exists-->Postgresql format
(Here the messages are Specific right)

What i want to manipulate is:
It should simply display
Database already exists --->Format i need
(The messages i need to display generally)

I am able to get the error code as a return value from the function using,
return (PQresultErrorField(res,PG_DIAG_SQLSTATE));
Problem is i don't know how to generalize the messages once i get
this....Pls any one help me in this regard

Thanks,
Sandhya



----- Original Message -----
From: "Michael Fuhr" <mike@fuhr.org>
To: "sandhya" <sandhyar@amiindia.co.in>
Cc: "postgre" <pgsql-admin@postgresql.org>
Sent: Wednesday, October 19, 2005 10:55 PM
Subject: Re: [ADMIN] Reg : Error Handling


> On Wed, Oct 19, 2005 at 03:56:57PM +0530, sandhya wrote:
> > In error handling suppose if the database already exists..
> >
> > It is returning : database "sample(say)" doesn't exists.
>
> What is "it"?  What error handling are you talking about?  What are
> you doing that results in the error, and why does the error message
> (database doesn't exist) contradict what you first said (database
> already exists)?  Or is that part of what's puzzling you?  What
> does your query or function code (or whatever) look like, and what
> is the *exact* text of the error message?
>
> > If i want to return general error messages with out specifying names how
can i?
>
> Return error messages from where?
>
> > Tell me where can i get the error codes for this instead of
> > messages and how can i retrieve error no instead of printing message?
>
> Please tell us more about what you're doing and what problem you're
> trying to solve.  We don't have enough information to answer your
> questions without a lot of guessing.
>
> Incidentally, I notice that your Subject headers always begin with
> the word "Reg".  What's that about?  I've seen it a few other places
> but have never known what it meant.  Anybody?
>
> --
> Michael Fuhr
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend


Re: Reg : Error Handling

From
Michael Fuhr
Date:
On Thu, Oct 20, 2005 at 10:30:36AM +0530, sandhya wrote:
> I am able to get the error code as a return value from the function using,
> return (PQresultErrorField(res,PG_DIAG_SQLSTATE));
> Problem is i don't know how to generalize the messages once i get
> this....Pls any one help me in this regard

The "PostgreSQL Error Codes" appendix to the documentation explains
what each SQLSTATE code means:

http://www.postgresql.org/docs/8.0/interactive/errcodes-appendix.html

See also server/utils/errcodes.h.  I haven't found anywhere in the
source code that provides mappings from SQLSTATE to generic messages,
so you'll probably have to do that yourself.

--
Michael Fuhr