# JRuby-Oracle Error - Part 2

**URL:** <https://www.ruby-forum.com/t/jruby-oracle-error-part-2/167305>\
**Category:** Rails\
**Created:** [May 6, 2009, 4:28pm UTC](https://www.ruby-forum.com/t/jruby-oracle-error-part-2/167305 "2009-05-06T16:28:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nlsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/43a26b/32.png) [@nlsmith](https://www.ruby-forum.com/u/nlsmith)\
**Post date:** [May 6, 2009, 4:28pm UTC](https://www.ruby-forum.com/t/jruby-oracle-error-part-2/167305/1 "2009-05-06T16:28:41Z")

</div>

My app is using JRuby on Rails and Oracle. I have a join table that has  
not ID column. When I create the table via db:migrate, no Oracle  
Sequence is set up for it. Later when I populate the table with data, I  
get an error that the sequence for the table doesn’t exist. The  
db:migrate error is:

== UpdatePackagesValues: migrating ====================================  
rake aborted!  
An error has occurred, all later migrations canceled:

ActiveRecord::ActiveRecordError: ORA-02289: sequence does not exist  
: select packages\_values\_seq.nextval id from dual

I am using ActiveRecord-JDBC (0.5) and activerecord-jdbc-adapter (0.8)  
gems for accessing the database. The current 0.9.1 adapter has several  
problems that I can’t work around. This feels like bug in  
activerecord-jdbc-adapter (0.8) and I can work around it by manually  
creating the Oracle Sequence object.

Also related is the fact that the Oracle Sequence Objects default to  
starting at 10000. Is this an Oracle thing or can it be configured in  
the adapter? I think I can get around this issue for now by manually  
deleting and recreating the Sequence Objects before any data is loaded  
into the database.

Norm

---

<div class="post-metadata">

**Author:** ![nlsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/43a26b/32.png) [@nlsmith](https://www.ruby-forum.com/u/nlsmith)\
**Post date:** [May 6, 2009, 5:01pm UTC](https://www.ruby-forum.com/t/jruby-oracle-error-part-2/167305/2 "2009-05-06T17:01:21Z")

</div>

On Wed, May 6, 2009 at 9:28 AM, Norman Smith  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> starting at 10000. Is this an Oracle thing or can it be configured in  
> the adapter? I think I can get around this issue for now by manually  
> deleting and recreating the Sequence Objects before any data is loaded  
> into the database.

I found similar issues with the OracleEnhanced driver. I fixed things  
up like this:

module ActiveRecord  
module ConnectionAdapters  
class OracleEnhancedAdapter  
def create\_table(name, options = {}) #:nodoc:  
super(name, options)  
seq\_name = options[:sequence\_name] || “#{name}\_seq”  
execute “CREATE SEQUENCE #{seq\_name} START WITH 1 INCREMENT BY  
1 NOCACHE ORDER NOCYCLE” unless options[:id] == false  
end  
end  
module SchemaStatements  
def add\_index(table\_name, column\_name, options = {})  
column\_names = Array(column\_name)  
index\_name = index\_name(table\_name, :column =\> column\_names)  
if Hash === options # legacy support, since this param was a  
string  
# add support for Oracle bitmap indexes  
index\_type = options[:unique] ? “UNIQUE” : options[:bitmap]  
? “BITMAP” : “”  
index\_name = options[:name] || index\_name  
else  
index\_type = options  
end  
quoted\_column\_names = column\_names.map { |e|  
quote\_column\_name(e) }.join(", ")  
execute “CREATE #{index\_type} INDEX  
#{quote\_column\_name(index\_name)} ON #{quote\_table\_name(table\_name)}  
(#{quoted\_column\_names})”  
end  
end  
end  
end

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