Catching DML exceptions in PL/pgSQL

Поиск
Список
Период
Сортировка
От Radu-Adrian Popescu
Тема Catching DML exceptions in PL/pgSQL
Дата
Msg-id 5.2.1.1.0.20030617121526.02185a50@192.168.0.1
обсуждение исходный текст
Ответы Re: Catching DML exceptions in PL/pgSQL  (Tomasz Myrta <jasiek@klaster.net>)
Re: Catching DML exceptions in PL/pgSQL  (Joe Conway <mail@joeconway.com>)
Список pgsql-sql
Hello all,<br /> (and sorry if this has been aswered before)<br /><br /> Take this piece of code for example:<br />
.....................<br/><font face="Courier, Courier">begin<br />     _res.code:=1;<br />     select id into iid from
logwhere id=_id;<br />     if not found then begin<br />         _res.msg:=''insert'';<br />         <b>insert into log
(log,data) values (_log, _data);<br />         if not found</b> then begin<br />             _res.msg:=_res.msg || ''
error'';<br/>             _res.code:=-1;<br />         end;<br />         end if;<br />     end;<br />     else
begin<br/></font>.....................<br /> The thing is if _data (parameter) is null and table has a (data <>
null)check, the insert would fail and abort the function before my "if not found" test.<br /><br /> I'm porting a java
app.from mssql to postgresql, and the java code relies on the stored procedure to always return it's status (in
_res.codein this case).<br /><br /> Is there anything I can do to make sure the function always returns _res ?<br />
Somethingalong the lines of Oracle's exception handling, or the @@error trick in mssql ?<br /><br /><br /><p>
Regards,<br/> --<br /> Radu-Adrian Popescu<br /> CSA, DBA, Developer<br /> Aldratech Ltd. 

В списке pgsql-sql по дате отправления:

Предыдущее
От: "cristi"
Дата:
Сообщение: Blobs with perl
Следующее
От: Tomasz Myrta
Дата:
Сообщение: Re: Catching DML exceptions in PL/pgSQL