# Insert into an Oracle table no working

**URL:** <https://www.ruby-forum.com/t/insert-into-an-oracle-table-no-working/105024>\
**Category:** Rails\
**Created:** [May 25, 2007, 1:33am UTC](https://www.ruby-forum.com/t/insert-into-an-oracle-table-no-working/105024 "2007-05-25T01:33:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![david\_salisbury](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@david\_salisbury](https://www.ruby-forum.com/u/david_salisbury)\
**Post date:** [May 25, 2007, 1:33am UTC](https://www.ruby-forum.com/t/insert-into-an-oracle-table-no-working/105024/1 "2007-05-25T01:33:38Z")

</div>

Beginner here, so this should be easy.

I created an RoR application that worked against and sqlite3 table. But  
the next step was for it to work against an Oracle table.

So, I’ve changed the database.yml file to look at Oracle, and I’ve  
created the same table on Oracle as was on sqlite3. My table is called  
list\_items

desc list\_items  
Name Null? Type

* * *

* * *

ID NOT NULL NUMBER  
NAME VARCHAR2(1000)  
COST NUMBER(38,5)  
QUANTITY NUMBER

and I have created the sequence

create sequence list\_item\_seq;

But I’m getting the error - ORA-02289: sequence does not exist. I’ve  
tried other similar names to no avail.

We do have the primary key plug in installed, so I add to the empty  
model the line

set\_primary\_keys :id

I then get a different error

cannot insert NULL into (“GLOBE”.“LIST\_ITEMS”.“ID”): INSERT INTO  
list\_items (name, cost, quantity, id) VALUES (‘fred’‘s pizza’, 10.0,  
10.0, NULL)

Any clues as to where/what to look at? Shouldn’t it “just work”?

Thanx for any help

-Dave

---

<div class="post-metadata">

**Author:** ![david\_salisbury](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@david\_salisbury](https://www.ruby-forum.com/u/david_salisbury)\
**Post date:** [May 25, 2007, 2:53am UTC](https://www.ruby-forum.com/t/insert-into-an-oracle-table-no-working/105024/2 "2007-05-25T02:53:45Z")

</div>

I ran into a similar problem. I created a new ROR app that had to  
work with an existing legacy database (Oracle). The db has a members  
table. The primary key was already named ‘mem\_id’.

So, in my model I have:  
set\_table\_name “members”  
set\_primary\_key “mem\_id”

set\_sequence\_name “mem\_id\_seq”

It works after I added set\_sequence\_name. I got the same Oracle  
‘sequence does not exist error’ before I added that.

good luck.  
-emil

On May 24, 4:33 pm, david salisbury [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![david\_salisbury](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ac8455/32.png) [@david\_salisbury](https://www.ruby-forum.com/u/david_salisbury)\
**Post date:** [May 29, 2007, 9:38pm UTC](https://www.ruby-forum.com/t/insert-into-an-oracle-table-no-working/105024/3 "2007-05-29T21:38:48Z")

</div>

Thank you very much! That was it!

-Dave

EmilSF wrote:

> I ran into a similar problem. I created a new ROR app that had to  
> work with an existing legacy database (Oracle). The db has a members  
> table. The primary key was already named ‘mem\_id’.
> 
> So, in my model I have:  
> set\_table\_name “members”  
> set\_primary\_key “mem\_id”
> 
> set\_sequence\_name “mem\_id\_seq”
> 
> It works after I added set\_sequence\_name. I got the same Oracle  
> ‘sequence does not exist error’ before I added that.
> 
> good luck.  
> -emil
> 
> On May 24, 4:33 pm, david salisbury [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
