Subject RE: [IBO] Re: Problem with triggers
Author Eric Tishler
Just a note to all, I got everything working just fine. There was never a problem with the trigger, I was just looking at the wrong records. This was due mostly to an ugly database schema and lack of documentation. I suppose this happens a lot when you inherit a large-scale client/server application with little documentation. :-)

Anyway, this I have a point of interest for Helen. In your email below you indicated that the proper order is to perform the transaction test first and then the SQL prepare.

I had this backwards in my code originally, but it still worked. That is I had:

with DataAccessMod.IBODQuery do
begin
// construct the update SQL
Active := False;
SQL.Clear;
SQL.Add('UPDATE "UserAccounts" SET ');
SQL.Add('"Credits" = ' + IntToStr(iTotAmount) + ' ');
SQL.Add('WHERE "AccountID" = ' + IntToStr(iAccountID));

// run the UPDATE
try
// start the transaction, prepare the DSQL statement
if not Prepared then Prepare;
if not IB_Transaction.Started then IB_Transaction.StartTransaction;

// run the DSQL statment and commit
ExecSQL;
IB_Transaction.Commit;
except
// do not attempt further processing
on E: Exception do
begin
HandleDBException(SQL.Text, E.Message);
exit; // g'bye
end;
end;
end;

When I switched these two statements around, such as:

if not IB_Transaction.Started then IB_Transaction.StartTransaction;
if not Prepared then Prepare;

I got a very nasty exception, trying to read memory at a very low address. Both the IB_Transaction: TIB_Transaction; and the IBODQuery: TIB_DSQL; where components I dropped on my DataModule form. Also as another point in interest, I was able to hook the TIB_DSQL component up to my connection, but the TIB_Transaction would not allow me to select the connection as design time. (It kept going back to Default)

Any thoughts on this?

Regards,
WEric

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

-----Original Message-----
From: Helen Borrie [mailto:helebor@...]
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]