Subject | [IBO] Re: Problem with triggers |
---|---|
Author | radevojvodic |
Post date | 2004-04-07T06:34:40Z |
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:
Credits for the UserAccount table when the UserAccounts table is
updated.
field in UserInfo is update.
______
______
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 andtry again.
>application operates on a table not a view.
> The trigger itself is extremely simple and similar to my
>field in the UserInfo table is updated with the same value as
> 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
Credits for the UserAccount table when the UserAccounts table is
updated.
>UserAccounts table and update the Credits field. The UserCredits
> The trigger seems to take affect if I manually edit the
field in UserInfo is update.
>fire ...
> However when I do this via my code the trigger does not seem to
>and prepare testing and report back shortly.
> Per Helen's suggestion I will reverse the order of the transaction
>the
> 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
> Prepared test. If the query needs to be prepared, it won'tprepare if it's
> not in a started transaction.- have
>
> To repeat what Marco said - the client side does not --- can not --
> any influence over whether a trigger fires or not.records
>
> If you eliminated the possibility that the after trigger finds no
> to operate on, then the next thing to look at is the possibilitythat, in
> one case, the DML is operating on the table and, in the other, itis
> operating on a view. If it's a view, the table triggers won'tfire; if
> it's a table, the view triggers won't fire._____________________________________________________________________
>
> Helen
>
>
>
>
______
> IB Objects - direct, complete, custom connectivity to Firebird orInterBase
> without the need for BDE, ODBC or any other layer._____________________________________________________________________
>
______
> http://www.ibobjects.com - your IBO community resource for TechInfo papers,
> keyword-searchable FAQ, community code contributions andmore !
>unsubscribe@yahoogroups.com?subject=Unsubscribe>
>
>
> _____
>
> 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-
>of <http://docs.yahoo.com/info/terms/> Service.
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms
>
>
> [Non-text portions of this message have been removed]