Oracle auto_increment ? & Rails


#1

To make a new istance of an Oracle table with Rails, i need that this
table had a column named ‘id’. This ‘id’ must be Primary Key &
auto_increment;.
How Can I modify the ‘id’ properties to do it Auto_increment in Oracle?


#2

Hi Ivan,

In Oracle you need to tie a trigger to a sequence, which in turn is
tied to an id field in a table… I use 8i, there may be a better way
in later versions.

I hope this helps (a little)

Mark

On 01/03/06, Ivan M. removed_email_address@domain.invalid wrote:

http://lists.rubyonrails.org/mailman/listinfo/rails


Mark P.

www.markpanay.com
Jargon Free Web D.


#3

Ivan M. wrote:

To make a new istance of an Oracle table with Rails, i need that this
table had a column named ‘id’. This ‘id’ must be Primary Key &
auto_increment;.
How Can I modify the ‘id’ properties to do it Auto_increment in Oracle?

You could try:

create table foo (id integer not null, acolumn varchar(10));
create sequence foo_seq;

Rails will automatically use foo_seq.nextval as the id when inserting
new rows into the foo table.

-mark