Hello all,
(and sorry if this has been aswered before)

Take this piece of code for example:
.....................
begin
    _res.code:=1;
    select id into iid from log where id=_id;
    if not found then begin
        _res.msg:=''insert'';
        insert into log (log, data) values (_log, _data);
        if not found
then begin
            _res.msg:=_res.msg || '' error'';
            _res.code:=-1;
        end;
        end if;
    end;
    else begin
.....................
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.

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.code in this case).

Is there anything I can do to make sure the function always returns _res ?
Something along the lines of Oracle's exception handling, or the @@error trick in mssql ?


Regards,
--
Radu-Adrian Popescu
CSA, DBA, Developer
Aldratech Ltd.