The way the code is written, the cfif will never be true because it will always 
have "<br>" in so the length will never be below 4.

> Hi all, I understand the gist of cftransaction, but I've tried using 
> it with a conditional rollback on an action page in the below example 
> and it doesn't seem to work. saveDataToDatabase() submits data to a 
> stored procedure, which always returns a string: empty string if the 
> data was saved, or a message stating what the problem was if not.
> 
> <cfset allReturnMessages = "">
> <cftransaction>
  
> <cfloop>
      
> <cfset returnMessage = someCFC.saveDataToDatabase()>
      
> <cfset allReturnMessages = allReturnMessages & returnMessage & 
> "<br>">
  
> </cfloop>
  
> <cfif len(trim(allReturnMessages))>
     
> <cftransaction action="rollback" />
  
> </cfif>
> </cftransaction>
> 
> I'm not including cftry in this example, just to illustrate that I'm 
> not looking for a database or other type of CF error per se - rather, 
> I'm looking for any return message from the stored proc that isn't an 
> empty string, such as "sorry - everything is otherwise kosher, but 
> this stored proc is coded not to save the data if field x is above 
> value y". That's not a database error as far as CF is concerned, so 
> cftry wouldn't catch it. But in testing this code, I've found that the 
> rollback doesn't take place, even when the cfif statement is true. Am 
> I not using cftransaction correctly? 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:329097
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to