Search Postgresql Archives

NEW variable values in trigger functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



1. What is the value of the NEW variable for a column that is not mentioned
in an UPDATE statement?  Is it NULL?  If not NULL, what?

For example, given this table:

       my_tbl (id integer, att1 varchar, att2 varchar)

and a row-wise ON UPDATE OR INSERT trigger function containing this
conditional:

       IF NEW.att2 IS NULL THEN
       	<do stuff>
       END IF;
       
and this UPDATE query:

	UPDATE my_tbl SET att1 = 'foo' where id = 1;

will that conditional be satisfied?

2. Same questions re the value of a NEW variable that is not assigned a
value in an INSERT statement.  

For example, how would the previous conditional behave in response to:

	INSERT INTO my_tbl (id) VALUES (1);

?

3. If an UPDATE query set a column to DEFAULT, what value does a trigger
function see for the column's NEW variable?  Is it the string 'DEFAULT', a
reserved word DEFAULT, an empty string, or what?

For example, what would you put in place of <??> in this UPDATE trigger
function:

       IF NEW.att2 <??> THEN
       	<do stuff>
       END IF;

to get it to <do stuff> in response to this UPDATE query:

	UPDATE my_tbl SET att2 = DEFAULT where id = 1;

?

~ TIA
~ Ken




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux