Re: [GENERAL] upsert with trigger (or rule)

2016-07-20 Thread Adrian Klaver
On 07/20/2016 12:54 PM, Maeldron T. wrote: On 19/07/16 23:45, Adrian Klaver wrote: To be more complete it would nice to see the schema definition for the table messages. Also maybe some idea of what you the code is supposed to do. If I understand it correctly: 1) Check if a message is a draft

Re: [GENERAL] upsert with trigger (or rule)

2016-07-20 Thread Maeldron T.
On 19/07/16 23:45, Adrian Klaver wrote: To be more complete it would nice to see the schema definition for the table messages. Also maybe some idea of what you the code is supposed to do. If I understand it correctly: 1) Check if a message is a draft. 2) Check if there is a uniqueness con

Re: [GENERAL] upsert with trigger (or rule)

2016-07-19 Thread Adrian Klaver
On 07/19/2016 01:25 PM, Maeldron T. wrote: Hello Adrian, On 19/07/16 21:27, Adrian Klaver wrote: On 07/19/2016 11:56 AM, Maeldron T. wrote: By returning NULL in your function you are skipping the original INSERT. I know that, I wrote it. I am sure exactly what you are trying to ac

Re: [GENERAL] upsert with trigger (or rule)

2016-07-19 Thread Maeldron T.
Hello Adrian, On 19/07/16 21:27, Adrian Klaver wrote: On 07/19/2016 11:56 AM, Maeldron T. wrote: By returning NULL in your function you are skipping the original INSERT. I know that, I wrote it. I am sure exactly what you are trying to achieve, In general, there are the following

Re: [GENERAL] upsert with trigger (or rule)

2016-07-19 Thread Adrian Klaver
On 07/19/2016 11:56 AM, Maeldron T. wrote: Hello, I’m trying to rewrite inserts to upserts on a table when a certain column has a certain value. Reason: the inserts are coming from an ORM. It’s possible to send upsert from the ORM, however, in this case I find it more elegant and fut

[GENERAL] upsert with trigger (or rule)

2016-07-19 Thread Maeldron T.
Hello, I’m trying to rewrite inserts to upserts on a table when a certain column has a certain value. Reason: the inserts are coming from an ORM. It’s possible to send upsert from the ORM, however, in this case I find it more elegant and future-proof to deal with it at the DB level