User Guide
Example application 51
<cfset new = dao.update(old, new)>
<!--- Mark this change as processed successfully. --->
<cfset co.processed()>
<!--- If the SQL failed, mark this change with the error. --->
<cfcatch type="database">
<cfset msg = "Error during update: " & cfcatch.queryError &
". SQL was :" & cfcatch.sql>
<cfset co.fail(msg)>
</cfcatch>
<!--- If anything else happened, mark this change with the error. --->
<cfcatch type="any">
<cfset co.fail(cfcatch.message & " " & cfcatch.detail)>
</cfcatch>
</cftry>
<!--- Return the change object. --->
<cfreturn co>
</cffunction>
<cffunction name="doDelete" access="private" output="no">
<cfargument name="co" required="yes" hint="The change object.">
<!--- The record to delete. --->
<cfset var old = co.getPreviousVersion()>
<cftry>
<cfset dao = CreateObject("component", "samples.contact.ContactDAO")>
<!--- Delete the record. --->
<cfset dao.delete(old)>
<!--- Mark this change as processed successfully. --->
<cfset co.processed()>
<!--- If the SQL failed, mark this change with the error. --->
<cfcatch type="database">
<cfset msg = "Error during delete: " & cfcatch.queryError &
". SQL was :" & cfcatch.sql>
<cfset co.fail(msg)>
</cfcatch>
<!--- If anything else happened, mark this change with the error. --->
<cfcatch type="any">
<cfset co.fail(cfcatch.message & " " & cfcatch.detail)>
</cfcatch>
</cftry>
<!--- Return the change object. --->
<cfreturn co>
</cffunction>