Andy,

Looks great I'll try this soon! Thank you soo much for your help and time.

Regards,
JB

Andy Ousterhout wrote:

>James,
>
>Here is the outline of the code that should work.  Just plug in your
>queries:
>
><cfset IsOK = True>
><cftransaction action="begin">
>       <cftry>
>               <cfquery to read from A>
>               <cfcatch>
>                       <cfset IsOK = False>
>               </cfcatch>
>       </cftry>
>
>       <cfif IsOK>
>               <cftry>
>                       <cfquery to save in B>
>                       <cfcatch>
>                               <cfset IsOK = False>
>                       </cfcatch>                      <
>               </cftry>
>
>               <cfif IsOK>
>                       <cftry>
>                               <cfquery to delete from A>
>                               <cfcatch>
>                                       <cfset IsOK = False>
>                               </cfcatch>                      <
>                       </cftry>
>               </cfif>
>       </cfif>
>
>       <cfif IsOK>
>               <cftransaction action="commit">
>       <cfelse>
>               <cftransaction action = "rollback">
>       </cfif>
></cftransaction>
>
>
>-----Original Message-----
>From: James Blaha [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, February 11, 2003 1:08 PM
>To: CF-Talk
>Subject: cftransaction HELP Please...
>
>
>Hello All,
>
>I need some help. What Im trying to do is setup a transaction thats
>purpose is to move a record from table A to table B and if it is
>successful delete it from A. If anything fails roll back and output
>the error. Can anyone please offer some insight to either using
>different code or patching what I have below?
>
>I'm running CF5 Enterprise.
>
>Regards,
>James Blaha
>
>Error
>Context validation error in tag CFTRY
>The tag is not correctly positioned relative to other tags in the
>template: the last tag nested inside tag CFTRY must be a CFCATCH tag.
>Currently it is a CFTRANSACTION tag.
>The error occurred while processing an element with a general identifier
>of (CFTRY), occupying document position (25:1) to (25:7).
>
>
><!---
>Filename: Example_Delete_CFTransaction.cfm
>Created by: James Blaha
>Purpose: Archive data & Roll Back for deletetion if an errors occur.
>Please Note:
>--->
>
><!---__________ ** This example shows the use of cftransaction **
>________--->
>
><html>
><head>
><title>cftransaction Example</title>
></head>
>
><body>
><H3>Archive data and Roll Back for deletetion if an errors occur.</H3>
>
><P>cftransaction can be used to group multiple queries
>using cfquery into a single business event. Changes to data
>requested by these queries can be committed on the basis
>of the success or failure of the query by using the actions
>commit and rollback, respectively.
>
>
><cftry>
>
>
><!--- ******************************************************************
>--->
><!--- *************** Initialize commitIt to Yes. ******************** --->
><!--- ******************************************************************
>--->
>
><CFSET commitIt = "Yes">
><cftransaction action = "begin">
>
><!--- ********* --->
><!--- *** 1 *** --->
><!--- ********* --->
>
><cfquery name = 'ArchiveRecord' dataSource = 'xxx'>
>
>Insert Into Archived_Applicants
>Select * From tApply
>WHERE [identity] = 2
>
></cfquery>
>
><!---
>*********************************************************************** --->
><!--- * Rolls back the pending insertion if a database exception is
>caught. * --->
><!---
>*********************************************************************** --->
>
><cfcatch type = "DATABASE">
><cftransaction action = "rollback"/>
><cfset commitIt = "No">
>
><!--- Test S --->
>
><BODY TEXT="1c3b85">
>
><DIV ALIGN="Center">
><TABLE>
><TR>
><TD WIDTH="400">
><H2>A Database Error Has Occurred !</H2>
>
><CFOUTPUT> #CFCATCH.Message#
><P>The following exception has occurred, TYPE= #CFCATCH.Type#
></CFOUTPUT>
></TD>
></TR>
></TABLE>
></DIV>
>
><!--- Test E --->
>
></cfcatch>
><cfif commitIt>
><cftransaction action = "commit"/>
>
><!--- ******************************************************************
>--->
><!--- *************** Commits the pending insertion. ***************** --->
><!--- ******************************************************************
>--->
><cfelse>
><cfset commitIt = "Yes">
></cfif>
>
>
><!--- ********* --->
><!--- *** 2 *** --->
><!--- ********* --->
>
>
><CFQUERY NAME="DeleteRecord" DATASOURCE="xxx">
>DELETE
>FROM tApply
>
>WHERE [identity] = 2
></CFQUERY>
>
><!---
>********************************************************************** --->
><!--- * Rolls back the pending deletetion if database exception is
>caught. * --->
><!---
>********************************************************************** --->
>
><cfcatch type = "DATABASE">
><cftransaction action = "rollback"/>
><cfset commitIt = "No">
>
>
><!--- Test S --->
>
><BODY TEXT="1c3b85">
>
><DIV ALIGN="Center">
><TABLE>
><TR>
><TD WIDTH="400">
><H2>A Database Error Has Occurred !</H2>
>
><CFOUTPUT> #CFCATCH.Message#
><P>The following exception has occurred, TYPE= #CFCATCH.Type#
></CFOUTPUT>
></TD>
></TR>
></TABLE>
></DIV>
>
><!--- Test E --->
>
></cfcatch>
><cfif commitIt>
><cftransaction action = "commit"/>
>
><!--- ******************************************************************
>--->
><!--- *************** Commits the pending deletetion.
>******************* --->
><!--- ******************************************************************
>--->
>
><cfelse>
><cfset commitIt = "Yes">
></cfif>
></cftransaction>
>
>
></cftry>
>
></body>
></html>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to