Re: Trigger to create string to inverse SQL statement

From: Łukasz Jarych <jaryszek(at)gmail(dot)com>
To: Francisco Olarte <folarte(at)peoplecall(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Trigger to create string to inverse SQL statement
Date: 2018-03-08 12:51:11
Message-ID: CAGv31ofNKV7_c1cpxRdXSQ3ygJSa+YxunUg-4gBh-2AZWZRO=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

thank you,

what do you mean use external program to build inverted queries. Do you
have any examples?

Best,
Jacek

2018-03-08 13:44 GMT+01:00 Francisco Olarte <folarte(at)peoplecall(dot)com>:

> Hello:
>
> On Thu, Mar 8, 2018 at 1:32 PM, Łukasz Jarych <jaryszek(at)gmail(dot)com> wrote:
>
>>
>>
>> i have a trigger which is added log history:
>>
>>
>>
>>
> ​I'll trust it is, but I cannot really see any thing in there, it may be
> better if in the future you used something like psql and pasted the data in
> a text format, which people with no-so-good eyesight like me can zoom in.​
>
>
>
>> It is possible to create additional column here with string with inversed
>> SQL statement?
>>
>> So in this case: "Delete FROM t_trig WHERE ID=1".
>>
>> And what i want is to have possibility to loop through table and execute
>> inversed sql statement for each row.
>>
>
> ​It should be. For inserts it is not that difficult, for updates YMMV, it
> is difficult to ​reverse a command exactly, but you get new and old values
> so you could write it. For deletes just reinsert. But I doubt there is a
> function which does it for you, you'll have to code something, and I
> suspect it may be easier to just capture op, old and new in your triggers
> and use an external program to build the inverted queries.
>
> ​Francisco Olarte.​
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Łukasz Jarych 2018-03-08 12:53:22 Re: Trigger to create string to inverse SQL statement
Previous Message Łukasz Jarych 2018-03-08 12:48:37 Re: Command to execute SQL string