Re: Conditional INSERT

Поиск
Список
Период
Сортировка
От Michel Pelletier
Тема Re: Conditional INSERT
Дата
Msg-id CACxu=vKcVZdjsmMQyGf2tAcVAt8vyz2X1b+ynPb=_==AATjbVA@mail.gmail.com
обсуждение исходный текст
Ответ на Conditional INSERT  (basti <mailinglist@unix-solution.de>)
Ответы Re: Conditional INSERT  (Michael Lewis <mlewis@entrata.com>)
Список pgsql-general
Well, the obvious question is, why are you inserting data into your database you don't want?  It makes more sense to just not do the insert.

But, assuming perhaps you have no control over the client, you can create a BEFORE INSERT trigger that rejects the inserts that don't match your condition:




On Fri, Mar 15, 2019 at 10:55 AM basti <mailinglist@unix-solution.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');

The insert should only be done if Hostname like %_acme.challenge%.

How can it be done? I dont want that the user/script can insert any value.

Best regards.

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

Предыдущее
От: basti
Дата:
Сообщение: Conditional INSERT
Следующее
От: Michael Lewis
Дата:
Сообщение: Re: Conditional INSERT