# Ruby-oci8-1.0.0 rowid

**URL:** <https://rubytalk.org/t/ruby-oci8-1-0-0-rowid/43785>\
**Category:** ruby-talk\
**Created:** [15 January 2008 15:49 UTC](https://rubytalk.org/t/ruby-oci8-1-0-0-rowid/43785 "2008-01-15T15:49:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amos](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@Amos](https://rubytalk.org/u/Amos)\
**Post date:** [15 January 2008 15:49 UTC](https://rubytalk.org/t/ruby-oci8-1-0-0-rowid/43785/1 "2008-01-15T15:49:58Z")

</div>

I noticed this apparently unanswered thread:

[http://groups.google.com/group/comp.lang.ruby/browse\_frm/thread/2ae6af9717678d39/cf37b223d5f7231f](http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/2ae6af9717678d39/cf37b223d5f7231f)

It would seem that this is still a problem? I'm trying to port some  
old code from oracle-0.2.11 to ruby-oci8-1.0.0 and for the most part  
it is working. However, I can't seem to figure out how to access the  
rowid from oci8. I've got a simple query that I set up with the parse  
method, then do:

&nbsp;&nbsp;cur.exec  
&nbsp;&nbsp;while r = cur.fetch()  
&nbsp;&nbsp;&nbsp;&nbsp;p r  
&nbsp;&nbsp;&nbsp;&nbsp;p cur.rowid()  
&nbsp;&nbsp;end  
&nbsp;&nbsp;cur.close

But unfortunately get:

attr.c:261:in [oci8lib.so](http://oci8lib.so): No Data (OCINoData)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/ruby/oci8/oci8.rb:817:in `rowid'

Anyway around this? I need to use the newer Oracle library because I  
need to use a "//server:port/dataset" connection string that the older  
library doesn't seem to support.

I guess I may have to bail on using Ruby and convert it over to Java  
like what the reset of the group is doing.

Amos

---

<div class="post-metadata">

**Author:** ![Amos](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@Amos](https://rubytalk.org/u/Amos)\
**Post date:** [17 January 2008 15:32 UTC](https://rubytalk.org/t/ruby-oci8-1-0-0-rowid/43785/2 "2008-01-17T15:32:32Z")

</div>

It was pointed out to me that this works for ruby-oci8-1.0.0:

&nbsp;&nbsp;cursor = conn.parse('select rowid, t.\* from dual t')  
&nbsp;&nbsp;cursor.define(1, String, 23) # fetch 1st column as a String.  
&nbsp;&nbsp;cursor.exec  
&nbsp;&nbsp;while row = cursor.fetch  
&nbsp;&nbsp;&nbsp;&nbsp;puts row[0]  
&nbsp;&nbsp;end

As for OCI8::Cursor#rowid, it is available to get rowids of inserted  
rows.

&nbsp;&nbsp;cursor = conn.parse('insert into foo values (1, 2)')  
&nbsp;&nbsp;cursor.exec  
&nbsp;&nbsp;rowid = cursor.rowid # inserted row's rowid.

Amos

> **···**
>
> On Jan 15, 9:46 am, Amos \<a.go...@gmail.com\> wrote:
> 
> > I noticed this apparently unanswered thread:
> > 
> > [http://groups.google.com/group/comp.lang.ruby/browse\_frm/thread/2ae6af9717678d39/cf37b223d5f7231f](http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/2ae6af9717678d39/cf37b223d5f7231f)
> 
> > It would seem that this is still a problem? I'm trying to port some  
> > old code from oracle-0.2.11 to ruby-oci8-1.0.0 and for the most part  
> > it is working. However, I can't seem to figure out how to access the  
> > rowid from oci8.
