Add diagnostics info to warning #314

This commit is contained in:
Rafa de la Torre 2016-12-13 19:19:03 +01:00
parent dbd5911a2a
commit 842be0ba85

View File

@ -27,12 +27,19 @@ BEGIN
RAISE WARNING 'whatever';
END;
<% elsif multi_field %>
DECLARE
_returned_sqlstate TEXT;
_message_text TEXT;
_pg_exception_context TEXT;
BEGIN
SELECT * FROM <%= DATASERVICES_CLIENT_SCHEMA %>._<%= name %>(<%= ['username', 'orgname'].concat(params).join(', ') %>) INTO ret;
RETURN ret;
EXCEPTION
WHEN OTHERS THEN
RAISE WARNING 'whatever';
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
_message_text = MESSAGE_TEXT,
_pg_exception_context = PG_EXCEPTION_CONTEXT;
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
RETURN ret;
END;
<% else %>