James Rodgers
asked on
CFTRY w CFTRANSACTION - code not working
the below code ois directly from cf help files, when i tried to implement it i get an error about teh last block of a cftry must bre a cfcatch, but thsi code sample has a cftransaction, is there a different way to implement this?
<cftry>
<cfset commitIt = "Yes">
<cftransaction action = "begin">
<cfquery name = 'makeNewCourse' dataSource = 'cfsnippets'>
INSERT INTO Courses
(Course_Num, Descript)
VALUES
('#myNumber#', '#myDescription#')
</cfquery>
<cfcatch type = "DATABASE">
<cftransaction action = "rollback"/>
<cfset commitIt = "No">
</cfcatch>
<cfif commitIt>
<cftransaction action = "commit"/>
<cfelse>
<cfset commitIt = "Yes">
</cfif>
<cfquery name = 'insertNewCourseToList' dataSource = 'cfsnippets'>
INSERT INTO CourseList
(CorNumber, CorDesc, Dept_ID,
CorName, CorLevel, LastUpdate)
VALUES
('#myNumber#', '#myDescription#', '#myDepartment#',
'#myDescription#', '#myCorLevel#', #Now()#)
</cfquery>
<cfcatch type = "DATABASE">
<cftransaction action = "rollback"/>
<cfset commitIt = "No">
</cfcatch>
<cfif commitIt>
<cftransaction action = "commit"/>
<cfelse>
<cfset commitIt = "Yes">
</cfif>
</cftransaction>
</cftry>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that code makes more sense...
thanks
thanks
Open in new window