Forum: Ruby on Rails Oracle auto_increment ??? & 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 19:34
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?
A831c1839cf298073c05e1f2826f0090?d=identicon&s=25 Mark Panay (Guest)
on 2006-03-01 23:15
(Received via mailing list)
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 Medda <avemedda@tin.it> wrote:
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Mark Panay

www.markpanay.com
Jargon Free Web Development
18166b7b6d974f297d806ef0b206ea10?d=identicon&s=25 Mark Willson (mwillson)
on 2006-03-02 00:25
Ivan Medda 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
This topic is locked and can not be replied to.