Insert into an Oracle table no working


#1

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


#2

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


#3

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