pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedExaming cotets of NEW & OLD in a function programed in perl
4+ messages / 3 participants
[nested] [flat]
* Examing cotets of NEW & OLD in a function programed in perl
@ 2020-03-03 17:39 stan <stanb@panix.com>
0 siblings, 1 reply; 4+ messages in thread
From: stan @ 2020-03-03 17:39 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
I need to write a generic function to process data before allowing the
insert or update to continue.
To do this, I need to be able to examine the NEW, and OLD structures
without prior knowledge of the structure of the table that fired the
trigger.
Can someone show me an example of how to get these structures into
something I can work with in Perl?
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Examing cotets of NEW & OLD in a function programed in perl
@ 2020-03-03 17:59 Tom Lane <tgl@sss.pgh.pa.us>
parent: stan <stanb@panix.com>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2020-03-03 17:59 UTC (permalink / raw)
To: stan <stanb@panix.com>; +Cc: pgsql-general@lists.postgresql.org
stan <stanb@panix.com> writes:
> I need to write a generic function to process data before allowing the
> insert or update to continue.
> To do this, I need to be able to examine the NEW, and OLD structures
> without prior knowledge of the structure of the table that fired the
> trigger.
AFAIR, they're just hashes in Perl, so you should be able to do
stuff like iterating over the hash keys.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Examing cotets of NEW & OLD in a function programed in perl
@ 2020-03-03 21:26 stan <stanb@panix.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: stan @ 2020-03-03 21:26 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@lists.postgresql.org
On Tue, Mar 03, 2020 at 12:59:00PM -0500, Tom Lane wrote:
> stan <stanb@panix.com> writes:
> > I need to write a generic function to process data before allowing the
> > insert or update to continue.
> > To do this, I need to be able to examine the NEW, and OLD structures
> > without prior knowledge of the structure of the table that fired the
> > trigger.
>
> AFAIR, they're just hashes in Perl, so you should be able to do
> stuff like iterating over the hash keys.
>
> regards, tom lane
So, they should just be visible as OLD, and NEW as hasshes?
Sorry for my lack of understnading.
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Examing cotets of NEW & OLD in a function programed in perl
@ 2020-03-03 21:28 Christophe Pettus <xof@thebuild.com>
parent: stan <stanb@panix.com>
0 siblings, 0 replies; 4+ messages in thread
From: Christophe Pettus @ 2020-03-03 21:28 UTC (permalink / raw)
To: stan <stanb@panix.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-general@lists.postgresql.org
> On Mar 3, 2020, at 13:26, stan <stanb@panix.com> wrote:
> So, they should just be visible as OLD, and NEW as hasshes?
They're documented here:
https://www.postgresql.org/docs/current/plperl-triggers.html
A global hash variable $_TD is available in the trigger function with all sorts of trigger-related info.
--
-- Christophe Pettus
xof@thebuild.com
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2020-03-03 21:28 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-03 17:39 Examing cotets of NEW & OLD in a function programed in perl stan <stanb@panix.com>
2020-03-03 17:59 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-03-03 21:26 ` stan <stanb@panix.com>
2020-03-03 21:28 ` Christophe Pettus <xof@thebuild.com>
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