Forum: Ruby on Rails Insert a data in Oracle with Rails

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.
A6be7720d668f4f02160b600e67337e2?d=identicon&s=25 Ivan Medda (Guest)
on 2006-03-02 11:27
Hi,
I tried many things to insert a data in an Oracle Table, but the Rails
compiler never Works!

I create this Oracle table:

 CREATE TABLE "FOO" (
	"id"     	int NOT NULL primary key,
	"acolumn"	VARCHAR(10) NULL
	)

and when i tried to insert a new row the Rails compiler tell me :

OCIError: ORA-00904: invalid column name: INSERT INTO AGO.FOO (acolumn,
id) VALUES('pippolo', :id)

While with MySQL I've no problem using the same table!.

I tell to Oracle also :

CREATE SEQUENCE FOO_SEQ INCREMENT BY 1 START WITH 100

or :

CREATE SEQUENCE FOO_sequence
  START WITH 1
  MAXVALUE 9999
  MINVALUE 1
  NOCYCLE
  CACHE 200
  ORDER

But It doesn't Works!.
Where is the problem??? The column named 'id' is necessary with
oracle?And it must be "Auto_Increment".
E75cda3e915fa209386fae3de962cb6a?d=identicon&s=25 Michael Schoen (Guest)
on 2006-03-03 04:34
(Received via mailing list)
Ivan Medda wrote:
> OCIError: ORA-00904: invalid column name: INSERT INTO AGO.FOO (acolumn,
> id) VALUES('pippolo', :id)

> CREATE SEQUENCE FOO_SEQ INCREMENT BY 1 START WITH 100

> But It doesn't Works!.
> Where is the problem??? The column named 'id' is necessary with
> oracle?And it must be "Auto_Increment".

You can name the primary key column whatever you want, but the default
in Rails (not Oracle specifically) is "id". And as there's no
"auto-increment" in Oracle, the approach used is a sequence. By default,
that sequence is expected to be named "#{table_name}_seq".

I suspect the problem you're having is either the result of unexpected
pluralization (not sure what the plural of "foo" is), or the result of
referencing the table "foo" in the schema "AGO".

Are you logging into Oracle as the user "AGO"? Where was the sequence
created?
This topic is locked and can not be replied to.