From: Robert Wimmer <seppwimmer@hotmail.com>
To: pgsql-interfaces@postgresql.org
Subject: plpgsql errorcodes
Date: Thu, 16 Dec 2004 23:52:39 +0000
Message-ID: <BAY10-F10DF16D4924A5135BC8DC8D0AE0@phx.gbl> (raw)
hi,
i want the DB functionality to be done by the server. this means i want to
write functions like
CREATE FUNCTION insert_any(....) RETURNS INT AS '
BEGIN
END; '
LANGUAGE 'plpgsql'
returning an errorcode so i can map this errorcode to a message for the user
of the client. and i want to do this on the server without using any
special java or php command on the client side.
the only thing postgreSQL returns - if an error occured - is a textual
message you cant use for telling the user what happend.
one thing i want to know - inside the function - is why postgre stopped
working. something like
num := CAST($1 AS INT);
IF ERROR THEN RETURN -3; END IF; -- "cannot convert to integer"
because i do not want to reenvent the wheel. if there is a conversion
function i want to use it, and i want to know if or why it failed.
besides i have written simple type checking functions doing the following
// php
$ret = pg_call("SELECT checkInteger('abc')");
if ($ret != 0) $msg = pg_call("SELECT getErrorMessage($ret,'german')");
else ...
i can use the same functions in every client program (java, VB, C ..).
but i think it is absurd to do the same thing twice. postgre checks it also
in the CAST
statement. the only thing i want to know is what happend. even a parseable
errorcode
like
ERROR(23890) : 'invalid numeric format'
or
ERROR(100) constraint 'myConstraintName '
would be helpfull
is there ANY possibility to catch errorcodes in plpqsql ?
is there ANY possibility to catch errorcodes otherwise ?
i am using postgreSQL 7.4
thanx
Sepp
_________________________________________________________________
Immer für Sie da. MSN Hotmail. http://www.msn.de/email/webbased/ Jetzt
kostenlos anmelden und überall erreichbar sein!
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 using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: seppwimmer@hotmail.com
Subject: Re: plpgsql errorcodes
In-Reply-To: <BAY10-F10DF16D4924A5135BC8DC8D0AE0@phx.gbl>
* 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