| От | Jasen Betts |
|---|---|
| Тема | Re: conditional execution of insert/update-s |
| Дата | |
| Msg-id | glgekj$7dt$2@reversiblemaps.ath.cx обсуждение исходный текст |
| Ответ на | conditional execution of insert/update-s (Dmitry Teslenko <dteslenko@gmail.com>) |
| Список | pgsql-general |
On 2009-01-22, Dmitry Teslenko <dteslenko@gmail.com> wrote:
> Hello!
> Question is what's the easiest way to implement conditional execution
> of insert/update-s via psql interface?
>
> As far as I know there's following options:
> 1) create function in procedural language (plpgsql, for example);
> then call that function
> 2) update ... where <conditon>;
insert ... (select ... where <condition>);
> not sure here if <condition> can be unrelated to the table being modified
> by update/insert statement;
they can be unrelated
> Are there alternatives?
here's one but it's messy when the condition is false.
BEGIN;
SELECT expression_which_causes_an_exception_when_condition_fails;
statements...;
COMMIT;
the advantage of this is that it can be used with DDL statements.
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера