From: stan <stanb@panix.com>
To: S??ndor Daku <daku.sandor@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Another INSTEAD OF TRIGGER question
Date: Sun, 8 Mar 2020 17:13:25 -0400
Message-ID: <20200308211325.GA29529@panix.com> (raw)
In-Reply-To: <CAKyoTgY2Ez_4BV98EzZ=c7nqw2PVNso7NbDTvZ7Zp2fPU6Locg@mail.gmail.com>
References: <20200308142909.GA20937@panix.com>
<20200308143130.GA1498@panix.com>
<CAKyoTgYPP5+qk16BVaitZNdbqXTQ87_uku47iw1uRC0sFJVcBw@mail.gmail.com>
<20200308202651.GA15465@panix.com>
<CAKyoTgY2Ez_4BV98EzZ=c7nqw2PVNso7NbDTvZ7Zp2fPU6Locg@mail.gmail.com>
On Sun, Mar 08, 2020 at 10:07:24PM +0100, S??ndor Daku wrote:
> On Sun, 8 Mar 2020 at 21:26, stan <stanb@panix.com> wrote:
>
> > On Sun, Mar 08, 2020 at 03:56:56PM +0100, S??ndor Daku wrote:
> > > On Sun, 8 Mar 2020 at 15:31, stan <stanb@panix.com> wrote:
> > >
> > > > On Sun, Mar 08, 2020 at 10:29:09AM -0400, stan wrote:
> > > > > Still working on updateable views.
> > > > >
> > > > > Wish list item, a way to see the entire query that caused the
> > trigger to
> > > > > fire.
> > > > >
> > > > > Now on to something i hope I can get. Can I see what the verb that
> > caused
> > > > > the trigger to fire is? IE UPDATE, INSERT, DELETE?
> > > > >
> > > > > --
> > > > > "They that would give up essential liberty for temporary safety
> > deserve
> > > > > neither liberty nor safety."
> > > > > -- Benjamin Franklin
> > > > >
> > > > >
> > > >
> > > > OH, what was I thinking, that is controled by the trigger.
> > > >
> > > > --
> > > > "They that would give up essential liberty for temporary safety deserve
> > > > neither liberty nor safety."
> > > > -- Benjamin Franklin
> > > >
> > >
> > > Hi,
> > >
> > > Still, you can access that information in the TG_OP variable available in
> > > trigger functions because you can define triggers firing on
> > > multiple operation types.
> > > For instance this is an example from the Postgres documentation:
> > >
> > > CREATE TRIGGER emp_audit
> > > INSTEAD OF INSERT OR UPDATE OR DELETE ON emp_view
> > > FOR EACH ROW EXECUTE FUNCTION update_emp_view();
> > >
> >
> > Thaks for the info.
> >
> > Could yoou clarify how to acces this variable:
> >
> > This does not work:
> >
> > elog( NOTICE, "For OP $_TD->{TG_OP}" )
> >
> > But this does work
> >
> > elog( NOTICE, "On Table $_TD->{table_name}" );
> > --
> > "They that would give up essential liberty for temporary safety deserve
> > neither liberty nor safety."
> > -- Benjamin Franklin
> >
>
> Hi,
>
> Sorry I didn't know you are using something different than plpgsql.
> You can check the actual syntax for your language(plperl I guess) here:
>
> https://www.postgresql.org/docs/11/server-programming.html
>
> Look for the "Trigger functions" section below the corresponding language.
>
Yes, it is not there, which explains why I did not see it.
I can execute an SQL queryy from within plperl, do you think that will get
this value?
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: stanb@panix.com, daku.sandor@gmail.com
Subject: Re: Another INSTEAD OF TRIGGER question
In-Reply-To: <20200308211325.GA29529@panix.com>
References: <20200308142909.GA20937@panix.com> <20200308143130.GA1498@panix.com> <CAKyoTgYPP5+qk16BVaitZNdbqXTQ87_uku47iw1uRC0sFJVcBw@mail.gmail.com> <20200308202651.GA15465@panix.com> <CAKyoTgY2Ez_4BV98EzZ=c7nqw2PVNso7NbDTvZ7Zp2fPU6Locg@mail.gmail.com> <20200308211325.GA29529@panix.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox