Forum: Ruby on Rails Oracle Sequence & 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.
Ivan M. (Guest)
on 2006-03-01 17:12
the compiler tell me it:

invalid column name: INSERT INTO ago.prova_stats (cognome, nome, id,
telefono) VALUES('Medda', 'Ivan', :id, 70565611)

where ago.prova_stats is the table used by me and that have only the
columns 'cognome','nome' and 'telefono'.
My table hasn't the column 'id'(???).Why Rails search it?
Ivan.
Mathieu C. (Guest)
on 2006-03-01 18:16
(Received via mailing list)
>
> invalid column name: INSERT INTO ago.prova_stats (cognome, nome, id,
> telefono) VALUES('Medda', 'Ivan', :id, 70565611)
>
> where ago.prova_stats is the table used by me and that have only the
> columns 'cognome','nome' and 'telefono'.
> My table hasn't the column 'id'(???).Why Rails search it?

You have to enforce the table name, pk and sequence in the model's
definition

class MyTable < ActiveRecord::Base
  set_table_name "legacy_table"
  set_primary_key "legacy_id"
  set_sequence_name "legacy_sequence"
end
Ivan M. (Guest)
on 2006-03-01 18:33
how can i enforge the sequence in the model definition?
I used it,where ago.prova_stats is my table name.

class Nanto < ActiveRecord::Base
set_table_name "ago.prova_stats"
set_primary_key "ago.prova_stats_id"
set_sequence_name "ago.prova_stats_sequence"

but the compiler tell me :
sequence does not exist: select ago.prova_stats_sequence.nextval id from
dual
 Ivan.


Mathieu C. wrote:
>>
>> invalid column name: INSERT INTO ago.prova_stats (cognome, nome, id,
>> telefono) VALUES('Medda', 'Ivan', :id, 70565611)
>>
>> where ago.prova_stats is the table used by me and that have only the
>> columns 'cognome','nome' and 'telefono'.
>> My table hasn't the column 'id'(???).Why Rails search it?
>
> You have to enforce the table name, pk and sequence in the model's
> definition
>
> class MyTable < ActiveRecord::Base
>   set_table_name "legacy_table"
>   set_primary_key "legacy_id"
>   set_sequence_name "legacy_sequence"
> end
Mathieu C. (Guest)
on 2006-03-01 18:46
(Received via mailing list)
> but the compiler tell me :
> sequence does not exist: select ago.prova_stats_sequence.nextval id from
> dual

Sequence must exists in your Oracle database schema.

CREATE SEQUENCE ago.prova_stats_sequence
  START WITH 1
  MAXVALUE 999999999999999999999999999
  MINVALUE 1
  NOCYCLE
  CACHE 200
  ORDER;
Ivan M. (Guest)
on 2006-03-01 18:59
Excuse me, but the table ago.prova_stats must have a column named 'id'?


Mathieu C. wrote:
>> but the compiler tell me :
>> sequence does not exist: select ago.prova_stats_sequence.nextval id from
>> dual
>
> Sequence must exists in your Oracle database schema.
>
> CREATE SEQUENCE ago.prova_stats_sequence
>   START WITH 1
>   MAXVALUE 999999999999999999999999999
>   MINVALUE 1
>   NOCYCLE
>   CACHE 200
>   ORDER;
Aly Dharshi (Guest)
on 2006-03-01 22:45
(Received via mailing list)
Yeah I think its a rails thing, it needs that column.

Ivan M. wrote:
>>   START WITH 1
>>   MAXVALUE 999999999999999999999999999
>>   MINVALUE 1
>>   NOCYCLE
>>   CACHE 200
>>   ORDER;
>
>

--
Aly S.P Dharshi
removed_email_address@domain.invalid

	 "A good speech is like a good dress
	  that's short enough to be interesting
	  and long enough to cover the subject"
Ivan M. (Guest)
on 2006-03-02 10:42
OK! Thank u.


Aly Dharshi wrote:
> Yeah I think its a rails thing, it needs that column.
>
> Ivan M. wrote:
>>>   START WITH 1
>>>   MAXVALUE 999999999999999999999999999
>>>   MINVALUE 1
>>>   NOCYCLE
>>>   CACHE 200
>>>   ORDER;
>>
>>
>
> --
> Aly S.P Dharshi
> removed_email_address@domain.invalid
>
> 	 "A good speech is like a good dress
> 	  that's short enough to be interesting
> 	  and long enough to cover the subject"
Michael Schoen (Guest)
on 2006-03-03 05:40
(Received via mailing list)
Ivan M. wrote:
> the compiler tell me it:
>
> invalid column name: INSERT INTO ago.prova_stats (cognome, nome, id,
> telefono) VALUES('Medda', 'Ivan', :id, 70565611)
>
> where ago.prova_stats is the table used by me and that have only the
> columns 'cognome','nome' and 'telefono'.
> My table hasn't the column 'id'(???).Why Rails search it?
> Ivan.

Rails presumes that every table has a numeric incrementing primary key.
For dbs like mysql, this is autoincrementing, for Oracle it uses a
sequence.
This topic is locked and can not be replied to.