Subject RE: [firebird-support] How I can know the value of a parent table?
Author Svein Erling Tysvær
>Hello everybody
>
>I am using Firebird 2.1
>
>I have a parent table (MOVIMCAB) and a child table (MOVIMDET)
>
>In a trigger of MOVIMDET I want to access a value of MOVIMCAB, something
>like that:
>
>IF (MOVIMCAB.MVC_TIPMOV = 'E') THEN
> UPDATE ....
>
>but the message "column unknown" appears. Why? How I can know the value of
>the related column of MOVIMCAB?
>
>MOVIMDET has a foreign constraint:
>ALTER TABLE MOVIMDET ADD CONSTRAINT FK_MOVIMDET1 FOREIGN KEY (MOV_IDENTI)
>REFERENCES MOVIMCAB(MVC_IDENTI);
>
>Thanks in advance.

Define a variable in your trigger, then do something like

SELECT MVC_TIPMOV FROM MOVIMCAB MC where MC.MVC_IDENTI = new.MOV_IDENTI into :MyVariable;
IF (MyVariable = 'E') THEN
UPDATE ...

HTH,
Set