catch runtime errors

From: "Robert Wimmer" <seppwimmer(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: catch runtime errors
Date: 2004-12-01 16:56:04
Message-ID: BAY10-F501BF8D0481F8D6D3A4D11D0BF0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

hi,

is there a possibility to catch runtime errors in pgplsql function ? i did
not find anything about this in the docs. what i want to do is to check all
values in a database function before doing any uptates or inserts.

for example (psudo code)

CREATE FUNCTION insert_xxx(TEXT,TEXT) RETURNS INT AS '
DECLARE id INTEGER;
d DATE;
BEGIN
-- check if $1 is integer
id := CAST($1 AS INT);
IF xxxError THEN RETURN -1; END IF;
-- check if $2 is date
d := CAST($2 AS DATE);
IF xxxError THEN RETURN -2; END IF;
...
RETURN 0;
END; '
......

i want to avoid to write different conversion tools for maybe php or java or
c or even VB. there is a function somewhere inside psql thats checking it -
because it causes a runtime error if something is wrong - why reinvent the
wheel (4 times!) ?

bye and thanks

sepp

_________________________________________________________________
Schaffen Sie das Platzproblem in Ihrem E-Mail-Konto für immer aus der Welt!
http://join.msn.com/?pgmarket=de-at&DI=1031&XAPID=1581

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2004-12-01 19:04:35 Re: Data directory copies...
Previous Message Bruno Wolff III 2004-12-01 14:49:44 Re: remove too much space between words of the string