Thread: Catching internal error ID's to throw custom errors. Is it possib le in PostGreSQL?
Catching internal error ID's to throw custom errors. Is it possib le in PostGreSQL?
I have a lot of plpgsql functions and I would like to catch the original postgresql error and, based on that value, to throw with a raise or something my custom error. In SQL Server, for example, I have the sysmessages table in which I have all the possible values if the original errors. I catch that value (named @@error) and I call a function who have a parameter this value and who will return my custom value. This kind of error treatment permit me to have the same error ID's in Oracle, SQL Server and DB2, using a raise with the same error value. Is it possible to do the same in PostGreSQL using plpgsql language.
Thanks in advanced.
Stefan Ardeleanu
Database Expert / Business Analyst
SIVECO Romania SA
Business Address: 8-10 Bd. Mareşal Averescu
71316 Bucureşti, Sector 1, România
Web: http://www.siveco.ro
Business 1: +40 (21) 224 2531
Business 2: +40 (21) 224 2577
Business Fax: +40 (21) 224 4108
Stefan.Ardeleanu@siveco.ro wrote: > I have a lot of plpgsql functions and I would like to catch the original > postgresql error and, based on that value, to throw with a raise or > something my custom error. The section "Trapping Errors" in the plpgsql chapter of the manuals covers this. Does this not do what you want? -- Richard Huxton Archonet Ltd