Whoops, This should be correct.  Sorry for the mis-code. :)

Robert,

I generally use cftry/cfcatch in conjunction with cftransaction.  This
allows you to roll back if errors are encountered.  The general outline is
this:

<cftransaction action="BEGIN">

<cfset doCommit = True>

<cftry>
 <cfquery whatever...>
        some sql...
 </cfquery>
 <cfquery whatever...>
        some sql...
 </cfquery>

 <cfcatch type="any">
  <cfset doCommit=False> Set it to false if there was an error...
 </cfcatch>
</cftry>

<!--- Test the results --->
<cfif doCommit EQ True>
        <cftransaction action="COMMIT"/> Success!!!
        <cfset session.errormessage="none">
<cfelse>
        <cftransaction action="ROLLBACK"/> Failure!!!
        <cfset session.errormessage="There was difficulty processing you data.
Please go back and review your values.">
        <cflocation url="index.cfm?fuseaction=error">
</cfif>

</cftransaction>



-----Original Message-----
From: Robert Everland [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 02, 2002 1:58 PM
To: CF-Talk
Subject: CFtransaction crap


        I have an AS/400 and I am not sure if it supports transactions and I
want to test it. Is the syntax for cftransaction correct below. I would like
to pretend there is an error right after I insert the newlinenumber and I
would like to roll that back.


<cftransaction action="BEGIN">
        <cfquery name="GetNextNumber" datasource="#request.AS400dsn#"
dbtype="ODBC">
                SELECT  #request.enviroment_exception#.F0002.NNN002 as Next
                FROM #request.enviroment_exception#.F0002
                WHERE #request.enviroment_exception#.F0002.NNSY =
<cfqueryparam value="55" cfsqltype="CF_SQL_VARCHAR">
        </cfquery>

        <cftransaction action="COMMIT"/>


        <!--- Set number to have zeros in from which will be shortened
throughout application --->
        <cfset variables.TrimOrderNum = "0000000#GetNextNumber.Next#">

        <!--- Set new line number to be 1 up from old number --->
        <cfset variables.newlinenumber = GetNextNumber.Next + 1>

        <!--- Insert new line number --->
        <cfquery name="InsertNewLineNumber" datasource="#request.AS400dsn#"
dbtype="ODBC">
                update  #request.enviroment_exception#.F0002
                SET     NNN002 = <cfqueryparam
value="#variables.newlinenumber#" cfsqltype="CF_SQL_INTEGER">
                WHERE   #request.enviroment_exception#.F0002.NNSY =
<cfqueryparam value="55" cfsqltype="CF_SQL_VARCHAR">
        </cfquery>

        <cftransaction action = "rollback"/>


</cftransaction>

Robert Everland III
Dixon Ticonderoga
Web Developer Extraordinaire


______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to