Re: Conditional INSERT - Mailing list pgsql-general

From Andreas Kretschmer
Subject Re: Conditional INSERT
Date
Msg-id 94fb335b-4a63-b0e3-3168-83f3b57da26e@a-kretschmer.de
Whole thread Raw
In response to Conditional INSERT  (basti <mailinglist@unix-solution.de>)
List 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 by date:

Previous
From: Chapman Flack
Date:
Subject: Re: Facing issue in using special characters
Next
From: Morris de Oryx
Date:
Subject: Re: Camel case identifiers and folding