views:

18

answers:

2
ruby 1.9.2 
rails 3.0.0 
ruby-oci 2.0.4
activerecord-oracle_enhanced-adapter 1.3.1

for example table named users(id:number(38,0), name)

user = User.new
user.name ='test'
user.save! # is successful
user.id # got nil
user.name # got 'test'

and in the database I have sequence named "USERS_SEQ" and worked well(nextval or currentval is right)

What's the problem?

A: 

You'll have to explicitly assign the users_seq.nextval to user.id. This is not done automatically like in SQL Server. The is no such thing as a auto increment column in Oracle.

Robert Merkwürdigeliebe
no,in rails,actually it auto.
qichunren
It will auto execute users_seq.nextval and generate right insert sql
qichunren
apparently not. Maybe you should give us some more info. Like the class definition. You have to enforce the table name, pk and sequence in the model's definition
Robert Merkwürdigeliebe
A: 

Maybe your table does not have primary key constraint and therefore primary key column is not identified by oracle_enhanced adapter?

See discussion at http://groups.google.com/group/oracle-enhanced/browse_thread/thread/3cf18b86333752c5

Raimonds Simanovskis