# Multidatabase transactions

**URL:** <https://www.ruby-forum.com/t/multidatabase-transactions/129637>\
**Category:** Ruby\
**Created:** [February 20, 2008, 8:12am UTC](https://www.ruby-forum.com/t/multidatabase-transactions/129637 "2008-02-20T08:12:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![coolgeng\_coolgeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eada6e/32.png) [@coolgeng\_coolgeng](https://www.ruby-forum.com/u/coolgeng_coolgeng)\
**Post date:** [February 20, 2008, 8:12am UTC](https://www.ruby-forum.com/t/multidatabase-transactions/129637/1 "2008-02-20T08:12:59Z")

</div>

Hi guys,  
I build a application with SQL server and Oracle. At the beginning,  
there is no requirement to operate data between two database. But now I  
must  
access both database at the same time. I chose the ActiveRecord, but it  
could not resolve this problem. Now how can I deal with that?  
Thanks a lot.

---

<div class="post-metadata">

**Author:** ![coolgeng\_coolgeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eada6e/32.png) [@coolgeng\_coolgeng](https://www.ruby-forum.com/u/coolgeng_coolgeng)\
**Post date:** [February 20, 2008, 8:36am UTC](https://www.ruby-forum.com/t/multidatabase-transactions/129637/2 "2008-02-20T08:36:32Z")

</div>

2008/2/20, coolgeng coolgeng [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ```
> I build a application with SQL server and Oracle. At the beginning,
> 
> ```
> 
> there is no requirement to operate data between two database. But now I must  
> access both database at the same time. I chose the ActiveRecord, but it  
> could not resolve this problem. Now how can I deal with that?

I do not know of anything in Ruby land that would be able to do this  
(which does not mean there is none). Basically you would need XA  
support for this because we are talking distributed transactions here.  
So the XA transaction would either have to be coordinated by Ruby code  
or you would need a TX manager which you can access from Ruby like  
this one for example:

> **[Microsoft Learn: Build skills that open doors in your career](https://learn.microsoft.com/en-us/)**
>
> Gain technical skills through documentation and training, earn certifications and connect with the community

It may be that you can solve this using database links in Oracle.  
However I was not able to determine whether the linked database needs  
to be an Oracle DB as well (I would guess so).

If you do not have strict TX requirements and do not need queries to  
return data from both databases you might get away with using two  
independent DB connections. But this does not give you 2PC.

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![coolgeng\_coolgeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eada6e/32.png) [@coolgeng\_coolgeng](https://www.ruby-forum.com/u/coolgeng_coolgeng)\
**Post date:** [February 20, 2008, 9:04am UTC](https://www.ruby-forum.com/t/multidatabase-transactions/129637/3 "2008-02-20T09:04:18Z")

</div>

Now I just try use commander like “transaction” to resolve this .  
However it  
still some bug in this. It can not act as ACID. So …  
By the way, shall I migrate the data from one of database to another?  
But I  
do not think it is a good idea.

---

<div class="post-metadata">

**Author:** ![coolgeng\_coolgeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eada6e/32.png) [@coolgeng\_coolgeng](https://www.ruby-forum.com/u/coolgeng_coolgeng)\
**Post date:** [February 20, 2008, 10:24am UTC](https://www.ruby-forum.com/t/multidatabase-transactions/129637/4 "2008-02-20T10:24:35Z")

</div>

I mean in Rails. The key word “transaction” can resovle the Transaction.  
However not for multidatabase transaction.  
If I use the keyword ‘transaction’, some problems still come out.

---

<div class="post-metadata">

**Author:** ![coolgeng\_coolgeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eada6e/32.png) [@coolgeng\_coolgeng](https://www.ruby-forum.com/u/coolgeng_coolgeng)\
**Post date:** [February 21, 2008, 8:01pm UTC](https://www.ruby-forum.com/t/multidatabase-transactions/129637/5 "2008-02-21T20:01:04Z")

</div>

On 20.02.2008 10:23, coolgeng coolgeng wrote:

> I mean in Rails. The key word “transaction” can resovle the Transaction.  
> However not for multidatabase transaction.  
> If I use the keyword ‘transaction’, some problems still come out.

Sorry, no Rails experience here. I can’t help you there.

Cheers

robert

---

<div class="post-metadata">

**Author:** ![coolgeng\_coolgeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eada6e/32.png) [@coolgeng\_coolgeng](https://www.ruby-forum.com/u/coolgeng_coolgeng)\
**Post date:** [February 20, 2008, 10:03am UTC](https://www.ruby-forum.com/t/multidatabase-transactions/129637/6 "2008-02-20T10:03:49Z")

</div>

2008/2/20, coolgeng coolgeng [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Now I just try use commander like “transaction” to resolve this . However it  
> still some bug in this. It can not act as ACID. So …

Pardon?

> By the way, shall I migrate the data from one of database to another? But I  
> do not think it is a good idea.

With the little we know so far it’s impossible to answer this question.

Cheers

robert
