Re: Conditional INSERT

2019-03-15 Thread Tom Lane
Ken Tanzer writes: > OK, and thanks for the info. I've gleaned that rules are not "deprecated" > in the sense that they are slated for removal, but they are rather > discouraged. Since that's the case, wouldn't it make sense to warn users > about this? There's no plan to remove them, but we do

Re: Conditional INSERT

2019-03-15 Thread Adrian Klaver
On 3/15/19 5:19 PM, Ken Tanzer wrote: On Fri, Mar 15, 2019 at 4:42 PM Adrian Klaver > wrote: OK, and thanks for the info. I've gleaned that rules are not "deprecated" in the sense that they are slated for removal, but they are rather discouraged.  Since

Re: Conditional INSERT

2019-03-15 Thread Ken Tanzer
On Fri, Mar 15, 2019 at 4:42 PM Adrian Klaver wrote: > > Just curious, but wanted to follow up on whether rules are > > across-the-board discouraged? I've seen disparaging comments about > > them, but I don't see any indication of that on the create rule page. > > See here: >

Re: Conditional INSERT

2019-03-15 Thread Adrian Klaver
On 3/15/19 4:23 PM, Ken Tanzer wrote: On Fri, Mar 15, 2019 at 11:59 AM Adrian Klaver mailto:adrian.kla...@aklaver.com>> wrote: On 3/15/19 11:54 AM, basti wrote: > this is a dns database, and the client is update the _acme-challenge for > LE certificates. I don't want that the

Re: Conditional INSERT

2019-03-15 Thread Ken Tanzer
On Fri, Mar 15, 2019 at 11:59 AM Adrian Klaver wrote: > On 3/15/19 11:54 AM, basti wrote: > > this is a dns database, and the client is update the _acme-challenge for > > LE certificates. I don't want that the client can insert "any" txt > record. > > the client should only insert data if the

Re: Conditional INSERT

2019-03-15 Thread Andreas Kretschmer
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%.

Re: Conditional INSERT

2019-03-15 Thread Michel Pelletier
You're right it probably does, unless the constraint needs to do a sub-query to get the matching pattern, which would require a trigger. On Fri, Mar 15, 2019 at 12:05 PM Rob Sargent wrote: > > > On Mar 15, 2019, at 12:59 PM, Adrian Klaver > wrote: > > On 3/15/19 11:54 AM, basti wrote: > > this

Re: Conditional INSERT

2019-03-15 Thread Rob Sargent
> On Mar 15, 2019, at 12:59 PM, Adrian Klaver wrote: > > On 3/15/19 11:54 AM, basti wrote: >> this is a dns database, and the client is update the _acme-challenge for >> LE certificates. I don't want that the client can insert "any" txt record. >> the client should only insert data if the

Re: Conditional INSERT

2019-03-15 Thread Adrian Klaver
On 3/15/19 11:54 AM, basti wrote: this is a dns database, and the client is update the _acme-challenge for LE certificates. I don't want that the client can insert "any" txt record. the client should only insert data if the hostname start with _acme-challenge. i have no control on client. i

Re: Conditional INSERT

2019-03-15 Thread basti
this is a dns database, and the client is update the _acme-challenge for LE certificates. I don't want that the client can insert "any" txt record. the client should only insert data if the hostname start with _acme-challenge. i have no control on client. i have try this rule but the server

Re: Conditional INSERT

2019-03-15 Thread Paul Jungwirth
On 3/15/19 10:55 AM, basti wrote: 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%. I would use

Re: Conditional INSERT

2019-03-15 Thread Michael Lewis
> > On Fri, Mar 15, 2019 at 10:55 AM basti > 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

Re: Conditional INSERT

2019-03-15 Thread Michel Pelletier
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:

Conditional INSERT

2019-03-15 Thread 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%. How can it be done? I dont want that the