rollback to savepoint issue

Поиск
Список
Период
Сортировка
От Lorusso Domenico
Тема rollback to savepoint issue
Дата
Msg-id CAJMpnG7DAcz4ckE_GGN4VkjaJvzVrdwCYwjH+ocLnVVYvb-fcQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: rollback to savepoint issue  (Erik Wienhold <ewie@ewie.name>)
Список pgsql-general
Hello guys,
I can't use the savepoint and rollback to savepoint clause.
I've found some similar problems around on the web, but I can't catch the good way to proceed.

What I'm trying to do is:
  • compare new set of attribute with older
  • if some attributes are part of old set and not in the new one: delete the old
  • but if parameter "on_misisng_delete" is false rollback delete command and rais exception
The original code in embedded in a function, but the problem is the same:
ERROR:  syntax error at or near "to"
LINE 41:   rollback to savepoint deleteAttribute;
                    ^

SQL state: 42601
Character: 768



Code extracted:
do $body$
declare
on_missing_delete  boolean=false;
_i integer;
_vAttributeName text='paperi';
_importo integer= 5000;
begin
savepoint deleteAttribute;

execute format($$
with ru as (
update  public.%I as q
set is_closed=true
, modify_user_id='process:definitionUpdate'
where q.importo > $1
returning 1
)
select count(*) from ru
;$$
, _vAttributeName)
using _importo
into _i;
--> If I can't delete and there are row to delete raise excpetion
if not on_missing_delete  and _i > 0 then
--> undo deletion
rollback to savepoint deleteAttribute;

raise exception 'New attributes list foresees to remove % attribute(s), but parameter "on missing delete" is false.', _i;
else
release savepoint deleteAttribute;
end if;

rollback;
end;
$body$;



I know I can modify the code, but I wish to understand why I can't use rollback to save point

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

Предыдущее
От: Arthur Bazin
Дата:
Сообщение: Re: pg_dump/pg_restore and the magic of the search_path
Следующее
От: wheels
Дата:
Сообщение: Efficient Partitioning Strategies for PostgreSQL Table with KSUID and High Volume