﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Transactions</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sun, 05 Apr 2026 15:00:22 GMT</lastBuildDate><ttl>20</ttl><item><title>Transactions</title><link>http://forum.strataframe.net/FindPost3038.aspx</link><description>My question is this, when exactly do I know a transactional save has been successful?&lt;br&gt;
&lt;br&gt;
The code below is from the documentation for illustration purposes.&lt;br&gt;
&lt;br&gt;
Lets say that the BO [b]me.customers[/b] had records added that were imported from an XML file. Once I know that information is safely saved off to my SQL server I want to dispose of/archive the XML source.&lt;br&gt;
&lt;br&gt;
Where in the code below would you actually be 100% sure the values were saved successfully enough to delete the file?&lt;br&gt;
&lt;br&gt;
Thank you.&lt;br&gt;
&lt;br&gt;
Public Sub SaveAllOnTransaction()&lt;br&gt;
    '-- Add a try around the transaction processing&lt;br&gt;
    '   This enables the process to call TransactionRollback()&lt;br&gt;
    '   if anything bad happens during the transaction process.&lt;br&gt;
    Try&lt;br&gt;
        '-- Start the transaction&lt;br&gt;
        BusinessLayer.TransactionBegin(Data.IsolationLevel.ReadCommitted)&lt;br&gt;
        &lt;br&gt;
        '-- Save the business objects on the transaction&lt;br&gt;
        Me.Customers.Save(True)&lt;br&gt;
        Me.Orders.Save(True)&lt;br&gt;
        Me.OrderItems.Save(True)&lt;br&gt;
        &lt;br&gt;
        '-- When business objects are saved on the transaction, the&lt;br&gt;
        '   pending changes to their internal DataTables are NOT saved&lt;br&gt;
        '   until TransactionEnd() is called...&lt;br&gt;
        '-- Call transaction end to commit the transaction queries and&lt;br&gt;
        '   accept the pending changes on all of the business objects&lt;br&gt;
        '   that participated in the transaction.&lt;br&gt;
        BusinessLayer.TransactionEnd()&lt;br&gt;
    &lt;br&gt;
    Catch ex As Exception&lt;br&gt;
        '-- If an exception occurs during the saving of the records, then &lt;br&gt;
        '   abort the transaction.&lt;br&gt;
        BusinessLayer.TransactionRollback()&lt;br&gt;
    End Try&lt;br&gt;
End Sub&lt;br&gt;</description><pubDate>Tue, 26 Sep 2006 15:33:25 GMT</pubDate><dc:creator>Keith Chisarik</dc:creator></item><item><title>RE: Transactions</title><link>http://forum.strataframe.net/FindPost3086.aspx</link><description>It is possible for the TransactionCommit() to throw an exception, so if you put your code after the TransactionCommit(), then you can be sure that it was committed successfully, because if the TransactionCommit fails, then it will throw an exception (which is why you have the TransactionRollback() in the catch of the try/catch structure).&amp;nbsp; Also, if you put your TransactionCommit() in an If test like that other sample, then make sure you put the TransactionRollback() in the Else of the test in case the TransactionCommit() is never called, otherwise the database might keep the table locked.</description><pubDate>Tue, 26 Sep 2006 15:33:25 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Transactions</title><link>http://forum.strataframe.net/FindPost3050.aspx</link><description>Good deal :)</description><pubDate>Mon, 25 Sep 2006 15:17:04 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Transactions</title><link>http://forum.strataframe.net/FindPost3048.aspx</link><description>Perfect, thanks!&lt;br&gt;
&lt;br&gt;
:D</description><pubDate>Mon, 25 Sep 2006 15:15:46 GMT</pubDate><dc:creator>Keith Chisarik</dc:creator></item><item><title>RE: Transactions</title><link>http://forum.strataframe.net/FindPost3046.aspx</link><description>Well, all business objects return a success state.&amp;nbsp; For example:&lt;/P&gt;&lt;P&gt;If MyBO.Save() = Success Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TransactionCommit()&lt;BR&gt;ENd If&lt;/P&gt;&lt;P&gt;And as for the one table question.&amp;nbsp; The answer is not necessarily.&amp;nbsp; Read the post I added prior to this one.&amp;nbsp;</description><pubDate>Mon, 25 Sep 2006 15:14:34 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Transactions</title><link>http://forum.strataframe.net/FindPost3045.aspx</link><description>Yes, is there a return value to TransactionCommit? I didnt see one defined using the Object Browser.&lt;br&gt;
&lt;br&gt;
In VFP I got a return value on by buffered table when I issued a commit, when I got a .T., I knew to feel all warm and fuzzy about my data save. I guess I am looking for that same thing here.</description><pubDate>Mon, 25 Sep 2006 15:10:25 GMT</pubDate><dc:creator>Keith Chisarik</dc:creator></item><item><title>RE: Transactions</title><link>http://forum.strataframe.net/FindPost3042.aspx</link><description>Using a transaction for a single BO is not necessarily overkill...it just depends on what youa re attempting to accomplish.&amp;nbsp; So this is just really up to you.&lt;/P&gt;&lt;P&gt;As for knowing when the save has been successful, this too is up to you :)&amp;nbsp; If you have not received any errors, broken rules, exceptions, etc.&amp;nbsp; then it would more than likely be a good save and the TransactionCommit would be ready to be called.&amp;nbsp; That is the point of a transaction, you can place save logic while it is saving and if something happens, be it an error or just some broken logic, you can issue the TransactionRollback.&amp;nbsp; Does this make sense.&amp;nbsp; Knowing whether you are ready to call the TransactionCommit is up to you to know.&amp;nbsp; If you have not received any errors, in most cases, it would be safe to call the TransactionCommit.&amp;nbsp; Make sense?</description><pubDate>Mon, 25 Sep 2006 15:05:00 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Transactions</title><link>http://forum.strataframe.net/FindPost3040.aspx</link><description>Also, is a transaction overkill on a save to a single BO?&lt;br&gt;
&lt;br&gt;
If yes, the same question applies, when/how exactly do I KNOW that BO.SAVE() was successfully written to the SQL Server?&lt;br&gt;
&lt;br&gt;
Thanks.</description><pubDate>Mon, 25 Sep 2006 14:55:35 GMT</pubDate><dc:creator>Keith Chisarik</dc:creator></item></channel></rss>