Subject | Re: [firebird-support] CASE Statement annidation |
---|---|
Author | Helen Borrie |
Post date | 2004-06-11T12:31:18Z |
At 11:40 AM 11/06/2004 +0000, you wrote:
but Firebird doesn't have a CASE statement in its syntax. In your first
use of CASE you are using a case expression..
but:::::::::::
Don't write triggers that do things to the table that owns the
trigger. You'll get into an endless loop, where the operation causes the
trigger to fire which causes another operation which causes the trigger to
fire which causes another operation which causes the trigger to fire
which..........................
/heLen
>Hi all,I don't know what "annidiate" would be...
>
>I'm trying to write a trigger that log to a table all user operations.
>
>So I write someting like this:
>CREATE TRIGGER table1_log FOR table1
>ACTIVE AFTER INSERT OR UPDATE OR DELETE POSITION 0
>AS
>BEGIN
>IF (USER <> 'REPL') THEN BEGIN
> INSERT INTO table_log(utente, tipo, tabella, istruzione)
> VALUES (USER,
> case
> when (inserting) then 'I'
> when (updating) then 'U'
> when (deleting) then 'D'
> end,
> 'TABLE1',
> case
> when (inserting) then
> 'INSERT INTO table1 (
> fieldkey,
> field1,
> field2)
> VALUES
>('||new.fieldkey||','||new.field1||','||new.field2||')'
> 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
> || ' WHERE fieldkey=old.fieldkey'
> when (deleting) then
> 'DELETE FROM table1 WHERE fieldkey=old.fieldkey'
> end);END
>end
>
>but in the (updating) CASE, when I try to insert another CASE IBExpert
> return a precompiler error.
>
>My question is:
>
>It is possible to annidiate CASE statement?
but Firebird doesn't have a CASE statement in its syntax. In your first
use of CASE you are using a case expression..
>If not how can I write myUse good old IF..THEN.
>trigger to obtain same result?
but:::::::::::
Don't write triggers that do things to the table that owns the
trigger. You'll get into an endless loop, where the operation causes the
trigger to fire which causes another operation which causes the trigger to
fire which causes another operation which causes the trigger to fire
which..........................
/heLen