Oracle Sequence & Rails

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.

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

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

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;

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;

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
[email protected]

“A good speech is like a good dress
that’s short enough to be interesting
and long enough to cover the subject”

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.

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
[email protected]

 "A good speech is like a good dress
  that's short enough to be interesting
  and long enough to cover the subject"