WHERE clause?

Поиск
Список
Период
Сортировка
От Jim Rowan
Тема WHERE clause?
Дата
Msg-id 199907140517.AAA23407@zee.computing.com
обсуждение исходный текст
Ответы Re: [SQL] WHERE clause?  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [SQL] WHERE clause?  (Steven Bradley <sbradley@llnl.gov>)
Список pgsql-sql
I'm trying to create a log table to track changes to a table..  so I've
created a set of rules that look something like this:

CREATE RULE "m_log_change" AS ON UPDATE TO "machine"
do ( INSERT INTO machine_log (who, date, machnum, col, newval)   SELECT getpgusername(), 'now'::text, old.machnum,
'host',new.host   WHERE (new.host != old.host) or (old.host IS NOT NULL and new.host IS NULL) or    (old.host IS NULL
andnew.host IS NOT NULL);
 
... more similar INSERT statements with different WHERE clauses..
);

My question is:

Is this the best way to code the WHERE?  What I'm really after is "did the
value change?".  I found that the tests to see if one-but-not-both of the
values is NULL are required to identify times when the value changed to or
from NULL.  

Seems like a lot of extra work...


Jim Rowan            DCSI            DCE/DFS/Sysadmin Consulting
jmr@computing.com                                            (512) 374-1143


В списке pgsql-sql по дате отправления:

Предыдущее
От: Michael Richards
Дата:
Сообщение: counting bools in a complex query
Следующее
От: Johann Spies
Дата:
Сообщение: OFF-TOPIC: Postgresql for NT?