PL/TCL and NULL values - Mailing list pgsql-sql

From Daniele Orlandi
Subject PL/TCL and NULL values
Date
Msg-id 37193771.230EA8FA@orlandi.com
Whole thread Raw
List pgsql-sql
Hi,

I created this trigger to implement templates for a fields in a table.
This works except if fieldvalue in template is NULL. In that case, the field is
excluded in the array and the "set" directive fails.

How can I copy NULL values from TPL to NEW array ?
I think I should test if the value is the array and avoid to execute the set
directive if not, but I'm totally a newbie with TCL. Please help ! :^)

CREATE FUNCTION users_trig_func() RETURNS opaque AS ' spi_exec -array TPL "SELECT * FROM $1 WHERE template=
\'$NEW(template)\'AND
 
force=\'f\'" {   set NEW($TPL(fieldname)) $TPL(fieldvalue)  }
 return [array get NEW]
' LANGUAGE 'pltcl';

Thanks in advance.

Bye!

-- Daniele

-------------------------------------------------------------------------------
"Besides, I think [Slackware] sounds better than 'Microsoft,' don't you?"
(By Patrick Volkerding)
-------------------------------------------------------------------------------Dal 01-03-1993, con un solo POP abbiamo
fattoguadagnare a telecom italia27.325.828 Lire solo in scatti alla risposta. Non male eh ?
 
-------------------------------------------------------------------------------Daniele Orlandi - Utility Line Italia -
http://www.orlandi.comViaMezzera 29/A - 20030 - Seveso (MI) - Italy
 
-------------------------------------------------------------------------------


pgsql-sql by date:

Previous
From: david
Date:
Subject: Impossible query with SQL? or not?
Next
From: Tom Lane
Date:
Subject: Re: [SQL] Trouble with null text fields!