Subject | RE: [IBO] Explicit transaction and FK Violation |
---|---|
Author | Nico Callewaert |
Post date | 2001-02-17T18:53:40Z |
Helen,
Do you have to call "StartTransaction", or does IBO this for you ?
Because I never call this method and everything seems to work fine. Maybe
you could explain me the advantage of this ? And is it necessary to call
"Unprepare" for a query, or is a hard "Commit" enough ?
Many thanks,
Kind regards,
Nico Callewaert
-----Oorspronkelijk bericht-----
Van: Helen Borrie [mailto:helebor@...]
Verzonden: zaterdag 17 februari 2001 12:10
Aan: IBObjects@yahoogroups.com
Onderwerp: Re: [IBO] Explicit transaction and FK Violation
At 09:57 PM 17-02-01 +1100, you wrote:
was a try...except. So here's replacement code for the end part:
Rollback;
{{ handle the error }}
code in the finally....end block *regardless* of what happens between
try.... and finally, e.g. restore a screen cursor, release/free an object
created by the method before the try... block began, etc.
With your use of finally... you are trying to run code which is
actually impossible because the unhandled error inside the try... block
makes the Commit impossible.
HB
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________
Yahoo! Groups Sponsor
Stamp powered by www.mailround.com
[Non-text portions of this message have been removed]
Do you have to call "StartTransaction", or does IBO this for you ?
Because I never call this method and everything seems to work fine. Maybe
you could explain me the advantage of this ? And is it necessary to call
"Unprepare" for a query, or is a hard "Commit" enough ?
Many thanks,
Kind regards,
Nico Callewaert
-----Oorspronkelijk bericht-----
Van: Helen Borrie [mailto:helebor@...]
Verzonden: zaterdag 17 februari 2001 12:10
Aan: IBObjects@yahoogroups.com
Onderwerp: Re: [IBO] Explicit transaction and FK Violation
At 09:57 PM 17-02-01 +1100, you wrote:
>Do it this way:Sorry, just noticed this try..finally.. which I mistakenly thought
>
>procedure DoSQLWork( mySQL : String);
>begin
> with DataModule1.trWork do
> begin
> try
> if InTransaction then
> try
> Commit
> except
> Rollback;
> {{ and do something }};
> end;
> StartTransaction;
> with DataModule1.ibDSQLWork do
> begin
> if Prepared then
> Prepared := False;
> SQL.Clear;
> SQL.Add(mySQL);
> Prepare;
> Execute;
> end;{with ibDSQLWork}
> finally
> Commit;
> end;{try}
> end;{with trWork}
>end;{DoSQLWork}
was a try...except. So here's replacement code for the end part:
> try..........
> Prepare;except
> Execute;
> end;{with ibDSQLWork}
> Commit
Rollback;
{{ handle the error }}
> end;{try}You should use try...finally to force the program to run a piece of
> end;{with trWork}
>end;{DoSQLWork}
code in the finally....end block *regardless* of what happens between
try.... and finally, e.g. restore a screen cursor, release/free an object
created by the method before the try... block began, etc.
With your use of finally... you are trying to run code which is
actually impossible because the unhandled error inside the try... block
makes the Commit impossible.
HB
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________
Yahoo! Groups Sponsor
Stamp powered by www.mailround.com
[Non-text portions of this message have been removed]