From: | Michael Lewis <mlewis(at)entrata(dot)com> |
---|---|
To: | Michel Pelletier <pelletier(dot)michel(at)gmail(dot)com> |
Cc: | basti <mailinglist(at)unix-solution(dot)de>, Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Conditional INSERT |
Date: | 2019-03-15 18:17:17 |
Message-ID: | CAHOFxGr3WCD1Kb0mL8aXiRHyYpOaV98uzF_pcJA_ALF4V0qhjA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>
> On Fri, Mar 15, 2019 at 10:55 AM basti <mailinglist(at)unix-solution(dot)de>
> wrote:
>
>> 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');
>>
>
Alternative to a trigger implementation, if you are generating that INSERT
statement, you can change it to use a sub-select or CTE that contains no
values if the domainid isn't what you like. If you want it to fail with
error, you could add a check constraint. We might need more context on what
you are doing and why to give good advice.
From | Date | Subject | |
---|---|---|---|
Next Message | Paul Jungwirth | 2019-03-15 18:26:24 | Re: Conditional INSERT |
Previous Message | Michel Pelletier | 2019-03-15 18:10:04 | Re: Conditional INSERT |