Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update table within a CFTRY tag

Status
Not open for further replies.

khue

Programmer
Mar 6, 2001
112
US
I have the follow code to update an existing record:

<CFSET commitIt = &quot;Yes&quot;>
<CFTRANSACTION ACTION=&quot;BEGIN&quot;>
<CFTRY>

<CFQUERY NAME=&quot;qryUpdateRefund&quot; DBNAME=&quot;#Application.DSN3#&quot; DBTYPE=&quot;ODBC&quot; DATASOURCE=&quot;#Application.DSN3#&quot;>
UPDATE dbo.Compensation
SET <CFIF IsDefined(&quot;URL.Rate&quot;)>
<CFIF URL.Rate EQ &quot;&quot;>
Rate = NULL,
<CFELSE>
Rate = '#URL.Rate#',
</CFIF>
</CFIF>
<CFIF IsDefined(&quot;URL.Hours&quot;)>
<CFIF URL.Hours EQ &quot;&quot;>
Hours = NULL,
<CFELSE>
Hours = '#URL.Hours#',
</CFIF>
</CFIF>
<CFIF IsDefined(&quot;URL.Compensation&quot;)>
<CFIF URL.Compensation EQ &quot;&quot;>
Compensation = NULL,
<CFELSE>
Compensation = '#URL.Compensation#',
</CFIF>
</CFIF>
<CFIF IsDefined(&quot;URL.Alternate&quot;)>
<CFIF URL.Alternate EQ &quot;&quot;>
Alternate = NULL,
<CFELSE>
Alternate = '#URL.Alternate#',
</CFIF>
</CFIF>
<CFIF IsDefined(&quot;URL.Additional&quot;)>
<CFIF URL.Additional EQ &quot;&quot;>
Additional = NULL,
<CFELSE>
Additional = '#URL.Additional#',
</CFIF>
</CFIF>
<CFIF IsDefined(&quot;URL.Comments&quot;)>
<CFIF URL.Additional EQ &quot;&quot;>
Comments = NULL
<CFELSE>
Comments = '#URL.Comments#'
</CFIF>
</CFIF>
WHERE CourseID = '#URL.CourseID#'
AND PersonID = '#URL.ContextID#'
</CFQUERY>

<CFCATCH TYPE=&quot;DATABASE&quot;>
<CFIF CFCATCH.NativeErrorCode EQ &quot;08S01&quot;>
Database is unavailable.<BR>
<CFELSE>
<CFTRANSACTION ACTION=&quot;ROLLBACK&quot;/>
</CFIF>

NativeError Code: <cfoutput>#CFCATCH.NativeErrorCode#</cfoutput><BR>
Error Message: <cfoutput>#CFCATCH.message#</cfoutput><BR>
<CFSET commitIt= &quot;No&quot;>
</CFCATCH>
</CFTRY>

<CFIF commitIt>
<CFTRANSACTION ACTION=&quot;COMMIT&quot;/>
<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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top