Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用 oci8 和 ruby 从 oracle 中的序列中选择下一个 id。这样做的简单方法是什么?错误代码示例:
id = @conn.exec( 'Select NEXT_ID.NEXTVAL from dual' )
.exec 返回一个游标。有没有一种简单的方法可以从 exec 或类似方法中获取我需要的一个值?
@conn.exec('Select NEXT_ID.NEXTVAL from dual') {|row| id = row[0]}
你也可以做
id = @conn.exec('Select NEXT_ID.NEXTVAL from dual').fetch[0]