Re: Conditional INSERT

Поиск
Список
Период
Сортировка
От Andreas Kretschmer
Тема Re: Conditional INSERT
Дата
Msg-id 94fb335b-4a63-b0e3-3168-83f3b57da26e@a-kretschmer.de
обсуждение исходный текст
Ответ на Conditional INSERT  (basti <mailinglist@unix-solution.de>)
Список pgsql-general

Am 15.03.19 um 18:55 schrieb basti:
> Hello,
>
> I want to insert data into table only if condition is true.
> For example:
>
> INSERT into  mytable (domainid, hostname, txtdata)
>    VALUES (100,'_acme.challenge.example', 'somedata');
>
> The insert should only be done if Hostname like %_acme.challenge%.
>
>

you can use a check-constraint:

create table mytable(hostname text, check(hostname like 
'%_acme.challenge%'));


I think you can see the idea...


Regards, Andreas

-- 
2ndQuadrant - The PostgreSQL Support Company.
www.2ndQuadrant.com



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

Предыдущее
От: Chapman Flack
Дата:
Сообщение: Re: Facing issue in using special characters
Следующее
От: Morris de Oryx
Дата:
Сообщение: Re: Camel case identifiers and folding