Saturday, March 26, 2011

RE: [firebird-support] How I can know the value of a parent table?

 

>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

__._,_.___
Recent Activity:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

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

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.


Get great advice about dogs and cats. Visit the Dog & Cat Answers Center.

.

__,_._,___

No comments: