ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 15th, 2012, 09:28 AM
alwaysprepared alwaysprepared is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 3 alwaysprepared User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 5 sec
Reputation Power: 0
Want to always commit a certain CFQUERY Insert within a CFTRANSACTION

I have a situation where I would like to always COMMIT a CFQUERY Insert statement into a Log table within a CFTRANSACTION block whether the transaction succeeds or fails. I am a Coldfusion newbie, so I am uncertain how best to proceed.
It seems from what I have researched that I might have 2 possible ways to do this.
1. Use CFTHREAD to kick off an asynchronous process to do this Insert. I'm uncertain if this would be immune from being Rolledback in a failed transaction, however.
2. Use Setsavepoint within the CFTRANSACTION and explicitly commit only that short block of code, obviously, without committing anything outside the Savepoint. I am unclear from the documentation if this would work as I intend or not.
We are running Coldfusion version 9.
I would appreciate any comments or advice here. Perhaps there is a better way of doing this altogether that I am overlooking??

Reply With Quote
  #2  
Old June 15th, 2012, 12:23 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,100 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 4 h 29 m 54 sec
Reputation Power: 966
If you want one of the updates to happen even if the transaction fails, then it shouldn't be part of the transaction. A transaction is an atomic unit, meaning it all succeeds or it all fails. So unless I'm missing something, you want to run this query either before or after the transaction, not within it.

Reply With Quote
  #3  
Old June 15th, 2012, 01:24 PM
alwaysprepared alwaysprepared is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 3 alwaysprepared User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 5 sec
Reputation Power: 0
Kiteless, I hear you and understand that. My issue then is the variables I need to output to my log table are multiple levels deep inside the Transaction. So, I guess my only choice is to pull the variables I need up the tree (so to speak) until I'm outside the transaction? Is that doable without losing the variable data??
I am pulling up some of the data a level while I was testing solutions with cfset caller.xxxxx function.... Not crazy about doing that, but I don't know a better way currently, being a Newbie and all..
Any further thoughts??


Quote:
Originally Posted by kiteless
If you want one of the updates to happen even if the transaction fails, then it shouldn't be part of the transaction. A transaction is an atomic unit, meaning it all succeeds or it all fails. So unless I'm missing something, you want to run this query either before or after the transaction, not within it.

Reply With Quote
  #4  
Old June 15th, 2012, 02:38 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,100 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 4 h 29 m 54 sec
Reputation Power: 966
Without seeing everything you're doing, it's hard to say. But it sounds like what you want to do is have the method running the transaction return some value or an object containing the data you need, and then use that to do your insert.

Reply With Quote
  #5  
Old June 19th, 2012, 10:02 AM
alwaysprepared alwaysprepared is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 3 alwaysprepared User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 5 sec
Reputation Power: 0
OK, I guess I'll work that direction, then. Appreciate the input....

Quote:
Originally Posted by kiteless
If you want one of the updates to happen even if the transaction fails, then it shouldn't be part of the transaction. A transaction is an atomic unit, meaning it all succeeds or it all fails. So unless I'm missing something, you want to run this query either before or after the transaction, not within it.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Want to always commit a certain CFQUERY Insert within a CFTRANSACTION

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap