Subject Re: CASE Statement annidation
Author achiadodespammed
--- In firebird-support@yahoogroups.com, "Arno Brinkman"
<firebird@a...> wrote:

Hi Arno,

[CUT]

> What do you meant with annidate?, but if you meant nested CASE
>expressions,
> yes that is possible.

Yes, nested CASE. Sorry for my bad english.


> > when (updating) then
> > '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

What I'm trying to do is to save all sql instructions on a table.

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,
> Arno Brinkman
> ABVisie

Thanks
Ciao

Andrea Chiado' Piat