[ruby-oci8-commit] [235] branches/ruby-oci8-1.0: * ext/oci8/define.c, lib/oci8.rb.in: support cursors in a result

nobody at rubyforge.org nobody at rubyforge.org
Fri Jan 4 05:52:44 EST 2008


Revision: 235
Author:   kubo
Date:     2008-01-04 05:52:44 -0500 (Fri, 04 Jan 2008)

Log Message:
-----------
* ext/oci8/define.c, lib/oci8.rb.in: support cursors in a result
    set without re-defining the define handle.
* test/test_oci8.rb: delete re-defining in a test case for cursors
    in a result set.

Modified Paths:
--------------
    branches/ruby-oci8-1.0/ChangeLog
    branches/ruby-oci8-1.0/ext/oci8/define.c
    branches/ruby-oci8-1.0/lib/oci8.rb.in
    branches/ruby-oci8-1.0/test/test_oci8.rb

Modified: branches/ruby-oci8-1.0/ChangeLog
===================================================================
--- branches/ruby-oci8-1.0/ChangeLog	2008-01-03 15:10:51 UTC (rev 234)
+++ branches/ruby-oci8-1.0/ChangeLog	2008-01-04 10:52:44 UTC (rev 235)
@@ -1,3 +1,9 @@
+2008-01-04  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/define.c, lib/oci8.rb.in: support cursors in a result
+	    set without re-defining the define handle.
+	* test/test_oci8.rb: delete re-defining in a test case for cursors
+	    in a result set.
+
 2007-12-29  KUBO Takehiro  <kubo at jiubao.org>
 	* lib/oci8.rb.in: support cursors in a result set. For example:
 	    SELECT column1 A, column2 B, CURSOR(SELECT * FROM table2) C

Modified: branches/ruby-oci8-1.0/ext/oci8/define.c
===================================================================
--- branches/ruby-oci8-1.0/ext/oci8/define.c	2008-01-03 15:10:51 UTC (rev 234)
+++ branches/ruby-oci8-1.0/ext/oci8/define.c	2008-01-04 10:52:44 UTC (rev 235)
@@ -37,7 +37,17 @@
   return obj;
 }
 
+static VALUE oci8_set_data(VALUE self, VALUE val)
+{
+  oci8_bind_handle_t *hp;
+
+  Data_Get_Struct(self, oci8_bind_handle_t, hp);
+  oci8_set_value(hp, val);
+  return self;
+}
+
 void Init_oci8_define(void)
 {
   rb_define_method(cOCIDefine, "get", oci8_get_data, 0);
+  rb_define_method(cOCIDefine, "set", oci8_set_data, 1);
 }

Modified: branches/ruby-oci8-1.0/lib/oci8.rb.in
===================================================================
--- branches/ruby-oci8-1.0/lib/oci8.rb.in	2008-01-03 15:10:51 UTC (rev 234)
+++ branches/ruby-oci8-1.0/lib/oci8.rb.in	2008-01-04 10:52:44 UTC (rev 235)
@@ -643,12 +643,12 @@
         [OCI8::SQLT_RSET, nil, val]
       end
       def decorate(b)
-        def b.set(val)
-          raise NotImplementedError
-        end
         def b.get()
           (val = super()) && OCI8::Cursor.new(@env, @svc, @ctx, val)
         end
+        def b.pre_fetch_hook()
+          set(@env.alloc(OCIStmt))
+        end
       end
     end
 
@@ -918,6 +918,9 @@
     end # bind_params
 
     def fetch_a_row
+      @defns.each do |d|
+        d.pre_fetch_hook if d.respond_to? :pre_fetch_hook
+      end
       res = do_ocicall(@ctx) { @stmt.fetch() }
       return nil if res.nil?
       res.collect do |r| r.get() end

Modified: branches/ruby-oci8-1.0/test/test_oci8.rb
===================================================================
--- branches/ruby-oci8-1.0/test/test_oci8.rb	2008-01-03 15:10:51 UTC (rev 234)
+++ branches/ruby-oci8-1.0/test/test_oci8.rb	2008-01-04 10:52:44 UTC (rev 235)
@@ -192,7 +192,6 @@
       end
       assert_nil(cursor_in_result_set.fetch) # check end of row data
       cursor_in_result_set.close
-      cursor.define(2, OCI8::Cursor) # bad hack. fix later.
     end
     assert_nil(cursor.fetch) # check end of row data
     drop_table('test_table')




More information about the ruby-oci8-commit mailing list