From: | Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz> |
---|---|
To: | Ali Baba <idofyear(at)yahoo(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org, <pgsql-patches(at)postgresql(dot)org> |
Subject: | Implementation of SQLCODE and SQLERRM variables for PL/pgSQL |
Date: | 2005-03-06 19:24:38 |
Message-ID: | Pine.LNX.4.44.0503062003220.32436-600000@kix.fsv.cvut.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
Hello
This is my second patch, than please will be tolerant :-). For one my
project I miss information about exception when I use EXCEPTION WITH
OTHERS THEN. I found two Oracle's varaibles SQLCODE and SQLERRM which
carry this information. With patch you can:
--
-- Test of built variables SQLERRM and SQLCODE
--
create or replace function trap_exceptions() returns void as $_$
begin
begin
raise exception 'first exception';
exception when others then
raise notice '% %', SQLCODE, SQLERRM;
end;
raise notice '% %', SQLCODE, SQLERRM;
begin
raise exception 'last exception';
exception when others then
raise notice '% %', SQLCODE, SQLERRM;
end;
return;
end; $_$ language plpgsql;
select trap_exceptions();
drop function trap_exceptions();
CREATE FUNCTION
NOTICE: P0001 first exception
NOTICE: 000000 Sucessful completion
NOTICE: P0001 last exception
trap_exceptions
-----------------
(1 row)
DROP FUNCTION
Regards,
Pavel Stehule
Attachment | Content-Type | Size |
---|---|---|
test.sql | text/plain | 538 bytes |
test.out | text/plain | 187 bytes |
plpgsql.h.diff | text/plain | 66 bytes |
pl_exec.c.diff | text/plain | 1.0 KB |
gram.y.diff | text/plain | 1.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-03-06 20:05:05 | Re: Implementation of SQLCODE and SQLERRM variables for PL/pgSQL |
Previous Message | Tom Lane | 2005-03-06 19:14:47 | Speeding up tupledesc copying |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-03-06 19:52:08 | Re: Cleaning up unreferenced table files |
Previous Message | Neil Conway | 2005-03-06 08:49:05 | Re: Display Pg buffer cache (WIP) |