[ruby-oci8-devel] rowid?

KUBO Takehiro kubo at jiubao.org
Thu Jan 17 08:53:21 EST 2008


Hi,

Here is a mailing list for who develop ruby-oci8 itself, not for who
use ruby-oci8 to develop other applications.

On Jan 17, 2008 5:10 AM, Amos <a.goo0h at gmail.com> wrote:
> It's gross, but this will work for now....
>
> cur.exec
> while r = cur.fetch()
>   p r
>   rowid = r[0].inspect().sub(/#<OCIRowid:/,'').sub(/>/,'')
    rowid = r[0].to_s
>   puts rowid
> end
> cur.close

But, I guess, you are using svn trunk, which will be ruby-oci8 2.0.
Don't use it for real applications yet.

The following code works on 1.0.
  cursor = conn.parse('select rowid, t.* from dual t')
  cursor.define(1, String, 23) # fetch 1st column as a String.
  cursor.exec
  while row = cursor.fetch
    puts row[0]
  end

As for OCI8::Cursor#rowid, it is available to get rowids of
inserted rows.
   cursor = conn.parse('insert into foo values (1, 2)')
   cursor.exec
   rowid = cursor.rowid # inserted row's rowid.


More information about the ruby-oci8-devel mailing list