I have the follow code to update an existing record:
<CFSET commitIt = "Yes">
<CFTRANSACTION ACTION="BEGIN">
<CFTRY>
<CFQUERY NAME="qryUpdateRefund" DBNAME="#Application.DSN3#" DBTYPE="ODBC" DATASOURCE="#Application.DSN3#">
UPDATE dbo.Compensation
SET <CFIF IsDefined("URL.Rate"
>
<CFIF URL.Rate EQ "">
Rate = NULL,
<CFELSE>
Rate = '#URL.Rate#',
</CFIF>
</CFIF>
<CFIF IsDefined("URL.Hours"
>
<CFIF URL.Hours EQ "">
Hours = NULL,
<CFELSE>
Hours = '#URL.Hours#',
</CFIF>
</CFIF>
<CFIF IsDefined("URL.Compensation"
>
<CFIF URL.Compensation EQ "">
Compensation = NULL,
<CFELSE>
Compensation = '#URL.Compensation#',
</CFIF>
</CFIF>
<CFIF IsDefined("URL.Alternate"
>
<CFIF URL.Alternate EQ "">
Alternate = NULL,
<CFELSE>
Alternate = '#URL.Alternate#',
</CFIF>
</CFIF>
<CFIF IsDefined("URL.Additional"
>
<CFIF URL.Additional EQ "">
Additional = NULL,
<CFELSE>
Additional = '#URL.Additional#',
</CFIF>
</CFIF>
<CFIF IsDefined("URL.Comments"
>
<CFIF URL.Additional EQ "">
Comments = NULL
<CFELSE>
Comments = '#URL.Comments#'
</CFIF>
</CFIF>
WHERE CourseID = '#URL.CourseID#'
AND PersonID = '#URL.ContextID#'
</CFQUERY>
<CFCATCH TYPE="DATABASE">
<CFIF CFCATCH.NativeErrorCode EQ "08S01">
Database is unavailable.<BR>
<CFELSE>
<CFTRANSACTION ACTION="ROLLBACK"/>
</CFIF>
NativeError Code: <cfoutput>#CFCATCH.NativeErrorCode#</cfoutput><BR>
Error Message: <cfoutput>#CFCATCH.message#</cfoutput><BR>
<CFSET commitIt= "No">
</CFCATCH>
</CFTRY>
<CFIF commitIt>
<CFTRANSACTION ACTION="COMMIT"/>
<CFELSE>
Your transaction to update this Compensation record: <CFOUTPUT>#qryCompensation.CompensationID#</CFOUTPUT> did not complete successfully.
<CFABORT>
</CFIF>
</CFTRANSACTION>
Problem: The update fails if it is inside the <CFTRY>...</CFTRY> tags but successfully update the record if I remove the <CFTRY></CFTRY> tag, why?
The error I got back when I get an error is:
NativeError Code: 8114
Error Message: ODBC Error Code = 37000 (Syntax error or access violation)
The error message is too general. Can someone tell me what this mean?
<CFSET commitIt = "Yes">
<CFTRANSACTION ACTION="BEGIN">
<CFTRY>
<CFQUERY NAME="qryUpdateRefund" DBNAME="#Application.DSN3#" DBTYPE="ODBC" DATASOURCE="#Application.DSN3#">
UPDATE dbo.Compensation
SET <CFIF IsDefined("URL.Rate"
<CFIF URL.Rate EQ "">
Rate = NULL,
<CFELSE>
Rate = '#URL.Rate#',
</CFIF>
</CFIF>
<CFIF IsDefined("URL.Hours"
<CFIF URL.Hours EQ "">
Hours = NULL,
<CFELSE>
Hours = '#URL.Hours#',
</CFIF>
</CFIF>
<CFIF IsDefined("URL.Compensation"
<CFIF URL.Compensation EQ "">
Compensation = NULL,
<CFELSE>
Compensation = '#URL.Compensation#',
</CFIF>
</CFIF>
<CFIF IsDefined("URL.Alternate"
<CFIF URL.Alternate EQ "">
Alternate = NULL,
<CFELSE>
Alternate = '#URL.Alternate#',
</CFIF>
</CFIF>
<CFIF IsDefined("URL.Additional"
<CFIF URL.Additional EQ "">
Additional = NULL,
<CFELSE>
Additional = '#URL.Additional#',
</CFIF>
</CFIF>
<CFIF IsDefined("URL.Comments"
<CFIF URL.Additional EQ "">
Comments = NULL
<CFELSE>
Comments = '#URL.Comments#'
</CFIF>
</CFIF>
WHERE CourseID = '#URL.CourseID#'
AND PersonID = '#URL.ContextID#'
</CFQUERY>
<CFCATCH TYPE="DATABASE">
<CFIF CFCATCH.NativeErrorCode EQ "08S01">
Database is unavailable.<BR>
<CFELSE>
<CFTRANSACTION ACTION="ROLLBACK"/>
</CFIF>
NativeError Code: <cfoutput>#CFCATCH.NativeErrorCode#</cfoutput><BR>
Error Message: <cfoutput>#CFCATCH.message#</cfoutput><BR>
<CFSET commitIt= "No">
</CFCATCH>
</CFTRY>
<CFIF commitIt>
<CFTRANSACTION ACTION="COMMIT"/>
<CFELSE>
Your transaction to update this Compensation record: <CFOUTPUT>#qryCompensation.CompensationID#</CFOUTPUT> did not complete successfully.
<CFABORT>
</CFIF>
</CFTRANSACTION>
Problem: The update fails if it is inside the <CFTRY>...</CFTRY> tags but successfully update the record if I remove the <CFTRY></CFTRY> tag, why?
The error I got back when I get an error is:
NativeError Code: 8114
Error Message: ODBC Error Code = 37000 (Syntax error or access violation)
The error message is too general. Can someone tell me what this mean?