Problems with Triggers

Started by Sebastian Böckalmost 22 years ago4 messagesgeneral
Jump to latest
#1Sebastian Böck
sebastianboeck@freenet.de

Hello,

is there a simple operator to determine whether the OLD.value and
NEW.value are different. The <> operator is not working on NULL's.

I need something like this:
NEW.val <> Old.val OR
NEW.val IS NULL AND OLD.val IS NOT NULL OR
NEW.val IS NOT NULL AND OLD.val IS NULL

Thanks in advance

Sebastian

#2Martín Marqués
martin@bugs.unl.edu.ar
In reply to: Sebastian Böck (#1)
Re: Problems with Triggers

El Jue 15 Abr 2004 08:55, Sebastian Böck escribió:

Hello,

is there a simple operator to determine whether the OLD.value and
NEW.value are different. The <> operator is not working on NULL's.

I need something like this:
NEW.val <> Old.val OR
NEW.val IS NULL AND OLD.val IS NOT NULL OR
NEW.val IS NOT NULL AND OLD.val IS NULL

(NEW.val <> Old.val) OR
(NEW.val IS NULL AND OLD.val IS NOT NULL) OR
(NEW.val IS NOT NULL AND OLD.val IS NULL)

You forgot the parenthesis, to group the conditions accordingly

--
11:56:01 up 37 days, 16:23, 2 users, load average: 1.86, 0.99, 0.72
-----------------------------------------------------------------
Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica | DBA, Programador, Administrador
Universidad Nacional
del Litoral
-----------------------------------------------------------------

#3Sebastian Böck
sebastianboeck@freenet.de
In reply to: Martín Marqués (#2)
Re: Problems with Triggers

Martin Marques wrote:

El Jue 15 Abr 2004 08:55, Sebastian Böck escribió:

Hello,

is there a simple operator to determine whether the OLD.value and
NEW.value are different. The <> operator is not working on NULL's.

I need something like this:
NEW.val <> Old.val OR
NEW.val IS NULL AND OLD.val IS NOT NULL OR
NEW.val IS NOT NULL AND OLD.val IS NULL

(NEW.val <> Old.val) OR
(NEW.val IS NULL AND OLD.val IS NOT NULL) OR
(NEW.val IS NOT NULL AND OLD.val IS NULL)

You forgot the parenthesis, to group the conditions accordingly

Yes i did in my mail, but that's not the question.
I wanted to know if there is a special operator that does exactly
this.

Sebastian

#4Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Sebastian Böck (#1)
Re: Problems with Triggers

On Thu, 15 Apr 2004, [ISO-8859-1] Sebastian B�ck wrote:

is there a simple operator to determine whether the OLD.value and
NEW.value are different. The <> operator is not working on NULL's.

Not as far as I know, although I think you can simplify the last part as
(NEW.val IS NULL <> OLD.val IS NULL)

Show quoted text

I need something like this:
NEW.val <> Old.val OR
NEW.val IS NULL AND OLD.val IS NOT NULL OR
NEW.val IS NOT NULL AND OLD.val IS NULL