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.
A6be7720d668f4f02160b600e67337e2?d=identicon&s=25 Ivan Medda (Guest)
on 2006-03-01 16: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.
F16def8015a7562a285c65a14be48540?d=identicon&s=25 Mathieu Chappuis (Guest)
on 2006-03-01 17: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
A6be7720d668f4f02160b600e67337e2?d=identicon&s=25 Ivan Medda (Guest)
on 2006-03-01 17: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 Chappuis 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
F16def8015a7562a285c65a14be48540?d=identicon&s=25 Mathieu Chappuis (Guest)
on 2006-03-01 17: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;
A6be7720d668f4f02160b600e67337e2?d=identicon&s=25 Ivan Medda (Guest)
on 2006-03-01 17:59
Excuse me, but the table ago.prova_stats must have a column named 'id'?


Mathieu Chappuis 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;
Fbfcee91e5f674c612061c229589ab46?d=identicon&s=25 Aly Dharshi (Guest)
on 2006-03-01 21:45
(Received via mailing list)
Yeah I think its a rails thing, it needs that column.

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

--
Aly S.P Dharshi
aly.dharshi@telus.net

	 "A good speech is like a good dress
	  that's short enough to be interesting
	  and long enough to cover the subject"
A6be7720d668f4f02160b600e67337e2?d=identicon&s=25 Ivan Medda (Guest)
on 2006-03-02 09:42
OK! Thank u.


Aly Dharshi wrote:
> Yeah I think its a rails thing, it needs that column.
>
> Ivan Medda wrote:
>>>   START WITH 1
>>>   MAXVALUE 999999999999999999999999999
>>>   MINVALUE 1
>>>   NOCYCLE
>>>   CACHE 200
>>>   ORDER;
>>
>>
>
> --
> Aly S.P Dharshi
> aly.dharshi@telus.net
>
> 	 "A good speech is like a good dress
> 	  that's short enough to be interesting
> 	  and long enough to cover the subject"
E75cda3e915fa209386fae3de962cb6a?d=identicon&s=25 Michael Schoen (Guest)
on 2006-03-03 04:40
(Received via mailing list)
Ivan Medda 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.