Subject | Re: [ib-support] Triggers |
---|---|
Author | Lucas Franzen |
Post date | 2001-03-15T14:24:08Z |
Lee Catlett schrieb:
Either this 'abc_def' part is a field within the table itself, then you
can use:
NEW.ABC_FIELD || CAST ( .... )
or:
if it's a value from a different table then you have to "identify" the
record somehow, to get the value out of it.
Suppose this is just a single record table, the primary key is always 1.
Then you can do:
create trigger...
as
declare variable DEFSTRING VARCHAR(xx);
begin
SELECT DEFFIELD from DEFTABLE where DEF_ID = 1 INTO :DEFSTRING;
NEW.ABC_FIELD = DEFSTRING || cast ( ... )
end
If neither od these possibilities is teh case, then you've got a
problem. The trigger has to know where this value has to come from and
(as I said) it has to identify the record in a table uniquely.
Luc.
>since you can't pass parameters to a trigger, it's not that easy.
> Thanks Lucas, yes I think that works when I use a constant. Any idea on how
> to do this when the 'abc_def' part needs to come from a table value?
> Lee
Either this 'abc_def' part is a field within the table itself, then you
can use:
NEW.ABC_FIELD || CAST ( .... )
or:
if it's a value from a different table then you have to "identify" the
record somehow, to get the value out of it.
Suppose this is just a single record table, the primary key is always 1.
Then you can do:
create trigger...
as
declare variable DEFSTRING VARCHAR(xx);
begin
SELECT DEFFIELD from DEFTABLE where DEF_ID = 1 INTO :DEFSTRING;
NEW.ABC_FIELD = DEFSTRING || cast ( ... )
end
If neither od these possibilities is teh case, then you've got a
problem. The trigger has to know where this value has to come from and
(as I said) it has to identify the record in a table uniquely.
Luc.