Tim: if you're using commands like DB1['rollback'] or DB1['commit'], why are you still using Sequel?
Sequel is much more than just sending raw SQL commands... You should replace most of these commands by Sequel equivalents, if you wish to have a portable/reusable code. Back to your use case: my original suggestion would have been to split into 2 transactions. Yet the last snippet from Jeremy is an eye-opener: if any of 2 transactions on DB1 and DB2 fails, then it would rollback on both DB. Is this what you need? On Tue, Mar 25, 2014 at 10:03 PM, Jeremy Evans <[email protected]>wrote: > On Tuesday, March 25, 2014 1:29:49 PM UTC-7, Tim Uckun wrote: >> >> >>> I'm not exactly sure what you mean. If you aren't inside a transaction, >>> PostgreSQL treats each statement as inside it's own transaction. I'm >>> guessing the answer to your question is to enclose the individual calls in >>> a transaction block. >>> >>> >> I mean this... >> >> DB1['begin transaction'] >> DB2['begin transaction'] >> >> ... Do some more stuff with DB1 and DB2. >> >> if (something or another) >> DB1['rollback'] >> DB2['rollback'] >> else >> DB1['commit'] >> DB2['commit'] >> end >> >> >> I think the only way this can work is if I am using the same connection >> from the pool throughout the code. Sometimes with AR I checkout a >> connection from the pool, use it on multiple statements, and then either >> commit or rollback. >> > > As mentioned earlier, by design Sequel does not have a blockless > transaction API. You need do things inside a transaction block: > > Sequel.transaction([db1, db2]) do > # ... Do some more stuff with DB1 and DB2. > raise Sequel::Rollback if (something or another) > end > > For similar reasons, by design Sequel does not have a blockless > connection-checkout API. > > Thanks, > Jeremy > > -- > You received this message because you are subscribed to the Google Groups > "sequel-talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sequel-talk. > For more options, visit https://groups.google.com/d/optout. > -- Christian -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
