Hi Adam,

Cheers for the pointers, as usual a few queries....


> 3) Transactions must be controlled as close to the data as 
> possible, so stored procedures must have their own 
> transactional controls and either succeed or fail as a single 
> call.  Don't "return an error code"; just throw an exception 
> and let structured exception handling "handle" it.  And don't 
> use CFTRY for what CFERROR is supposed to do.

Are you saying that this type of code is wrong/inefficient/bad practice?

<cfset bDBAction = True>
<cftransaction action = "begin">
        <cftry>
                <cfquery name="myQuery" datasource="myDatasource">
                        .... some action sql ....
                </cfquery>

                <cfcatch type="DATABASE">
                        <cfset bDBAction = False>
                </cfcatch>
        </cftry>
        
        <cfif bDBAction>
                <cftransaction action="COMMIT" />
        <cfelse>
                <cftransaction action="ROLLBACK" />
        </cfif>
</cftransaction>

What would be a proper example of the above type of code if so?


> 4) CFTRANSACTION is for those times when you must make 
> separate calls between CF and the DB.  For example, inserting 
> a sales order row and then looping over the line items in a 
> shopping cart structure and repeatedly inserting line item 
> rows related to the sales order just inserted, where the 
> sales order ID is equal to the identity column value returned 
> by the insert trigger on the sales order table.  In this 
> case, you would wrap both the single sales order insert and 
> the loop with the line item inserts in a CFTRANSACTION 
> (always use the long form, rather than a simple paired 
> CFTRANSACTION tag); this signals through the database driver 
> that you intend for the database to consider these statements 
> as a single atomic action.

I am kinda getting this point..... but still a bit foggy....
Wot do you mean by long and short form of CFTRANSACTION tho?

Cheers

DC (Developing in CF5, Oracle 8.1.7, IIS 5)


                                
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

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

Reply via email to