Subject | Re: TMP$STATEMENTS - field "sql" in firebird ? |
---|---|
Author | Adam |
Post date | 2005-06-21T00:33:02Z |
> Is something like this possible:the
>
> CREATE TRIGGER update_table
> FOR ARTIKEL
> AFTER UPDATE OR INSERT
> AS
> DECLARE VARIABLE FNAME varchar(255);
> DECLARE VARIABLE INHALT varchar(255);
> BEGIN
> FOR
> SELECT DISTINCT
> R.RDB$FIELD_NAME AS FNAME
> FROM RDB$RELATION_FIELDS R
> WHERE R.RDB$RELATION_NAME = 'ARTIKEL'
> ORDER BY R.RDB$FIELD_POSITION
> INTO :FNAME
> DO
> SUSPEND;
> BEGIN
> SELECT :FNAME FROM ARTIKEL A
> WHERE A.artikelnr = OLD.artikelnr
> INTO :INHALT;
> SUSPEND;
> IF ( :INHALT <> NEW.FNAME ) THEN
> INSERT INTO UPDATE_DEF (id,artikelnr) VALUES
> (GEN_ID(andi_gen,1),:INHALT);
> END
> END
>
> I cant get it to work. I want to use a variable for the field in
> select statement. Is this generally possible?Andi,
>
> Andi
Why are you calling suspend inside a trigger? Triggers do not have
output parameters like selectable stored procedures, so I can't see
what you are aiming to achieve here. Even in stored procedures,
calling suspend does nothing with a value you have assigned to a
declared variables, it just suspends the thread so you can grab the
next record which you have placed in the output parameters.
Is there not another layer in your application that you can intercept
the queries and log them (or whatever you intended on doing) at that
point? or do you let your users run whatever queries they like
against your database?
Adam