We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

cftransaction with multiple data sources

polobruce
polobruce asked
on
Medium Priority
494 Views
Last Modified: 2013-12-24
I have a script that basically pulls data from one dsn and inserts it using another dsn.

I am currently wrapping each insert in DSN 1 with a cftry and then at the end

  <cfcatch type = "DATABASE">
    <cfset commitIt = "No">
    <cftransaction action = "rollback"/>
  </cfcatch>
</CFTRY>


at the end of the entire transaction i have the following:

  <cfif commitIt>
    <cftransaction action = "commit"/>
    <!--------------------------------------------------------------
    Commits the pending insertion.
    ---------------------------------------------------------------->
  <cfelse>
    <cfset commitIt = "Yes">
  </cfif>


</cftransaction>



I'm getting an error  of:

 Data source eventreg verification failed.
The root cause was that: java.sql.SQLException: Datasource names for all the database tags within CFTRANSACTION must be the same.

This is correct because i have nested queries inside the transaction that lookup records and verify them.
 

What solution can i do to safely complete this transaction even when i have queries like this.
Comment
Watch Question

Commented:
polobruce,

You simply can't use cftransaction across datasources.

Put the two different tasks within two seperate <cftransaction blocks.

If one fails, you may need to code manually a rollback.

Regards
Plucka

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.