Subject | Re: CASE Statement annidation |
---|---|
Author | achiadodespammed |
Post date | 2004-06-11T14:04:21Z |
--- In firebird-support@yahoogroups.com, "Arno Brinkman"
<firebird@a...> wrote:
Hi Arno,
[CUT]
my idea is:
...
case
when (inserting) then 'INSERT INTO ..table.. (..field..) VALUES
(..new.values..)'
when (updating) then 'UPDATE ..table.. SET field1=new.field1,
field2=new.field2, ... WHERE key=old.key'
when (deleting) then 'DELETE from ..table.. WHERE key=old.key'
end
This works well.
But, in case (updating) I'm trying to distinguish if a field has been
modified or not (if new.field1<>old.field) so that I in my log table
only fields really modified.
Ciao
Andrea Chiado' Piat
<firebird@a...> wrote:
Hi Arno,
[CUT]
> What do you meant with annidate?, but if you meant nested CASEYes, nested CASE. Sorry for my bad english.
>expressions,
> yes that is possible.
> > when (updating) thenWhat I'm trying to do is to save all sql instructions on a table.
> > 'UPDATE table1 SET fieldkey='||new.fieldkey
> > || case when (new.field1#old.field1) then
> ^^^^^^^^^^^^^^^
> > ',field1='||new.field1|| end
> > || case when (new.field2#old.field2) then
> ^^^^^^^^^^^^^^^^
> > ',field2='||new.field2|| end
>
> What do you meant with :
> new.field2#old.field1
my idea is:
...
case
when (inserting) then 'INSERT INTO ..table.. (..field..) VALUES
(..new.values..)'
when (updating) then 'UPDATE ..table.. SET field1=new.field1,
field2=new.field2, ... WHERE key=old.key'
when (deleting) then 'DELETE from ..table.. WHERE key=old.key'
end
This works well.
But, in case (updating) I'm trying to distinguish if a field has been
modified or not (if new.field1<>old.field) so that I in my log table
only fields really modified.
> # ?Sorry, '<>'
> Regards,Thanks
> Arno Brinkman
> ABVisie
Ciao
Andrea Chiado' Piat