Обсуждение: Access Error Details from PL/pgSQL

Поиск
Список
Период
Сортировка

Access Error Details from PL/pgSQL

От
"David E. Wheeler"
Дата:
Hackers,

In PL/pgSQL exception handling, I'm able to access the error code (SQLSTATE) and error message (SQLERRM). Is there any
wayto get at error details (yet)? If not, could SQLDETAIL or some such be added? 

Thanks,

David

Re: Access Error Details from PL/pgSQL

От
Pavel Stehule
Дата:
Hello

2012/2/13 David E. Wheeler <david@justatheory.com>:
> Hackers,
>
> In PL/pgSQL exception handling, I'm able to access the error code (SQLSTATE) and error message (SQLERRM). Is there
anyway to get at error details (yet)? If not, could SQLDETAIL or some such be added?
 
>

no in stable

http://www.depesz.com/2011/07/20/waiting-for-9-2-stacked-diagnostics-in-plpgsql/

Pavel

> Thanks,
>
> David
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers


Re: Access Error Details from PL/pgSQL

От
"David E. Wheeler"
Дата:
On Feb 13, 2012, at 9:30 AM, Pavel Stehule wrote:

> no in stable
>
> http://www.depesz.com/2011/07/20/waiting-for-9-2-stacked-diagnostics-in-plpgsql/

Ah, great, I had forgotten about that.

Thank you,

David



Re: Access Error Details from PL/pgSQL

От
aasat
Дата:
I have question. GET STACKED DIAGNOSTICS work only in exception block? is it
posible to use it in separate function called in exception block?


EXCEPTION  WHEN others THEN   peform log_error();
END;

CREATE OR REPLACE FUNCTION log_error() RETURNS boolean AS
$BODY$
declare   v_state   TEXT;   v_msg     TEXT;   v_detail  TEXT;   v_hint    TEXT;   v_context TEXT;
begin
 GET STACKED DIAGNOSTICS           v_state   = RETURNED_SQLSTATE,           v_msg     = MESSAGE_TEXT,
v_detail = PG_EXCEPTION_DETAIL,           v_hint    = PG_EXCEPTION_HINT,           v_context = PG_EXCEPTION_CONTEXT;
  raise notice E'Got exception:           state  : %           message: %           detail : %           hint   : %
     context: %', v_state, v_msg, v_detail, v_hint, v_context;
 
end;
$BODY$
LANGUAGE plpgsql VOLATILE;



--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Access-Error-Details-from-PL-pgSQL-tp5479926p5501584.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.


Re: Access Error Details from PL/pgSQL

От
Pavel Stehule
Дата:
Hello

2012/2/21 aasat <satriani@veranet.pl>:
> I have question. GET STACKED DIAGNOSTICS work only in exception block? is it
> posible to use it in separate function called in exception block?
>

Stacked diagnostick will be in 9.2 and it is allowed only in exception block.

Regards

Pavel Stehule

>
> EXCEPTION
>  WHEN others THEN
>    peform log_error();
> END;
>
> CREATE OR REPLACE FUNCTION log_error()
>  RETURNS boolean AS
> $BODY$
> declare
>    v_state   TEXT;
>    v_msg     TEXT;
>    v_detail  TEXT;
>    v_hint    TEXT;
>    v_context TEXT;
> begin
>
>  GET STACKED DIAGNOSTICS
>            v_state   = RETURNED_SQLSTATE,
>            v_msg     = MESSAGE_TEXT,
>            v_detail  = PG_EXCEPTION_DETAIL,
>            v_hint    = PG_EXCEPTION_HINT,
>            v_context = PG_EXCEPTION_CONTEXT;
>        raise notice E'Got exception:
>            state  : %
>            message: %
>            detail : %
>            hint   : %
>            context: %', v_state, v_msg, v_detail, v_hint, v_context;
> end;
> $BODY$
> LANGUAGE plpgsql VOLATILE;
>
>
>
> --
> View this message in context:
http://postgresql.1045698.n5.nabble.com/Access-Error-Details-from-PL-pgSQL-tp5479926p5501584.html
> Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers