Subject Re: [firebird-support] Re: Retrieving field new and old value using variable
Author Helen Borrie
At 01:44 PM 18/07/2006, you wrote:
>--- In firebird-support@yahoogroups.com, Alexandre Benson Smith
><iblist@...> wrote:
> >
> > TechVale - Gustavo wrote:
> > > Hi All,
> > >
> > > May i retrieve the "new" and "old" field values using its field
>name in a trigger ?
> > >
> > > i would like to do something like :
> > >
> > > for select <SelectToGetAllFieldsNameInTable> into :MyFieldName do
> > > begin
> > > if( <OldFieldNameUsingMyFieldNameVar> <>
><NewFieldNameUsingMyFieldNameVar> ) then ...
> > >
> > > Thanks in advanced,
> > >
> > > Gustavo.
> > >
> >
> > Gustavo,
> >
> > You could go the EXECUTE STATEMENT way.
> >
> > But I would create a simple app that reads the RDB$Relations,
> > RDB$Relation_Fields, etc. and generate a script with the full SQL
> >
>
>I think he is talking about the OLD and NEW context variables
>available within triggers. It looks like he is attempting to cycle
>through each field in the given table (probably through system
>tables), then check field by field whether the value has changed,
>possibly some sort of replication idea.
>
>I may be mistaken, but I don't think this is possible at the moment,
>although I can see its merit.

Well, it's possible, just as Alexandre suggested, but it doesn't make
a lot of sense. A trigger is created "for" a known table, which
presupposes that one knows the structure and therefore the column
names. It seems to me like a mackerel to catch a sprat.

./hb