Re: Access to an element of array NEW in TCL

From: Ian Harding <iharding(at)tpchd(dot)org>
To: Josué Maldonado <josue(at)lamundial(dot)hn>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Access to an element of array NEW in TCL
Date: 2003-09-03 10:36:22
Message-ID: 3F55C426.3070007@tpchd.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

As long as it is an insert or update trigger that fires your tcl
function, you have access to the NEW array. The foreach loop uses the
tcl command [array names NEW] to suck out the names of the existing
members of the array. If a column called duser exists in the NEW array
(it is part of the inserted tuple, or not updated to null) you should be
able to access it as

$NEW(duser)

What error are you getting? If the duser column is null, there is no
array member called NEW(duser) and you will get an error to that effect.

Josué Maldonado wrote:

> Hi list,
>
> Is there a way to access an especific element of the array NEW in an
> TCL trigger, I have a loop that goes for each field (thanks Ian &
> Darren) like this:
>
> foreach id [array names NEW] {
>
> then I can refer to an element with this (inside the loop):
> $NEW($id)
>
> I do need to make a reference to an especific column name (duser) in
> that array to get its value, I already tried $NEW(duser),
> $NEW(\'duser\') but didn't work. I'll appreciate any help from you
>
> Thanks
>
>
> Josue Maldonado
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Malcolm Warren 2003-09-03 11:05:30 Re: Using oids
Previous Message Csaba Nagy 2003-09-03 10:29:40 Re: Oracle decode Function in Postgres