Skip site navigation (1) Skip section navigation (2)

plpgsql errorcodes

From: "Robert Wimmer" <seppwimmer(at)hotmail(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: plpgsql errorcodes
Date: 2004-12-16 23:52:39
Message-ID: BAY10-F10DF16D4924A5135BC8DC8D0AE0@phx.gbl (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces

i want the DB functionality to be done by the server. this means i want to 
write functions like


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 

ERROR(23890) : 'invalid numeric format'


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



Immer für Sie da. MSN Hotmail. Jetzt 
kostenlos anmelden und überall erreichbar sein!


pgsql-interfaces by date

Next:From: Tom LaneDate: 2004-12-17 02:17:43
Subject: Re: [INTERFACES] PL/Python: How do I use result methods?
Previous:From: Jan WieckDate: 2004-12-16 18:05:46
Subject: Re: Lost updates vs resumable connections/transactions

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group