[ruby-oci8-commit] [571] trunk/ruby-oci8: Support package type description.

nobody at rubyforge.org nobody at rubyforge.org
Mon Jul 22 12:52:53 UTC 2013


Revision: 571
Author:   kubo
Date:     2013-07-22 12:52:52 +0000 (Mon, 22 Jul 2013)
Log Message:
-----------
Support package type description. It is a new feature of Oracle 12c.

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/oci8lib.c
    trunk/ruby-oci8/lib/oci8/metadata.rb
    trunk/ruby-oci8/lib/oci8.rb.in
    trunk/ruby-oci8/test/test_all.rb

Added Paths:
-----------
    trunk/ruby-oci8/test/setup_test_package.sql
    trunk/ruby-oci8/test/test_package_type.rb

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2013-07-15 05:39:30 UTC (rev 570)
+++ trunk/ruby-oci8/ChangeLog	2013-07-22 12:52:52 UTC (rev 571)
@@ -1,3 +1,12 @@
+2013-07-22  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/oci8lib.c, lib/oci8.rb.in, lib/oci8/metadata.rb: Support
+	    package type description. It is a new feature of Oracle 12c.
+	* test/setup_test_package.sql, test/test_all.rb,
+	  test/test_package_type.rb: Add tests for package type description.
+
+2013-07-15  KUBO Takehiro  <kubo at jiubao.org>
+	* test/*.rb: Use MiniTest instead of Test::Unit.
+
 2013-06-23  KUBO Takehiro  <kubo at jiubao.org>
 	* lib/oci8/cursor.rb, lib/oci8/object.rb: fix to bind object types by
 	    name as OCI8::Cursor#bind_param(pos, val, :named_type, typename).

Modified: trunk/ruby-oci8/ext/oci8/oci8lib.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8lib.c	2013-07-15 05:39:30 UTC (rev 570)
+++ trunk/ruby-oci8/ext/oci8/oci8lib.c	2013-07-22 12:52:52 UTC (rev 571)
@@ -508,16 +508,19 @@
             "libclntsh.a(shr.o)",
 #elif defined(__hppa)
             /* HP-UX(PA-RISC) */
+            "libclntsh.sl.12.1",
             "libclntsh.sl.11.1",
             "libclntsh.sl.10.1",
             "libclntsh.sl.9.0",
             "libclntsh.sl.8.0",
 #elif defined(__APPLE__)
             /* Mac OS X */
+            "libclntsh.dylib.12.1",
             "libclntsh.dylib.11.1",
             "libclntsh.dylib.10.1",
 #else
             /* Linux, Solaris and HP-UX(IA64) */
+            "libclntsh.so.12.1",
             "libclntsh.so.11.1",
             "libclntsh.so.10.1",
             "libclntsh.so.9.0",

Modified: trunk/ruby-oci8/lib/oci8/metadata.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/metadata.rb	2013-07-15 05:39:30 UTC (rev 570)
+++ trunk/ruby-oci8/lib/oci8/metadata.rb	2013-07-22 12:52:52 UTC (rev 571)
@@ -248,6 +248,12 @@
                                 "TIMESTAMP(#{fsprecision}) WITH LOCAL TIME ZONE"
                               end
                             end]
+      DATA_TYPE_MAP[245] = [:record,
+                            Proc.new do |p|
+                              "#{p.schema_name}.#{p.type_name}"
+                            end]
+      DATA_TYPE_MAP[252] = [:boolean, "BOOLEAN"]
+      DATA_TYPE_MAP[266] = [:pls_integer, "PLS_INTEGER"]
 
       def __data_type # :nodoc:
         return @data_type if defined? @data_type
@@ -337,6 +343,9 @@
         #when 228; :sysfirst   # OCI_TYPECODE_SYSFIRST
         #when 235; :syslast    # OCI_TYPECODE_SYSLAST
         when 266; :pls_integer # OCI_TYPECODE_PLS_INTEGER
+        when 250; :record      # OCI_TYPECODE_RECORD
+        when 251; :itable      # OCI_TYPECODE_ITABLE
+        when 252; :boolean     # OCI_TYPECODE_BOOLEAN
         end
       end
     end
@@ -632,6 +641,12 @@
       end
       private :list_subprograms
 
+      # package type list
+      def list_types # :nodoc:
+        __param(137) # OCI_ATTR_LIST_PKG_TYPES
+      end
+      private :list_types
+
       # Returns +true+ if the package subprograms have
       # {invoker's rights}[http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/subprograms.htm#i18574].
       # Otherwise, +false+.
@@ -647,6 +662,22 @@
           prog.instance_variable_set(:@is_standalone, false)
         end
       end
+
+      if OCI8.oracle_client_version < ORAVER_12_1
+        def types
+          raise "This version of the Oracle client does not support PL/SQL package type descriptions."
+        end
+      else
+        # Returns an array of types defined within the Package.
+        #
+        # @return [array of OCI8::Metadata::Type]
+        # @since 2.1.6
+        def types
+          @types ||= list_types.to_a.each do |type|
+            type.instance_variable_set(:@is_standalone, false)
+          end
+        end
+      end
     end
 
     # Information about types
@@ -1648,8 +1679,9 @@
         #when OCI_LTYPE_TABLE_ALIAS;   offset = ?
         #when OCI_LTYPE_VARIABLE_TYPE; offset = ?
         #when OCI_LTYPE_NAME_VALUE;    offset = ?
+        when 15; offset = 0 # OCI_LTYPE_PACKAGE_TYPE
         else
-          raise NotImplementedError, "unsupported list type #{list.ltype}"
+          raise NotImplementedError, "unsupported list type #{ltype}"
         end
         ary = []
         0.upto(num_params - 1) do |i|

Modified: trunk/ruby-oci8/lib/oci8.rb.in
===================================================================
--- trunk/ruby-oci8/lib/oci8.rb.in	2013-07-15 05:39:30 UTC (rev 570)
+++ trunk/ruby-oci8/lib/oci8.rb.in	2013-07-22 12:52:52 UTC (rev 571)
@@ -104,6 +104,8 @@
   ORAVER_10_2 = OCI8::OracleVersion.new(10, 2)
   # @private
   ORAVER_11_1 = OCI8::OracleVersion.new(11, 1)
+  # @private
+  ORAVER_12_1 = OCI8::OracleVersion.new(12, 1)
 
   # @private
   @@oracle_client_version = OCI8::OracleVersion.new(self.oracle_client_vernum)

Added: trunk/ruby-oci8/test/setup_test_package.sql
===================================================================
--- trunk/ruby-oci8/test/setup_test_package.sql	                        (rev 0)
+++ trunk/ruby-oci8/test/setup_test_package.sql	2013-07-22 12:52:52 UTC (rev 571)
@@ -0,0 +1,59 @@
+create or replace package rb_test_pkg is
+  package_version pls_integer := 1;
+
+  type array_of_integer is array(50) of integer;
+  type table_of_pls_integer is table of pls_integer;
+  type table_of_boolean is table of boolean;
+  type indexed_table_of_varchar2 is table of varchar2(10) index by varchar2(5);
+  type rec1 is record (i pls_integer, j integer);
+  type rec2 is record (b boolean, it indexed_table_of_varchar2, rec rec1);
+  type table_of_rec1 is table of rec1;
+  type table_of_rec2 is table of rec2;
+
+  function sum_table_of_pls_integer(tbl in table_of_pls_integer) return pls_integer;
+  function add_rec1_values(tbl in table_of_rec1) return pls_integer;
+  procedure out_rec1_values(tbl out table_of_rec1);
+end;
+/
+create or replace package body rb_test_pkg is
+  function sum_table_of_pls_integer(tbl in table_of_pls_integer) return pls_integer is
+    i pls_integer;
+    ret pls_integer := 0;
+  begin
+    for i in tbl.first..tbl.last loop
+      ret := ret + tbl(i);
+    end loop;
+    return ret;
+  end;
+
+  function add_rec1_values(tbl in table_of_rec1) return pls_integer is
+    i pls_integer;
+    ret pls_integer := 0;
+  begin
+    for i in tbl.first..tbl.last loop
+      ret := ret + nvl(tbl(i).i, 0) + nvl(tbl(i).j, 0);
+    end loop;
+    return ret;
+  end;
+
+  procedure out_rec1_values(tbl out table_of_rec1) is
+    i pls_integer;
+    rec1val rec1;
+  begin
+    tbl := table_of_rec1();
+    for i in 1..20 loop
+      tbl.extend;
+      if i mod 6 != 0 then
+        if i mod 3 != 0 then
+          rec1val.i := i;
+          rec1val.j := i;
+        else
+          rec1val.i := null;
+          rec1val.j := null;
+        end if;
+        tbl(i) := rec1val;
+      end if;
+    end loop;
+  end;
+end;
+/


Property changes on: trunk/ruby-oci8/test/setup_test_package.sql
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/ruby-oci8/test/test_all.rb
===================================================================
--- trunk/ruby-oci8/test/test_all.rb	2013-07-15 05:39:30 UTC (rev 570)
+++ trunk/ruby-oci8/test/test_all.rb	2013-07-22 12:52:52 UTC (rev 571)
@@ -29,6 +29,10 @@
   require "#{srcdir}/test_encoding"
 end
 
+if $oracle_version >= OCI8::ORAVER_12_1
+  require "#{srcdir}/test_package_type"
+end
+
 # Ruby/DBI
 begin
   require 'dbi'

Added: trunk/ruby-oci8/test/test_package_type.rb
===================================================================
--- trunk/ruby-oci8/test/test_package_type.rb	                        (rev 0)
+++ trunk/ruby-oci8/test/test_package_type.rb	2013-07-22 12:52:52 UTC (rev 571)
@@ -0,0 +1,880 @@
+require 'oci8'
+require File.dirname(__FILE__) + '/config'
+
+if $oracle_version < OCI8::ORAVER_12_1
+  raise "Package types are not supported in this Oracle version."
+end
+
+conn = OCI8.new($dbuser, $dbpass, $dbname)
+test_package_version = nil
+begin
+  cursor = conn.parse('begin :1 := rb_test_pkg.package_version; end;')
+  cursor.bind_param(1, nil, Integer)
+  cursor.exec
+  test_package_version = cursor[1]
+  cursor.close
+rescue OCIError
+  raise if $!.code != 6550
+end
+raise <<EOS if test_package_version != 1
+You need to execute SQL statements in #{File.dirname(__FILE__)}/setup_test_package.sql as follows:
+
+  $ sqlplus USERNAME/PASSWORD
+  SQL> @test/setup_test_package.sql
+
+EOS
+
+class TestPackageType < MiniTest::Unit::TestCase
+  def setup
+    @conn = get_oci8_connection
+  end
+
+  def teardown
+    @conn.logoff
+  end
+
+  def check_attributes(msg, obj, attrs)
+    attrs.each do |method, expected_value|
+      val = method.is_a?(Array) ? obj[method[0]] : obj.send(method)
+      if expected_value.is_a? Hash
+        check_attributes("#{msg} > #{method}", val, expected_value)
+      else
+        assert_equal(expected_value, val, "#{msg} > #{method}")
+      end
+    end
+  end
+
+  def test_describe_package
+    integer_type_attrs = {
+      :class => OCI8::Metadata::Type,
+      #:typecode => nil,
+      #:collection_typecode => nil,
+      :is_incomplete_type? => false,
+      :is_system_type? => true,
+      :is_predefined_type? => true,
+      :is_transient_type? => false,
+      :is_system_generated_type? => false,
+      :has_nested_table? => false,
+      :has_lob? => false,
+      :has_file? => false,
+      #:collection_element => nil,
+      :num_type_attrs => 0,
+      :num_type_methods => 0,
+      #:map_method => nil,
+      #:order_method => nil,
+      :is_invoker_rights? => false,
+      :name => 'INTEGER',
+      :schema_name => 'SYS',
+      :is_final_type? => true,
+      :is_instantiable_type? => true,
+      :is_subtype? => false,
+      :type_attrs => [],
+      #:type_methods => [],
+    }
+
+    pls_integer_type_attrs = {
+      :class => OCI8::Metadata::Type,
+      #:typecode => nil,
+      #:collection_typecode => nil,
+      :is_incomplete_type? => false,
+      :is_system_type? => true,
+      :is_predefined_type? => true,
+      :is_transient_type? => false,
+      :is_system_generated_type? => false,
+      :has_nested_table? => false,
+      :has_lob? => false,
+      :has_file? => false,
+      #:collection_element => nil,
+      :num_type_attrs => 0,
+      :num_type_methods => 0,
+      #:map_method => nil,
+      #:order_method => nil,
+      :is_invoker_rights? => false,
+      :name => 'PL/SQL PLS INTEGER',
+      :schema_name => 'SYS',
+      :is_final_type? => true,
+      :is_instantiable_type? => true,
+      :is_subtype? => false,
+      :type_attrs => [],
+      #:type_methods => [],
+    }
+
+    boolean_type_attrs = {
+      :class => OCI8::Metadata::Type,
+      #:typecode => nil,
+      #:collection_typecode => nil,
+      :is_incomplete_type? => false,
+      :is_system_type? => true,
+      :is_predefined_type? => true,
+      :is_transient_type? => false,
+      :is_system_generated_type? => false,
+      :has_nested_table? => false,
+      :has_lob? => false,
+      :has_file? => false,
+      #:collection_element => nil,
+      :num_type_attrs => 0,
+      :num_type_methods => 0,
+      #:map_method => nil,
+      #:order_method => nil,
+      :is_invoker_rights? => false,
+      :name => 'PL/SQL BOOLEAN',
+      :schema_name => 'SYS',
+      :is_final_type? => true,
+      :is_instantiable_type? => true,
+      :is_subtype? => false,
+      :type_attrs => [],
+      #:type_methods => [],
+    }
+
+    varchar2_type_attrs = {
+      :class => OCI8::Metadata::Type,
+      #:typecode => nil,
+      #:collection_typecode => nil,
+      :is_incomplete_type? => false,
+      :is_system_type? => true,
+      :is_predefined_type? => true,
+      :is_transient_type? => false,
+      :is_system_generated_type? => false,
+      :has_nested_table? => false,
+      :has_lob? => false,
+      :has_file? => false,
+      #:collection_element => nil,
+      :num_type_attrs => 0,
+      :num_type_methods => 0,
+      #:map_method => nil,
+      #:order_method => nil,
+      :is_invoker_rights? => false,
+      :name => 'VARCHAR2',
+      :schema_name => 'SYS',
+      :is_final_type? => true,
+      :is_instantiable_type? => true,
+      :is_subtype? => false,
+      :type_attrs => [],
+      #:type_methods => #[],
+    }
+
+    array_of_integer_type_attrs = {
+      :class => OCI8::Metadata::Type,
+      :typecode => :named_collection,
+      :collection_typecode => :varray,
+      :is_incomplete_type? => false,
+      :is_system_type? => false,
+      :is_predefined_type? => false,
+      :is_transient_type? => false,
+      :is_system_generated_type? => false,
+      :has_nested_table? => false,
+      :has_lob? => false,
+      :has_file? => false,
+      :collection_element => {
+        :class => OCI8::Metadata::Collection,
+        :data_size => 22,
+        :typecode => :integer,
+        :data_type => :number,
+        :num_elems => 50,
+        :precision => 38,
+        :scale => 0,
+        :type_name => 'INTEGER',
+        :schema_name => 'SYS',
+        :type_metadata => integer_type_attrs,
+      },
+      :num_type_attrs => 0,
+      :num_type_methods => 0,
+      :map_method => nil,
+      :order_method => nil,
+      :is_invoker_rights? => false,
+      :name => 'ARRAY_OF_INTEGER',
+      :schema_name => @conn.username,
+      :is_final_type? => true,
+      :is_instantiable_type? => true,
+      :is_subtype? => false,
+      :type_attrs => [],
+      :type_methods => [],
+    }
+
+    table_of_pls_integer_type_attrs = {
+      :class => OCI8::Metadata::Type,
+      :typecode => :named_collection,
+      :collection_typecode => :table,
+      :is_incomplete_type? => false,
+      :is_system_type? => false,
+      :is_predefined_type? => false,
+      :is_transient_type? => false,
+      :is_system_generated_type? => false,
+      :has_nested_table? => true,
+      :has_lob? => false,
+      :has_file? => false,
+      :collection_element => {
+        :class => OCI8::Metadata::Collection,
+        :data_size => 0,
+        :typecode => :pls_integer,
+        :data_type => :pls_integer,
+        :num_elems => 0,
+        :precision => 0,
+        :scale => 0,
+        :type_name => 'PL/SQL PLS INTEGER',
+        :schema_name => 'SYS',
+        :type_metadata => pls_integer_type_attrs,
+      },
+      :num_type_attrs => 0,
+      :num_type_methods => 0,
+      :map_method => nil,
+      :order_method => nil,
+      :is_invoker_rights? => false,
+      :name => 'TABLE_OF_PLS_INTEGER',
+      :schema_name => @conn.username,
+      :is_final_type? => true,
+      :is_instantiable_type? => true,
+      :is_subtype? => false,
+      :type_attrs => [],
+      :type_methods => [],
+    }
+
+    table_of_boolean_type_attrs = {
+      :class => OCI8::Metadata::Type,
+      :typecode => :named_collection,
+      :collection_typecode => :table,
+      :is_incomplete_type? => false,
+      :is_system_type? => false,
+      :is_predefined_type? => false,
+      :is_transient_type? => false,
+      :is_system_generated_type? => false,
+      :has_nested_table? => true,
+      :has_lob? => false,
+      :has_file? => false,
+      :collection_element => {
+        :class => OCI8::Metadata::Collection,
+        :data_size => 0,
+        :typecode => :boolean,
+        :data_type => :boolean,
+        :num_elems => 0,
+        :precision => 0,
+        :scale => 0,
+        :type_name => 'PL/SQL BOOLEAN',
+        :schema_name => 'SYS',
+        :type_metadata => boolean_type_attrs,
+      },
+      :num_type_attrs => 0,
+      :num_type_methods => 0,
+      :map_method => nil,
+      :order_method => nil,
+      :is_invoker_rights? => false,
+      :name => 'TABLE_OF_BOOLEAN',
+      :schema_name => @conn.username,
+      :is_final_type? => true,
+      :is_instantiable_type? => true,
+      :is_subtype? => false,
+      :type_attrs => [],
+      :type_methods => [],
+    }
+
+    indexed_table_of_varchar2_type_attrs = {
+      :class => OCI8::Metadata::Type,
+      :typecode => :named_collection,
+      :collection_typecode => :itable,
+      :is_incomplete_type? => false,
+      :is_system_type? => false,
+      :is_predefined_type? => false,
+      :is_transient_type? => false,
+      :is_system_generated_type? => false,
+      :has_nested_table? => false,
+      :has_lob? => false,
+      :has_file? => false,
+      :collection_element => {
+        :class => OCI8::Metadata::Collection,
+        :data_size => 10,
+        :typecode => :varchar2,
+        :data_type => :varchar2,
+        :num_elems => 5,
+        :precision => 0,
+        :scale => 0,
+        :type_name => 'VARCHAR2',
+        :schema_name => 'SYS',
+        :type_metadata => varchar2_type_attrs,
+      },
+      :num_type_attrs => 0,
+      :num_type_methods => 0,
+      :map_method => nil,
+      :order_method => nil,
+      :is_invoker_rights? => false,
+      :name => 'INDEXED_TABLE_OF_VARCHAR2',
+      :schema_name => @conn.username,
+      :is_final_type? => true,
+      :is_instantiable_type? => true,
+      :is_subtype? => false,
+      :type_attrs => [],
+      :type_methods => [],
+    }
+
+    rec1_type_attrs = {
+      :class => OCI8::Metadata::Type,
+      :typecode => :record,
+      :collection_typecode => nil,
+      :is_incomplete_type? => false,
+      :is_system_type? => false,
+      :is_predefined_type? => false,
+      :is_transient_type? => false,
+      :is_system_generated_type? => false,
+      :has_nested_table? => false,
+      :has_lob? => false,
+      :has_file? => false,
+      :collection_element => nil,
+      :num_type_attrs => 2,
+      :num_type_methods => 0,
+      :map_method => nil,
+      :order_method => nil,
+      :is_invoker_rights? => false,
+      :name => 'REC1',
+      :schema_name => @conn.username,
+      :is_final_type? => true,
+      :is_instantiable_type? => true,
+      :is_subtype? => false,
+      :type_attrs => {
+        :class => Array,
+        :size => 2,
+        [0] => {
+          :class => OCI8::Metadata::TypeAttr,
+          :data_size => 0,
+          :typecode => :pls_integer,
+          :data_type => :pls_integer,
+          :name => 'I',
+          :precision => 0,
+          :scale => 0,
+          :type_name => 'PL/SQL PLS INTEGER',
+          :schema_name => 'SYS',
+          :fsprecision => 0,
+          :lfprecision => 0,
+          :type_metadata => pls_integer_type_attrs,
+        },
+        [1] => {
+          :class => OCI8::Metadata::TypeAttr,
+          :data_size => 22,
+          :typecode => :integer,
+          :data_type => :number,
+          :name => 'J',
+          :precision => 38,
+          :scale => 0,
+          :type_name => 'INTEGER',
+          :schema_name => 'SYS',
+          :fsprecision => 0,
+          :lfprecision => 0,
+          :type_metadata => integer_type_attrs,
+        },
+      },
+      :type_methods => [],
+    }
+
+    rec2_type_attrs = {
+      :class => OCI8::Metadata::Type,
+      :typecode => :record,
+      :collection_typecode => nil,
+      :is_incomplete_type? => false,
+      :is_system_type? => false,
+      :is_predefined_type? => false,
+      :is_transient_type? => false,
+      :is_system_generated_type? => false,
+      :has_nested_table? => false,
+      :has_lob? => false,
+      :has_file? => false,
+      :collection_element => nil,
+      :num_type_attrs => 3,
+      :num_type_methods => 0,
+      :map_method => nil,
+      :order_method => nil,
+      :is_invoker_rights? => false,
+      :name => 'REC2',
+      :schema_name => @conn.username,
+      :is_final_type? => true,
+      :is_instantiable_type? => true,
+      :is_subtype? => false,
+      :type_attrs => {
+        :class => Array,
+        :size => 3,
+        [0] => {
+          :class => OCI8::Metadata::TypeAttr,
+          :data_size => 0,
+          :typecode => :boolean,
+          :data_type => :boolean,
+          :name => 'B',
+          :precision => 0,
+          :scale => 0,
+          :type_name => 'PL/SQL BOOLEAN',
+          :schema_name => 'SYS',
+          :fsprecision => 0,
+          :lfprecision => 0,
+          :type_metadata => boolean_type_attrs,
+        },
+        [1] => {
+          :class => OCI8::Metadata::TypeAttr,
+          :data_size => 0,
+          :typecode => :named_collection,
+          :data_type => :named_type,
+          :name => 'IT',
+          :precision => 0,
+          :scale => 0,
+          :type_name => 'INDEXED_TABLE_OF_VARCHAR2',
+          :schema_name => @conn.username,
+          :fsprecision => 0,
+          :lfprecision => 0,
+          :type_metadata => indexed_table_of_varchar2_type_attrs,
+        },
+        [2] => {
+          :class => OCI8::Metadata::TypeAttr,
+          :data_size => 0,
+          :typecode => :record,
+          :data_type => :record,
+          :name => 'REC',
+          :precision => 0,
+          :scale => 0,
+          :type_name => 'REC1',
+          :schema_name => @conn.username,
+          :fsprecision => 0,
+          :lfprecision => 0,
+          :type_metadata => rec1_type_attrs,
+        },
+      },
+      :type_methods => [],
+    }
+
+    table_of_rec1_type_attrs = {
+      :class => OCI8::Metadata::Type,
+      :typecode => :named_collection,
+      :collection_typecode => :table,
+      :is_incomplete_type? => false,
+      :is_system_type? => false,
+      :is_predefined_type? => false,
+      :is_transient_type? => false,
+      :is_system_generated_type? => false,
+      :has_nested_table? => true,
+      :has_lob? => false,
+      :has_file? => false,
+      :collection_element => {
+        :class => OCI8::Metadata::Collection,
+        :data_size => 0,
+        :typecode => :record,
+        :data_type => :record,
+        :num_elems => 0,
+        :precision => 0,
+        :scale => 0,
+        :type_name => 'REC1',
+        :schema_name => @conn.username,
+        :type_metadata => rec1_type_attrs,
+      },
+      :num_type_attrs => 0,
+      :num_type_methods => 0,
+      :map_method => nil,
+      :order_method => nil,
+      :is_invoker_rights? => false,
+      :name => 'TABLE_OF_REC1',
+      :schema_name => @conn.username,
+      :is_final_type? => true,
+      :is_instantiable_type? => true,
+      :is_subtype? => false,
+      :type_attrs => [],
+      :type_methods => [],
+    }
+
+    table_of_rec2_type_attrs = {
+      :class => OCI8::Metadata::Type,
+      :typecode => :named_collection,
+      :collection_typecode => :table,
+      :is_incomplete_type? => false,
+      :is_system_type? => false,
+      :is_predefined_type? => false,
+      :is_transient_type? => false,
+      :is_system_generated_type? => false,
+      :has_nested_table? => true,
+      :has_lob? => false,
+      :has_file? => false,
+      :collection_element => {
+        :class => OCI8::Metadata::Collection,
+        :data_size => 0,
+        :typecode => :record,
+        :data_type => :record,
+        :num_elems => 0,
+        :precision => 0,
+        :scale => 0,
+        :type_name => 'REC2',
+        :schema_name => @conn.username,
+        :type_metadata => rec2_type_attrs,
+      },
+      :num_type_attrs => 0,
+      :num_type_methods => 0,
+      :map_method => nil,
+      :order_method => nil,
+      :is_invoker_rights? => false,
+      :name => 'TABLE_OF_REC2',
+      :schema_name => @conn.username,
+      :is_final_type? => true,
+      :is_instantiable_type? => true,
+      :is_subtype? => false,
+      :type_attrs => [],
+      :type_methods => [],
+    }
+
+    type_metadata_attrs = {
+      'ARRAY_OF_INTEGER' => array_of_integer_type_attrs,
+      'TABLE_OF_PLS_INTEGER' => table_of_pls_integer_type_attrs,
+      'TABLE_OF_BOOLEAN' => table_of_boolean_type_attrs,
+      'INDEXED_TABLE_OF_VARCHAR2' => indexed_table_of_varchar2_type_attrs,
+      'REC1' => rec1_type_attrs,
+      'REC2' => rec2_type_attrs,
+      'TABLE_OF_REC1' => table_of_rec1_type_attrs,
+      'TABLE_OF_REC2' => table_of_rec2_type_attrs,
+    }
+
+    sum_table_of_pls_integer_subprogram_attrs = {
+      :class => OCI8::Metadata::Function,
+      :obj_name => 'SUM_TABLE_OF_PLS_INTEGER',
+      :obj_schema => nil,
+      :is_invoker_rights? => false,
+      :name => 'SUM_TABLE_OF_PLS_INTEGER',
+      :overload_id => 0,
+      :arguments => {
+        :class => Array,
+        :size => 2,
+        [0] => {
+          :class => OCI8::Metadata::Argument,
+          :obj_name => nil,
+          :obj_schema => nil,
+          :name => "",
+          :position => 0,
+          #:typecode => nil,
+          :data_type => 3,
+          :data_size => 0,
+          :precision => 0,
+          :scale => 0,
+          :level => 0,
+          :has_default => 0,
+          :iomode => :out,
+          :radix => 0,
+          :type_name => "",
+          :schema_name => "",
+          :sub_name => "",
+          :link => "",
+          #:type_metadata => nil,
+          :arguments => [],
+        },
+        [1] => {
+          :class => OCI8::Metadata::Argument,
+          :obj_name => nil,
+          :obj_schema => nil,
+          :name => "TBL",
+          :position => 1,
+          #:typecode => nil,
+          :data_type => :named_type,
+          :data_size => 0,
+          :precision => 0,
+          :scale => 0,
+          :level => 0,
+          :has_default => 0,
+          :iomode => :in,
+          :radix => 0,
+          :type_name => "RB_TEST_PKG",
+          :schema_name => @conn.username,
+          :sub_name => "TABLE_OF_PLS_INTEGER",
+          :link => "",
+          #:type_metadata => nil,
+          :arguments => {
+            :class => Array,
+            :size => 1,
+            [0] => {
+              :class => OCI8::Metadata::Argument,
+              :obj_name => nil,
+              :obj_schema => nil,
+              :name => "",
+              :position => 1,
+              #:typecode => nil,
+              :data_type => 3,
+              :data_size => 0,
+              :precision => 0,
+              :scale => 0,
+              :level => 1,
+              :has_default => 0,
+              :iomode => :in,
+              :radix => 0,
+              :type_name => "",
+              :schema_name => "",
+              :sub_name => "",
+              :link => "",
+              #:type_metadata => nil,
+              :arguments => [],
+            },
+          },
+        },
+      },
+      :is_standalone? => false,
+    }
+
+    add_rec1_values_subprogram_attrs = {
+      :class => OCI8::Metadata::Function,
+      :obj_name => 'ADD_REC1_VALUES',
+      :obj_schema => nil,
+      :is_invoker_rights? => false,
+      :name => 'ADD_REC1_VALUES',
+      :overload_id => 0,
+      :arguments => {
+        :class => Array,
+        :size => 2,
+        [0] => {
+          :class => OCI8::Metadata::Argument,
+          :obj_name => nil,
+          :obj_schema => nil,
+          :name => "",
+          :position => 0,
+          #:typecode => nil,
+          :data_type => 3,
+          :data_size => 0,
+          :precision => 0,
+          :scale => 0,
+          :level => 0,
+          :has_default => 0,
+          :iomode => :out,
+          :radix => 0,
+          :type_name => "",
+          :schema_name => "",
+          :sub_name => "",
+          :link => "",
+          #:type_metadata => nil,
+          :arguments => [],
+        },
+        [1] => {
+          :class => OCI8::Metadata::Argument,
+          :obj_name => nil,
+          :obj_schema => nil,
+          :name => "TBL",
+          :position => 1,
+          #:typecode => nil,
+          :data_type => :named_type,
+          :data_size => 0,
+          :precision => 0,
+          :scale => 0,
+          :level => 0,
+          :has_default => 0,
+          :iomode => :in,
+          :radix => 0,
+          :type_name => "RB_TEST_PKG",
+          :schema_name => @conn.username,
+          :sub_name => "TABLE_OF_REC1",
+          :link => "",
+          #:type_metadata => nil,
+          :arguments => {
+            :class => Array,
+            :size => 1,
+            [0] => {
+              :class => OCI8::Metadata::Argument,
+              :obj_name => nil,
+              :obj_schema => nil,
+              :name => "",
+              :position => 1,
+              #:typecode => nil,
+              :data_type => 250,
+              :data_size => 0,
+              :precision => 0,
+              :scale => 0,
+              :level => 1,
+              :has_default => 0,
+              :iomode => :in,
+              :radix => 0,
+              :type_name => "RB_TEST_PKG",
+              :schema_name => @conn.username,
+              :sub_name => "REC1",
+              :link => "",
+              #:type_metadata => nil,
+              :arguments => {
+                :class => Array,
+                :size => 2,
+                [0] => {
+                  :class => OCI8::Metadata::Argument,
+                  :obj_name => nil,
+                  :obj_schema => nil,
+                  :name => "I",
+                  :position => 1,
+                  #:typecode => nil,
+                  :data_type => 3,
+                  :data_size => 0,
+                  :precision => 0,
+                  :scale => 0,
+                  :level => 2,
+                  :has_default => 0,
+                  :iomode => :in,
+                  :radix => 0,
+                  :type_name => "",
+                  :schema_name => "",
+                  :sub_name => "",
+                  :link => "",
+                  #:type_metadata => nil,
+                  :arguments => [],
+                },
+                [1] => {
+                  :class => OCI8::Metadata::Argument,
+                  :obj_name => nil,
+                  :obj_schema => nil,
+                  :name => "J",
+                  :position => 2,
+                  #:typecode => nil,
+                  :data_type => :number,
+                  :data_size => 22,
+                  :precision => 38,
+                  :scale => 0,
+                  :level => 2,
+                  :has_default => 0,
+                  :iomode => :in,
+                  :radix => 10,
+                  :type_name => "",
+                  :schema_name => "",
+                  :sub_name => "",
+                  :link => "",
+                  #:type_metadata => nil,
+                  :arguments => [],
+                },
+              },
+            },
+          },
+        },
+      },
+      :is_standalone? => false,
+    }
+
+    out_rec1_values_subprogram_attrs = {
+      :class => OCI8::Metadata::Procedure,
+      :obj_name => 'OUT_REC1_VALUES',
+      :obj_schema => nil,
+      :is_invoker_rights? => false,
+      :name => 'OUT_REC1_VALUES',
+      :overload_id => 0,
+      :arguments => {
+        :class => Array,
+        :size => 1,
+        [0] => {
+          :class => OCI8::Metadata::Argument,
+          :obj_name => nil,
+          :obj_schema => nil,
+          :name => "TBL",
+          :position => 1,
+          #:typecode => nil,
+          :data_type => :named_type,
+          :data_size => 0,
+          :precision => 0,
+          :scale => 0,
+          :level => 0,
+          :has_default => 0,
+          :iomode => :out,
+          :radix => 0,
+          :type_name => "RB_TEST_PKG",
+          :schema_name => @conn.username,
+          :sub_name => "TABLE_OF_REC1",
+          :link => "",
+          #:type_metadata => nil,
+          :arguments => {
+            :class => Array,
+            :size => 1,
+            [0] => {
+              :class => OCI8::Metadata::Argument,
+              :obj_name => nil,
+              :obj_schema => nil,
+              :name => "",
+              :position => 1,
+              #:typecode => nil,
+              :data_type => 250,
+              :data_size => 0,
+              :precision => 0,
+              :scale => 0,
+              :level => 1,
+              :has_default => 0,
+              :iomode => :out,
+              :radix => 0,
+              :type_name => "RB_TEST_PKG",
+              :schema_name => @conn.username,
+              :sub_name => "REC1",
+              :link => "",
+              #:type_metadata => nil,
+              :arguments => {
+                :class => Array,
+                :size => 2,
+                [0] => {
+                  :class => OCI8::Metadata::Argument,
+                  :obj_name => nil,
+                  :obj_schema => nil,
+                  :name => "I",
+                  :position => 1,
+                  #:typecode => nil,
+                  :data_type => 3,
+                  :data_size => 0,
+                  :precision => 0,
+                  :scale => 0,
+                  :level => 2,
+                  :has_default => 0,
+                  :iomode => :out,
+                  :radix => 0,
+                  :type_name => "",
+                  :schema_name => "",
+                  :sub_name => "",
+                  :link => "",
+                  #:type_metadata => nil,
+                  :arguments => [],
+                },
+                [1] => {
+                  :class => OCI8::Metadata::Argument,
+                  :obj_name => nil,
+                  :obj_schema => nil,
+                  :name => "J",
+                  :position => 2,
+                  #:typecode => nil,
+                  :data_type => :number,
+                  :data_size => 22,
+                  :precision => 38,
+                  :scale => 0,
+                  :level => 2,
+                  :has_default => 0,
+                  :iomode => :out,
+                  :radix => 10,
+                  :type_name => "",
+                  :schema_name => "",
+                  :sub_name => "",
+                  :link => "",
+                  #:type_metadata => nil,
+                  :arguments => [],
+                },
+              },
+            },
+          },
+        },
+      },
+      :is_standalone? => false,
+    }
+
+    subprogram_metadata_attrs = {
+      'SUM_TABLE_OF_PLS_INTEGER' => sum_table_of_pls_integer_subprogram_attrs,
+      'ADD_REC1_VALUES' => add_rec1_values_subprogram_attrs,
+      'OUT_REC1_VALUES' => out_rec1_values_subprogram_attrs,
+    }
+
+    pkg_metadata = @conn.describe_package('rb_test_pkg')
+
+    assert_kind_of(OCI8::Metadata::Package, pkg_metadata)
+    assert_equal(false, pkg_metadata.is_invoker_rights?)
+    type_metadata = pkg_metadata.types
+    assert_kind_of(Array, type_metadata)
+    assert_equal(8, type_metadata.size)
+    type_metadata.each do |md|
+      attrs = type_metadata_attrs[md.name]
+      if attrs
+        check_attributes(md.name, md, attrs)
+      else
+        raise "unknown type name #{md.name}"
+      end
+    end
+
+    subprogram_metadata = pkg_metadata.subprograms
+    assert_kind_of(Array, subprogram_metadata)
+    assert_equal(3, subprogram_metadata.size)
+    subprogram_metadata.each do |md|
+      attrs = subprogram_metadata_attrs[md.name]
+      if attrs
+        check_attributes(md.name, md, attrs)
+      else
+        raise "unknown subprogram name #{md.name}"
+      end
+    end
+  end
+end


Property changes on: trunk/ruby-oci8/test/test_package_type.rb
___________________________________________________________________
Added: svn:eol-style
   + native



More information about the ruby-oci8-commit mailing list