Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cftransaction question

Participant ,
Sep 15, 2008 Sep 15, 2008
Hi all, for a cftransaction similar as shown below,

<cftransaction action="BEGIN">
<cftry>

<cfquery ............>
SQL statement
</cfquery>

<cfquery ............>
SQL statement
</cfquery>

other statements

<cftransaction action="commit" /> <!--- is this necessary??? --->

<cfcatch type="any">
<cftransaction action="rollback" />
<cfoutput>
#cfcatch.detail#
</cfoutput>
</cfcatch>

</cftry>

</cftransaction>


Is the <cftransaction action="commit" /> necessary? What happens if I remove this line?
TOPICS
Database access
625
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Sep 16, 2008 Sep 16, 2008
Removing the COMMIT may or may not affect the outcome, as it probably depends on the particular RDBMS that you are using, and whether or not your "session" is set for auto-commit, etc, but one major point of using CFTRANSACTION is to allow you to control whether or not your transaction is committed or rolled back if something goes wrong, etc. This is in addition to giving you control over "holding" the state of certain database updates so that you can guarantee that state against other transactions until you complete your transaction, etc.

Phil
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 19, 2008 Sep 19, 2008
LATEST
Thanks
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources