# Problem with Rails and Oracle sequences

**URL:** <https://www.ruby-forum.com/t/problem-with-rails-and-oracle-sequences/176728>\
**Category:** Rails\
**Created:** [October 5, 2009, 2:35pm UTC](https://www.ruby-forum.com/t/problem-with-rails-and-oracle-sequences/176728 "2009-10-05T14:35:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rafaelrosafu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@rafaelrosafu](https://www.ruby-forum.com/u/rafaelrosafu)\
**Post date:** [October 5, 2009, 2:35pm UTC](https://www.ruby-forum.com/t/problem-with-rails-and-oracle-sequences/176728/1 "2009-10-05T14:35:58Z")

</div>

Hi all,  
Suppose my sequence current value is ‘1’ and I save a new record to the  
DB.After I call the save method,the attribute which uses the sequence  
has the value ‘2’,but in the database it is ‘3’.IÂ´m mapping the sequence  
as follows:

class Viagem \< ActiveRecord::Base  
set\_table\_name ‘xxxx’  
set\_primary\_key ‘xx’  
set\_sequence\_name ‘sequence\_name’

What could be wrong?  
Thanks,  
Rafael R.

---

<div class="post-metadata">

**Author:** ![rafaelrosafu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@rafaelrosafu](https://www.ruby-forum.com/u/rafaelrosafu)\
**Post date:** [October 5, 2009, 3:32pm UTC](https://www.ruby-forum.com/t/problem-with-rails-and-oracle-sequences/176728/2 "2009-10-05T15:32:29Z")

</div>

someone???

---

<div class="post-metadata">

**Author:** ![rafaelrosafu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@rafaelrosafu](https://www.ruby-forum.com/u/rafaelrosafu)\
**Post date:** [October 5, 2009, 3:33pm UTC](https://www.ruby-forum.com/t/problem-with-rails-and-oracle-sequences/176728/3 "2009-10-05T15:33:11Z")

</div>

On Mon, Oct 5, 2009 at 7:35 AM, Rafael R.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> set\_sequence\_name ‘sequence\_name’
> 
> What could be wrong?  
> Thanks,  
> Rafael R.

Which Oracle driver are you using? I used to have problems with the  
older one but now I use the enhanced one and it’s been much better.

> gem list --local|grep oracle  
> activerecord-oracle\_enhanced-adapter (1.2.0)

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)

---

<div class="post-metadata">

**Author:** ![rafaelrosafu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@rafaelrosafu](https://www.ruby-forum.com/u/rafaelrosafu)\
**Post date:** [October 5, 2009, 4:20pm UTC](https://www.ruby-forum.com/t/problem-with-rails-and-oracle-sequences/176728/4 "2009-10-05T16:20:23Z")

</div>

just correcting…  
I just put ojdbc14.jar in my %jruby\_home%/LIB directory

---

<div class="post-metadata">

**Author:** ![rafaelrosafu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@rafaelrosafu](https://www.ruby-forum.com/u/rafaelrosafu)\
**Post date:** [October 5, 2009, 3:55pm UTC](https://www.ruby-forum.com/t/problem-with-rails-and-oracle-sequences/176728/5 "2009-10-05T15:55:22Z")

</div>

Greg D. wrote:

> On Mon, Oct 5, 2009 at 7:35 AM, Rafael R.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > ï¿½set\_sequence\_name ‘sequence\_name’
> > 
> > What could be wrong?  
> > Thanks,  
> > Rafael R.
> 
> Which Oracle driver are you using? I used to have problems with the  
> older one but now I use the enhanced one and it’s been much better.
> 
> > gem list --local|grep oracle  
> > activerecord-oracle\_enhanced-adapter (1.2.0)
> 
> –  
> Greg D.  
> [http://destiney.com/](http://destiney.com/)

Hi Greg,  
IÂ´m using Oracle 9.2.I just put ojdbc14.jar in my %jruby\_home%/bin  
directory and it is ready to go.

In my environment.rb I have the following:  
if RUBY\_PLATFORM =~ /java/  
require ‘rubygems’  
gem ‘activerecord-jdbc-adapter’, ‘0.9’  
require ‘jdbc\_adapter’  
end

And my database.yml looks like this:  
development:  
adapter: jdbc  
driver: oracle.jdbc.OracleDriver  
url: jdbc:oracle:thin:@ip:1521:database  
username: xxxxxx  
password: xxxxxx  
encoding: utf8  
pool: 5

What should I change?  
Thanks for your attention.  
Rafael R.
