Subject Re: [firebird-support] Indirect value
Author unordained
Consider writing a procedure that *creates* a trigger, based on the columns
present in the table. You have access to rdb$relation_fields, and can get a list
of all of them, and their types (useful if you're also auto-building logging
tables, etc.). You could use string-concatenation to build up the desired
trigger, then use "execute statement" to create it. You could even put a trigger
on rdb$relation_fields that checks any changes against the list of tables on
which you've put replication triggers, and automatically replace the trigger
when it no longer covers all the columns of the table (after an "alter tablename
add fieldname..." operation, for example.) Might run into some weirdness with
DDL happening on commit, but ... something to think about. One generic procedure
to build many specialized procedures (triggers).

-Philip

---------- Original Message -----------
From: "Hans" <hhoogstraat@...>
To: <firebird-support@yahoogroups.com>
Sent: Sat, 7 Feb 2009 12:18:49 -0700
Subject: Re: [firebird-support] Indirect value

> Just the only thing I'm missing for a general after
> insert/update/delete trigger to replicate :)
>
> ----- Original Message -----
> From: "Teträm Corp" <dev@...>
> To: <firebird-support@yahoogroups.com>
> Sent: Saturday, February 07, 2009 11:50 AM
> Subject: Re: [firebird-support] Indirect value
>
> > Hi
> >
> > if you were in before update trigger, you could do this with
> >
> > execute statement 'select ' || colname || ' from mytable where ... '
> > into :colvalue;
> >
> > but in after update, I guess you have to use a way to store your value
> > in before update trigger and retrieve it in after update.
> > e.g. context, temporary table, etc
> >
> > Thierry
> >
> > Hans a écrit :
> >>
> >> Hi, my question
> >>
> >> Is it possible, say in a after update trigger to retrieve
> >> the value of a column 'Name' indirectly somewhat
> >> alike
> >>
> >> Suppose Old.Name contains 'Hans'
> >> -----
> >> declare variable ColName Varchar(8);
> >> declare variable ColValue Varchar(255);
> >> begin
> >> ColName = 'Name';
> >>
> >> ColValue = ['Old.' || ColName] ;
> >> -----
> >> The value of ColValue at this point = 'Hans'
> >>
> >> Best Regards
> >> Hans
> >>
> >>
> >
> >
> >
> > ------------------------------------
> >
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> > Visit http://www.firebirdsql.org and click the Resources item
> > on the main (top) menu. Try Knowledgebase and FAQ links !
> >
> > Also search the knowledgebases at http://www.ibphoenix.com
> >
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > Yahoo! Groups Links
> >
> >
> >
> >
>
>
------- End of Original Message -------