| От | Francesco Casadei |
|---|---|
| Тема | Catching errors inside a function |
| Дата | |
| Msg-id | 20010903200727.A5843@goku.kasby обсуждение исходный текст |
| Ответы |
Re: Catching errors inside a function
|
| Список | pgsql-general |
I want to execute an INSERT query that may fail due to a primary key constraint
check. The primary key is on a field whose value is generated randomly by
another C function.
Is it possible to wrap the insert into a function that checks for failures and
retry the insert until success? Something like this:
function blah
{
do {
cod = generate code;
execute insert with cod as primary key;
} while (! errors);
}
I tried with SQL, PL/pgSQL and C functions but the backend aborts the
transaction and stops execution of the function as soon as the error is thrown.
Is there a way to disable this behaviour?
Thanks in advance for your help.
Francesco Casadei
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера