plpgsql: how to get the exception's detail information?

Поиск
Список
Период
Сортировка
От Muiz
Тема plpgsql: how to get the exception's detail information?
Дата
Msg-id CAF2hCqwHuGtzni6uDMAwSSh8cBtBAj9xOVGPZJc1v4_RAh6cJg@mail.gmail.com
обсуждение исходный текст
Ответы Re: plpgsql: how to get the exception's detail information?  (Filip Rembiałkowski <plk.zuber@gmail.com>)
Список pgsql-sql
Dear all,

   I write a function to execute a sql string. E.g. "update tableA set field1='abc' where name='123'; deletee from tableB where id=333;"
   The following is my function: 
-----------------------------------------------------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION no_err_rollback()
  RETURNS boolean AS
$BODY$
BEGIN
    ROLLBACK;
    RETURN TRUE;
EXCEPTION
     WHEN others THEN
            RETURN TRUE;
END
$BODY$
  LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION execsqls(sqls character varying)
  RETURNS boolean AS
$BODY$
DECLARE
           r BOOLEAN;
BEGIN
           EXECUTE sqls;
           -- TODO-1: I want to know how many records the input sqls effects?
           RETURN TRUE;
EXCEPTION
           WHEN others THEN
                   SELECT no_err_rollback() INTO r;
                   -- TODO-2: I want to get the exception's code and detail information. can I ?
                   RAISE EXCEPTION 'Error: %', 'abc';

END; 
$BODY$
  LANGUAGE plpgsql;
-----------------------------------------------------------------------------------------------------------------------------

My Questions are:
 1. when I execute a sql, can I get the total records user updated or deleted ?
 2. if I cache the exceptions, can I get the detail information?

--
Regards,
Muiz


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

Предыдущее
От: David Johnston
Дата:
Сообщение: Re: running totals with end of month line
Следующее
От: Filip Rembiałkowski
Дата:
Сообщение: Re: plpgsql: how to get the exception's detail information?