plpgsql errorcodes
От | Robert Wimmer |
---|---|
Тема | plpgsql errorcodes |
Дата | |
Msg-id | BAY10-F10DF16D4924A5135BC8DC8D0AE0@phx.gbl обсуждение исходный текст |
Список | pgsql-interfaces |
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!
В списке pgsql-interfaces по дате отправления: