Subject RE: [IBO] Re: Problem with triggers
Author Eric Tishler
The PK and FK values are already set. I am only updating a field in the master table. I can't very well use a trigger to make sure the child table is updated with the before update trigger, since the update value is not yet know. Therefore the after update trigger is the logical way to go.

I have already resolved my problem.

Thank you for your input though ...

Eric

Eric Tishler
Software Architect
Resolute Partners, LLC
Phone: 203.271.1122
Fax: 203.271.1460
etishler@...

-----Original Message-----
From: radevojvodic [mailto:rvojvodic@...]
Sent: Wednesday, April 07, 2004 2:35 AM
To: IBObjects@yahoogroups.com
Subject: [IBO] Re: Problem with triggers

Hi,
As I understand here you want to ensure cascade update of child
table when change code in master. This you should do in before
update trigger. trigger should look like this

create trigger Tbeforeupdate For Master
before update
as
begin
if (old.ParentKey != new.ParentKey)
then
begin
Update CHILD
Set CHILD.FK = new.ParentKey
Where CHILD.FK = old.ParentKey
end
end
--- In IBObjects@yahoogroups.com, "Eric Tishler" <etishler@r...>
wrote:
> Once again this is valuable input. I will reverse the order and
try again.
>
> The trigger itself is extremely simple and similar to my
application operates on a table not a view.
>
> The trigger, is as follows ...
>
> Both UserInfo and UserAccounts are tables.
>
> Name: UserAccounts_AU For Table: UserAccounts
> Action: After Insert: Update: X Delete:
> Position: 0 Is Active: X
>
> AS
> BEGIN
> Update "UserInfo"
> SET "UserInfo"."UserCredits" = NEW."Credits"
> WHERE "UserInfo"."AccountID" = NEW."AccountID";
> END
>
> Basically all the trigger does is ensure that the UserCredits
field in the UserInfo table is updated with the same value as
Credits for the UserAccount table when the UserAccounts table is
updated.
>
> The trigger seems to take affect if I manually edit the
UserAccounts table and update the Credits field. The UserCredits
field in UserInfo is update.
>
> However when I do this via my code the trigger does not seem to
fire ...
>
> Per Helen's suggestion I will reverse the order of the transaction
and prepare testing and report back shortly.
>
> Thanks kindly,
>
> Eric
>
> Eric Tishler
> Software Architect
> Resolute Partners, LLC
> Phone: 203.271.1122
> Fax: 203.271.1460
> etishler@r...
>
> -----Original Message-----
> From: Helen Borrie [mailto:helebor@t...]
> Sent: Monday, April 05, 2004 8:56 PM
> To: IBObjects@yahoogroups.com
> Subject: RE: [IBO] Re: Problem with triggers
>
> At 04:09 PM 5/04/2004 -0400, you wrote:
> >Hi Marco,
> >
> >
> >I am using a TIB_DSQL object and the ExecSQL method as follows:
> >
> > // run the UPDATE
> > if not DataAccessMod.IBODQuery.Prepared then
> > DataAccessMod.IBODQuery.Prepare;
> > if not DataAccessMod.IBODQuery.IB_Transaction.Started then
> > DataAccessMod.IBODQuery.IB_Transaction.StartTransaction;
> > DataAccessMod.IBODQuery.ExecSQL;
> > DataAccessMod.IBODQuery.IB_Transaction.Commit;
>
> The sequence is wrong here. The transaction test has to precede
the
> Prepared test. If the query needs to be prepared, it won't
prepare if it's
> not in a started transaction.
>
> To repeat what Marco said - the client side does not --- can not --
- have
> any influence over whether a trigger fires or not.
>
> If you eliminated the possibility that the after trigger finds no
records
> to operate on, then the next thing to look at is the possibility
that, in
> one case, the DML is operating on the table and, in the other, it
is
> operating on a view. If it's a view, the table triggers won't
fire; if
> it's a table, the view triggers won't fire.
>
> Helen
>
>
>
>
_____________________________________________________________________
______
> IB Objects - direct, complete, custom connectivity to Firebird or
InterBase
> without the need for BDE, ODBC or any other layer.
>
_____________________________________________________________________
______
> http://www.ibobjects.com - your IBO community resource for Tech
Info papers,
> keyword-searchable FAQ, community code contributions and
more !
>
>
>
> _____
>
> Yahoo! Groups Links
> * To visit your group on the web, go to:
> http://groups.yahoo.com/group/IBObjects/
>
> * To unsubscribe from this group, send an email to:
> IBObjects-unsubscribe@yahoogroups.com <mailto:IBObjects-
unsubscribe@yahoogroups.com?subject=Unsubscribe>
>
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms
of < http://docs.yahoo.com/info/terms/> Service.
>
>
> [Non-text portions of this message have been removed]



___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !



_____

Yahoo! Groups Links
* To visit your group on the web, go to:
http://groups.yahoo.com/group/IBObjects/

* To unsubscribe from this group, send an email to:
IBObjects-unsubscribe@yahoogroups.com <mailto:IBObjects-unsubscribe@yahoogroups.com?subject=Unsubscribe>

* Your use of Yahoo! Groups is subject to the Yahoo! Terms of <http://docs.yahoo.com/info/terms/> Service.


[Non-text portions of this message have been removed]