473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Access to an element of array NEW in TCL

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

Nov 11 '05 #1
2 4281
The way you have it should work i.e. if the NEW array has a field called
duser in it you will be able to access it using $NEW(duser)

Put in an elog notice and do [array names NEW] in it.
Run the function and see what variables are available to you then you
should be able to call them just like shown below

-bash-2.05b$ tclsh
% set NEW(duser) darren
darren
% set NEW(cuser) carl
carl
% foreach id [array names NEW] { puts $NEW($id) }
carl
darren
% puts $NEW(duser)
darren
% puts $NEW(cuser)
carl

HTH
Darren

On Wed, 3 Sep 2003, 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 ma*******@postgresql.org)


--
Darren Ferguson
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 11 '05 #2
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 ma*******@postgresql.org)



---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 11 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: David Mathog | last post by:
If this: int i,sum; int *array; for(sum=0, i=0; i<len; i++){ sum += array; } is converted to this (never mind why for the moment):
9
by: Haobin | last post by:
Hi everyone, I have an ArrayList whose members are classes. These classes are derived from a same base class. The base class has a floating point array and a string. How do I access each element in...
2
by: Trip | last post by:
Hello all, Is there anyway to store an array to MS Access 2002 without parsing the entire array row-by-row. For example, Oracle allows you to store BLOBs (binary large objects). I would like...
9
by: gk245 | last post by:
I have something like this: struct block { int x; int y; float z; }
13
by: mfreeman | last post by:
The minimal code (VB.NET 2003) needed to show this problem is shown below. All I do is loop through the records in the table and update them without making any changes. Out of 600 records, about...
6
by: Urs Thuermann | last post by:
With offsetof() I can get the offset of a member in a struct. AFAICS, it is portable and clean to use this offset to access that member. I need to do something like this struct foo { struct...
10
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, There is error message when executing my program, Unhandled exception at 0x00411a49 in test_entern.exe: 0xC0000005: Access violation reading location 0x00000002. It is...
0
NeoPa
by: NeoPa | last post by:
Many of us have noticed that there are some very useful functions available to you when using Excel, but these same functions are not available, as standard, in Access. A particular issue I had...
1
by: gihan | last post by:
Hi, I have a problem accessing remote webservice from my asp code. Instead of returning results, it returns list of web methods it has. Wonder where i'm doing wrong. Also note that, this is a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.