X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C082E3CB680 for ; Thu, 16 Dec 2004 23:53:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57097-09 for ; Thu, 16 Dec 2004 23:53:04 +0000 (GMT) Received: from hotmail.com (bay10-f10.bay10.hotmail.com [64.4.37.10]) by svr1.postgresql.org (Postfix) with ESMTP id 20F8E3CB676 for ; Thu, 16 Dec 2004 23:53:06 +0000 (GMT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 16 Dec 2004 15:53:04 -0800 Message-ID: Received: from 62.178.117.119 by by10fd.bay10.hotmail.msn.com with HTTP; Thu, 16 Dec 2004 23:52:39 GMT X-Originating-IP: [62.178.117.119] X-Originating-Email: [seppwimmer@hotmail.com] X-Sender: seppwimmer@hotmail.com From: "Robert Wimmer" To: pgsql-interfaces@postgresql.org Subject: plpgsql errorcodes Date: Thu, 16 Dec 2004 23:52:39 +0000 Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed X-OriginalArrivalTime: 16 Dec 2004 23:53:04.0339 (UTC) FILETIME=[622F6A30:01C4E3CA] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.032 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, MSGID_FROM_MTA_HEADER X-Spam-Level: * X-Archive-Number: 200412/28 X-Sequence-Number: 5198 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!