dbTalk Databases Forums  

Column null versus omitted in update rule

comp.databases.postgresql comp.databases.postgresql


Discuss Column null versus omitted in update rule in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
KM
 
Posts: n/a

Default Column null versus omitted in update rule - 03-22-2010 , 09:53 PM






I have a view view1 with a column foo, among others.

A rule intercepts an update on view1. Is there a way for the rule to
distinguish between

* foo is in the SET clause and is set to NULL
* foo is not in the SET clause

?

Thanks
--
KM

Reply With Quote
  #2  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: Column null versus omitted in update rule - 03-23-2010 , 03:01 AM






KM wrote:
Quote:
I have a view view1 with a column foo, among others.

A rule intercepts an update on view1. Is there a way for the rule to
distinguish between

* foo is in the SET clause and is set to NULL
* foo is not in the SET clause

?
The NEW.* values for columns which are *not* in the set clause
are not NULL, they retain the original values.

There is no way in the rule to tell whether a certain column
was in the SET clause or not, but that has nothing to do with
NULL values.

So: technically the answer to your question is "no", but it
seems like you asked the question based on wrong information.

Yours,
Laurenz Albe

Reply With Quote
  #3  
Old   
news
 
Posts: n/a

Default Re: Column null versus omitted in update rule - 03-23-2010 , 03:22 AM



Il 23/03/2010 4.53, KM ha scritto:
Quote:
I have a view view1 with a column foo, among others.

A rule intercepts an update on view1. Is there a way for the rule to
distinguish between

* foo is in the SET clause and is set to NULL
* foo is not in the SET clause

?

Thanks
--
KM

Perhaps with upcoming 8.5 version you'll can use a trigger for the same
purpose on the underlying table, but you have to wait some months:

http://developer.postgresql.org/pgdo...lease-8.5.html
"Add SQL-compliant triggers on columns, which fire only if certain
columns are named in the UPDATE's SET list."

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.