[ruby-oci8-commit] [233] trunk/ruby-oci8: * lib/oci8/metadata.rb, lib/oci8/oci8.rb: support cursors in a
nobody at rubyforge.org
nobody at rubyforge.org
Sat Dec 29 08:38:23 EST 2007
Revision: 233
Author: kubo
Date: 2007-12-29 08:38:23 -0500 (Sat, 29 Dec 2007)
Log Message:
-----------
* lib/oci8/metadata.rb, lib/oci8/oci8.rb: support cursors in a
result set. For example:
SELECT column1 A, column2 B, CURSOR(SELECT * FROM table2) C
FROM table1
(port from changes in 1.0.0, which is contributed by Randy Gordon)
* test/test_oci8.rb: add a testcase for cursors in a result set.
Modified Paths:
--------------
trunk/ruby-oci8/ChangeLog
trunk/ruby-oci8/lib/oci8/metadata.rb
trunk/ruby-oci8/lib/oci8/oci8.rb
trunk/ruby-oci8/test/test_oci8.rb
Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog 2007-12-29 13:32:18 UTC (rev 232)
+++ trunk/ruby-oci8/ChangeLog 2007-12-29 13:38:23 UTC (rev 233)
@@ -1,3 +1,11 @@
+2007-12-29 KUBO Takehiro <kubo at jiubao.org>
+ * lib/oci8/metadata.rb, lib/oci8/oci8.rb: support cursors in a
+ result set. For example:
+ SELECT column1 A, column2 B, CURSOR(SELECT * FROM table2) C
+ FROM table1
+ (port from changes in 1.0.0, which is contributed by Randy Gordon)
+ * test/test_oci8.rb: add a testcase for cursors in a result set.
+
2007-12-23 KUBO Takehiro <kubo at jiubao.org>
* ext/oci8/oraconf.rb: fix for official x86_64 rpms.
(contributed by Pat.)
Modified: trunk/ruby-oci8/lib/oci8/metadata.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/metadata.rb 2007-12-29 13:32:18 UTC (rev 232)
+++ trunk/ruby-oci8/lib/oci8/metadata.rb 2007-12-29 13:38:23 UTC (rev 233)
@@ -364,6 +364,8 @@
DATA_TYPE_MAP[113] = [:blob, "BLOB"]
# SQLT_BFILE
DATA_TYPE_MAP[114] = [:bfile, "BFILE"]
+ # SQLT_RSET
+ DATA_TYPE_MAP[116] = [:cursor, "CURSOR"]
# SQLT_TIMESTAMP
DATA_TYPE_MAP[187] = [:timestamp,
Proc.new do |p|
Modified: trunk/ruby-oci8/lib/oci8/oci8.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/oci8.rb 2007-12-29 13:32:18 UTC (rev 232)
+++ trunk/ruby-oci8/lib/oci8/oci8.rb 2007-12-29 13:38:23 UTC (rev 233)
@@ -620,5 +620,8 @@
OCI8::BindType::Mapping[:binary_double] = OCI8::BindType::Float
end
+# Cursor
+OCI8::BindType::Mapping[:cursor] = OCI8::BindType::Cursor
+
# XMLType (This mapping will be changed before release.)
OCI8::BindType::Mapping[:xmltype] = OCI8::BindType::Long
Modified: trunk/ruby-oci8/test/test_oci8.rb
===================================================================
--- trunk/ruby-oci8/test/test_oci8.rb 2007-12-29 13:32:18 UTC (rev 232)
+++ trunk/ruby-oci8/test/test_oci8.rb 2007-12-29 13:38:23 UTC (rev 233)
@@ -186,6 +186,46 @@
drop_table('test_table')
end
+ def test_cursor_in_result_set
+ drop_table('test_table')
+ sql = <<-EOS
+CREATE TABLE test_table (N NUMBER(10, 2))
+STORAGE (
+ INITIAL 4k
+ NEXT 4k
+ MINEXTENTS 1
+ MAXEXTENTS UNLIMITED
+ PCTINCREASE 0)
+EOS
+ @conn.exec(sql)
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:1)")
+ 1.upto(10) do |i|
+ cursor.exec(i)
+ end
+ cursor.close
+ cursor = @conn.exec(<<EOS)
+select a.n, cursor (select a.n + b.n
+ from test_table b
+ order by n)
+ from test_table a
+ order by n
+EOS
+ 1.upto(10) do |i|
+ row = cursor.fetch
+ assert_equal(i, row[0])
+ cursor_in_result_set = row[1]
+ 1.upto(10) do |j|
+ row2 = cursor_in_result_set.fetch
+ assert_equal(i + j, row2[0])
+ 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')
+ end
+
if $oracle_version >= 1000
# Oracle 10g or upper
def test_binary_float
More information about the ruby-oci8-commit
mailing list