Forum: Ruby on Rails Insert into an Oracle table no working

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
david salisbury (Guest)
on 2007-05-25 03:33
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
EmilSF (Guest)
on 2007-05-25 04:53
(Received via mailing list)
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>
david salisbury (Guest)
on 2007-05-29 23:38
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>
This topic is locked and can not be replied to.