ruby-oci8 2.0.6-x86-mingw32 → 2.1.0-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,44 +2,76 @@
2
2
  # setup default OCI encoding from NLS_LANG.
3
3
  #
4
4
 
5
- # try to get NLS_LANG.
6
- nls_lang = ENV['NLS_LANG']
5
+ class OCI8
7
6
 
8
- # if NLS_LANG is not set, get it from the Windows registry.
9
- if nls_lang.nil? and defined? OCI8::Win32Util
10
- dll_path = OCI8::Win32Util.dll_path.upcase
11
- if dll_path =~ %r{\\BIN\\OCI.DLL}
12
- oracle_home = $`
13
- OCI8::Win32Util.enum_homes do |home, lang|
14
- if oracle_home == home.upcase
15
- nls_lang = lang
16
- break
7
+ # get the environment variable NLS_LANG.
8
+ nls_lang = ENV['NLS_LANG']
9
+
10
+ if nls_lang.is_a? String and nls_lang.length == 0
11
+ nls_lang = nil
12
+ end
13
+
14
+ # if NLS_LANG is not set, get it from the Windows registry.
15
+ if nls_lang.nil? and defined? OCI8::Win32Util
16
+ dll_path = OCI8::Win32Util.dll_path.upcase
17
+ if dll_path =~ %r{\\BIN\\OCI.DLL}
18
+ oracle_home = $`
19
+ OCI8::Win32Util.enum_homes do |home, lang|
20
+ if oracle_home == home.upcase
21
+ nls_lang = lang
22
+ break
23
+ end
17
24
  end
18
25
  end
19
26
  end
20
- end
21
27
 
22
- if nls_lang
23
- # Extract character set name from NLS_LANG.
24
- if nls_lang =~ /\.([[:alnum:]]+)$/
25
- charset = $1.upcase
28
+ # extract the charset name.
29
+ if nls_lang
30
+ if nls_lang =~ /\.([[:alnum:]]+)$/
31
+ @@client_charset_name = $1.upcase
32
+ else
33
+ raise "Invalid NLS_LANG format: #{nls_lang}"
34
+ end
26
35
  else
27
- raise "Invalid NLS_LANG format: #{nls_lang}"
36
+ warn "Warning: NLS_LANG is not set. fallback to US7ASCII."
37
+ @@client_charset_name = 'US7ASCII'
28
38
  end
29
39
 
30
- # Convert the Oracle character set name to Ruby encoding name by
31
- # querying the yaml data.
32
- require 'yaml'
33
- enc = YAML::load_file(File.dirname(__FILE__) + '/encoding.yml')[charset]
34
- if enc.nil?
35
- raise "Ruby encoding name is not found in encoding.yml for NLS_LANG #{nls_lang}."
40
+ # NLS ratio, maximum number of bytes per one chracter
41
+ case @@client_charset_name
42
+ when 'UTF8'
43
+ OCI8.nls_ratio = 3
44
+ when 'AL16UTF16'
45
+ OCI8.nls_ratio = 4
46
+ when /^[[:alpha:]]+(\d+)/
47
+ # convert maximum number of bits per one chracter to NLS ratio.
48
+ # charset name max bits max bytes
49
+ # ------------ -------- ---------
50
+ # US7ASCII 7 1
51
+ # WE8ISO8859P1 8 1
52
+ # JA16SJIS 16 2
53
+ # AL32UTF8 32 4
54
+ # ...
55
+ OCI8.nls_ratio = (($1.to_i + 7) >> 3)
56
+ else
57
+ raise "Unknown NLS character set name format: #{@@client_charset_name}"
36
58
  end
37
- if enc.is_a? Array
38
- # Use the first available encoding in the array.
39
- enc = enc.find do |e| Encoding.find(e) rescue false; end
59
+
60
+ # Ruby encoding name for ruby 1.9.
61
+ if OCI8.respond_to? :encoding
62
+ if defined? DEFAULT_OCI8_ENCODING
63
+ enc = DEFAULT_OCI8_ENCODING
64
+ else
65
+ require 'yaml'
66
+ enc = YAML::load_file(File.dirname(__FILE__) + '/encoding.yml')[@@client_charset_name]
67
+ if enc.nil?
68
+ raise "Ruby encoding name is not found in encoding.yml for NLS_LANG #{nls_lang}."
69
+ end
70
+ if enc.is_a? Array
71
+ # Use the first available encoding in the array.
72
+ enc = enc.find do |e| Encoding.find(e) rescue false; end
73
+ end
74
+ end
75
+ OCI8.encoding = enc
40
76
  end
41
- else
42
- warn "Warning: NLS_LANG is not set. fallback to US-ASCII."
43
- enc = 'US-ASCII'
44
77
  end
45
- OCI8.encoding = enc
@@ -40,10 +40,10 @@ ZHS16GBK: GBK
40
40
  # MS Windows Code Page 950 with Hong Kong Supplementary Character
41
41
  # Set HKSCS-2001 (character set conversion to and from Unicode is
42
42
  # based on Unicode 3.0)
43
- ZHT16HKSCS: [Big5-HKSCS, Big5]
43
+ ZHT16HKSCS: [CP951, Big5-HKSCS, Big5]
44
44
 
45
45
  # MS Windows Code Page 950 Traditional Chinese
46
- ZHT16MSWIN950: Big5
46
+ ZHT16MSWIN950: [CP950, Big5]
47
47
 
48
48
  # EUC 32-bit Traditional Chinese
49
49
  ZHT32EUC: EUC-TW # Who use this?
@@ -166,7 +166,7 @@ ZHT16DBT: nil # FIXME
166
166
  # MS Windows Code Page 950 with Hong Kong Supplementary Character
167
167
  # Set HKSCS-2001 (character set conversion to and from Unicode is
168
168
  # based on Unicode 3.1)
169
- ZHT16HKSCS31: [Big5-HKSCS, Big5]
169
+ ZHT16HKSCS31: [CP951, Big5-HKSCS, Big5]
170
170
 
171
171
  # SOPS 32-bit Traditional Chinese
172
172
  ZHT32SOPS: nil # FIXME
@@ -1,264 +1,99 @@
1
- # Implement OCI8::Metadata.
1
+ # oci8.rb -- implements OCI8::Metadata.
2
+ #
3
+ # Copyright (C) 2006-2010 KUBO Takehiro <kubo@jiubao.org>
4
+ #
2
5
  # See {'Describing Schema Metadata' in Oracle Call Interface Programmer's Guide}
3
6
  # [http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14250/oci06des.htm]
4
7
 
5
8
  #
6
9
  class OCI8
7
10
 
8
- # :stopdoc:
9
-
10
- # Attribute Types in oci.h
11
- OCI_ATTR_DATA_SIZE = 1 # maximum size of the data
12
- OCI_ATTR_DATA_TYPE = 2 # the SQL type of the column/argument
13
- OCI_ATTR_NAME = 4 # the name of the column/argument
14
- OCI_ATTR_PRECISION = 5 # precision if number type
15
- OCI_ATTR_SCALE = 6 # scale if number type
16
- OCI_ATTR_IS_NULL = 7 # is it null ?
17
- OCI_ATTR_TYPE_NAME = 8 # name of the named data type or a package name
18
- OCI_ATTR_SCHEMA_NAME = 9 # the schema name
19
- OCI_ATTR_SUB_NAME = 10 # type name if package private type
20
- OCI_ATTR_POSITION = 11 # relative position
21
- OCI_ATTR_PDSCL = 16 # packed decimal scale
22
- OCI_ATTR_FSPRECISION = OCI_ATTR_PDSCL # fs prec for datetime data types
23
- OCI_ATTR_PDPRC = 17 # packed decimal format
24
- OCI_ATTR_LFPRECISION = OCI_ATTR_PDPRC # fs prec for datetime data types
25
- OCI_ATTR_CHARSET_ID = 31 # Character Set ID
26
- OCI_ATTR_CHARSET_FORM = 32 # Character Set Form
27
- OCI_ATTR_NUM_COLS = 102 # number of columns
28
- OCI_ATTR_LIST_COLUMNS = 103 # parameter of the column list
29
- OCI_ATTR_RDBA = 104 # DBA of the segment header
30
- OCI_ATTR_CLUSTERED = 105 # whether the table is clustered
31
- OCI_ATTR_PARTITIONED = 106 # whether the table is partitioned
32
- OCI_ATTR_INDEX_ONLY = 107 # whether the table is index only
33
- OCI_ATTR_LIST_ARGUMENTS = 108 # parameter of the argument list
34
- OCI_ATTR_LIST_SUBPROGRAMS = 109 # parameter of the subprogram list
35
- OCI_ATTR_REF_TDO = 110 # REF to the type descriptor
36
- OCI_ATTR_LINK = 111 # the database link name
37
- OCI_ATTR_MIN = 112 # minimum value
38
- OCI_ATTR_MAX = 113 # maximum value
39
- OCI_ATTR_INCR = 114 # increment value
40
- OCI_ATTR_CACHE = 115 # number of sequence numbers cached
41
- OCI_ATTR_ORDER = 116 # whether the sequence is ordered
42
- OCI_ATTR_HW_MARK = 117 # high-water mark
43
- OCI_ATTR_TYPE_SCHEMA = 118 # type's schema name
44
- OCI_ATTR_TIMESTAMP = 119 # timestamp of the object
45
- OCI_ATTR_NUM_PARAMS = 121 # number of parameters
46
- OCI_ATTR_OBJID = 122 # object id for a table or view
47
- OCI_ATTR_OVERLOAD_ID = 125 # overload ID for funcs and procs
48
- OCI_ATTR_TABLESPACE = 126 # table name space
49
- OCI_ATTR_LTYPE = 128 # list type
50
- OCI_ATTR_IS_TEMPORARY = 130 # whether table is temporary
51
- OCI_ATTR_IS_TYPED = 131 # whether table is typed
52
- OCI_ATTR_DURATION = 132 # duration of temporary table
53
- OCI_ATTR_IS_INVOKER_RIGHTS = 133 # is invoker rights
54
- OCI_ATTR_OBJ_NAME = 134 # top level schema obj name
55
- OCI_ATTR_OBJ_SCHEMA = 135 # schema name
56
- OCI_ATTR_OBJ_ID = 136 # top level schema object id
57
- # OCI_ATTR_OVERLOAD = 210 # is this position overloaded
58
- OCI_ATTR_LEVEL = 211 # level for structured types
59
- OCI_ATTR_HAS_DEFAULT = 212 # has a default value
60
- OCI_ATTR_IOMODE = 213 # in, out inout
61
- OCI_ATTR_RADIX = 214 # returns a radix
62
- # OCI_ATTR_NUM_ARGS = 215 # total number of arguments
63
- OCI_ATTR_TYPECODE = 216 # object or collection
64
- OCI_ATTR_COLLECTION_TYPECODE = 217 # varray or nested table
65
- OCI_ATTR_VERSION = 218 # user assigned version
66
- OCI_ATTR_IS_INCOMPLETE_TYPE = 219 # is this an incomplete type
67
- OCI_ATTR_IS_SYSTEM_TYPE = 220 # a system type
68
- OCI_ATTR_IS_PREDEFINED_TYPE = 221 # a predefined type
69
- OCI_ATTR_IS_TRANSIENT_TYPE = 222 # a transient type
70
- OCI_ATTR_IS_SYSTEM_GENERATED_TYPE = 223 # system generated type
71
- OCI_ATTR_HAS_NESTED_TABLE = 224 # contains nested table attr
72
- OCI_ATTR_HAS_LOB = 225 # has a lob attribute
73
- OCI_ATTR_HAS_FILE = 226 # has a file attribute
74
- OCI_ATTR_COLLECTION_ELEMENT = 227 # has a collection attribute
75
- OCI_ATTR_NUM_TYPE_ATTRS = 228 # number of attribute types
76
- OCI_ATTR_LIST_TYPE_ATTRS = 229 # list of type attributes
77
- OCI_ATTR_NUM_TYPE_METHODS = 230 # number of type methods
78
- OCI_ATTR_LIST_TYPE_METHODS = 231 # list of type methods
79
- OCI_ATTR_MAP_METHOD = 232 # map method of type
80
- OCI_ATTR_ORDER_METHOD = 233 # order method of type
81
- OCI_ATTR_NUM_ELEMS = 234 # number of elements
82
- OCI_ATTR_ENCAPSULATION = 235 # encapsulation level
83
- OCI_ATTR_IS_SELFISH = 236 # method selfish
84
- # OCI_ATTR_IS_VIRTUAL = 237 # virtual
85
- # OCI_ATTR_IS_INLINE = 238 # inline
86
- # OCI_ATTR_IS_CONSTANT = 239 # constant
87
- OCI_ATTR_HAS_RESULT = 240 # has result
88
- OCI_ATTR_IS_CONSTRUCTOR = 241 # constructor
89
- OCI_ATTR_IS_DESTRUCTOR = 242 # destructor
90
- # OCI_ATTR_IS_OPERATOR = 243 # operator
91
- OCI_ATTR_IS_MAP = 244 # a map method
92
- OCI_ATTR_IS_ORDER = 245 # order method
93
- OCI_ATTR_IS_RNDS = 246 # read no data state method
94
- OCI_ATTR_IS_RNPS = 247 # read no process state
95
- OCI_ATTR_IS_WNDS = 248 # write no data state method
96
- OCI_ATTR_IS_WNPS = 249 # write no process state
97
- OCI_ATTR_IS_SUBTYPE = 258
98
- OCI_ATTR_SUPERTYPE_SCHEMA_NAME = 259
99
- OCI_ATTR_SUPERTYPE_NAME = 260
100
- OCI_ATTR_LIST_OBJECTS = 261 # list of objects in schema
101
- OCI_ATTR_NCHARSET_ID = 262 # char set id
102
- OCI_ATTR_LIST_SCHEMAS = 263 # list of schemas
103
- OCI_ATTR_MAX_PROC_LEN = 264 # max procedure length
104
- OCI_ATTR_MAX_COLUMN_LEN = 265 # max column name length
105
- OCI_ATTR_CURSOR_COMMIT_BEHAVIOR = 266 # cursor commit behavior
106
- OCI_ATTR_MAX_CATALOG_NAMELEN = 267 # catalog namelength
107
- OCI_ATTR_CATALOG_LOCATION = 268 # catalog location
108
- OCI_ATTR_SAVEPOINT_SUPPORT = 269 # savepoint support
109
- OCI_ATTR_NOWAIT_SUPPORT = 270 # nowait support
110
- OCI_ATTR_AUTOCOMMIT_DDL = 271 # autocommit DDL
111
- OCI_ATTR_LOCKING_MODE = 272 # locking mode
112
- # OCI_ATTR_CLIENT_IDENTIFIER = 278 # value of client id to set
113
- OCI_ATTR_IS_FINAL_TYPE = 279 # is final type ?
114
- OCI_ATTR_IS_INSTANTIABLE_TYPE = 280 # is instantiable type ?
115
- OCI_ATTR_IS_FINAL_METHOD = 281 # is final method ?
116
- OCI_ATTR_IS_INSTANTIABLE_METHOD = 282 # is instantiable method ?
117
- OCI_ATTR_IS_OVERRIDING_METHOD = 283 # is overriding method ?
118
- # OCI_ATTR_DESC_SYNBASE = 284 # Describe the base object
119
- OCI_ATTR_CHAR_USED = 285 # char length semantics
120
- OCI_ATTR_CHAR_SIZE = 286 # char length
121
- OCI_ATTR_CONDITION = 342 # rule condition
122
- OCI_ATTR_COMMENT = 343 # comment
123
- OCI_ATTR_VALUE = 344 # Anydata value
124
- OCI_ATTR_EVAL_CONTEXT_OWNER = 345 # eval context owner
125
- OCI_ATTR_EVAL_CONTEXT_NAME = 346 # eval context name
126
- OCI_ATTR_EVALUATION_FUNCTION = 347 # eval function name
127
- OCI_ATTR_VAR_TYPE = 348 # variable type
128
- OCI_ATTR_VAR_VALUE_FUNCTION = 349 # variable value function
129
- OCI_ATTR_VAR_METHOD_FUNCTION = 350 # variable method function
130
- # OCI_ATTR_ACTION_CONTEXT = 351 # action context
131
- OCI_ATTR_LIST_TABLE_ALIASES = 352 # list of table aliases
132
- OCI_ATTR_LIST_VARIABLE_TYPES = 353 # list of variable types
133
- OCI_ATTR_TABLE_NAME = 356 # table name
134
-
135
- # OCI Parameter Types
136
- OCI_PTYPE_UNK = 0 # unknown
137
- OCI_PTYPE_TABLE = 1 # table
138
- OCI_PTYPE_VIEW = 2 # view
139
- OCI_PTYPE_PROC = 3 # procedure
140
- OCI_PTYPE_FUNC = 4 # function
141
- OCI_PTYPE_PKG = 5 # package
142
- OCI_PTYPE_TYPE = 6 # user-defined type
143
- OCI_PTYPE_SYN = 7 # synonym
144
- OCI_PTYPE_SEQ = 8 # sequence
145
- OCI_PTYPE_COL = 9 # column
146
- OCI_PTYPE_ARG = 10 # argument
147
- OCI_PTYPE_LIST = 11 # list
148
- OCI_PTYPE_TYPE_ATTR = 12 # user-defined type's attribute
149
- OCI_PTYPE_TYPE_COLL = 13 # collection type's element
150
- OCI_PTYPE_TYPE_METHOD = 14 # user-defined type's method
151
- OCI_PTYPE_TYPE_ARG = 15 # user-defined type method's arg
152
- OCI_PTYPE_TYPE_RESULT = 16 # user-defined type method's result
153
- OCI_PTYPE_SCHEMA = 17 # schema
154
- OCI_PTYPE_DATABASE = 18 # database
155
- OCI_PTYPE_RULE = 19 # rule
156
- OCI_PTYPE_RULE_SET = 20 # rule set
157
- OCI_PTYPE_EVALUATION_CONTEXT = 21 # evaluation context
158
- OCI_PTYPE_TABLE_ALIAS = 22 # table alias
159
- OCI_PTYPE_VARIABLE_TYPE = 23 # variable type
160
- OCI_PTYPE_NAME_VALUE = 24 # name value pair
161
-
162
- # OCI List Types
163
- OCI_LTYPE_UNK = 0 # unknown
164
- OCI_LTYPE_COLUMN = 1 # column list
165
- OCI_LTYPE_ARG_PROC = 2 # procedure argument list
166
- OCI_LTYPE_ARG_FUNC = 3 # function argument list
167
- OCI_LTYPE_SUBPRG = 4 # subprogram list
168
- OCI_LTYPE_TYPE_ATTR = 5 # type attribute
169
- OCI_LTYPE_TYPE_METHOD = 6 # type method
170
- OCI_LTYPE_TYPE_ARG_PROC = 7 # type method w/o result argument list
171
- OCI_LTYPE_TYPE_ARG_FUNC = 8 # type method w/result argument list
172
- OCI_LTYPE_SCH_OBJ = 9 # schema object list
173
- OCI_LTYPE_DB_SCH = 10 # database schema list
174
- OCI_LTYPE_TYPE_SUBTYPE = 11 # subtype list
175
- OCI_LTYPE_TABLE_ALIAS = 12 # table alias list
176
- OCI_LTYPE_VARIABLE_TYPE = 13 # variable type list
177
- OCI_LTYPE_NAME_VALUE = 14 # name value list
178
-
179
- # OBJECT Duration in oro.h
180
- OCI_DURATION_INVALID = 0xFFFF
181
- OCI_DURATION_BEGIN = 10
182
- OCI_DURATION_NULL = OCI_DURATION_BEGIN - 1
183
- OCI_DURATION_DEFAULT = OCI_DURATION_BEGIN - 2
184
- OCI_DURATION_USER_CALLBACK = OCI_DURATION_BEGIN - 3
185
- OCI_DURATION_NEXT = OCI_DURATION_BEGIN - 4
186
- OCI_DURATION_SESSION = OCI_DURATION_BEGIN
187
- OCI_DURATION_TRANS = OCI_DURATION_BEGIN + 1
188
- OCI_DURATION_CALL = OCI_DURATION_BEGIN + 2
189
- OCI_DURATION_STATEMENT = OCI_DURATION_BEGIN + 3
190
- OCI_DURATION_CALLOUT = OCI_DURATION_BEGIN + 4
191
-
192
- # :startdoc:
193
-
194
- # = OCI8 can describe database object's metadata.
195
- # [user objects]
196
- # OCI8#describe_any(object_name)
197
- # [table or view]
198
- # OCI8#describe_table(table_name, table_only = false)
199
- # [view]
200
- # OCI8#describe_view(view_name)
201
- # [procedure]
202
- # OCI8#describe_procedure(procedure_name)
203
- # [function]
204
- # OCI8#describe_function(function_name)
205
- # [package]
206
- # OCI8#describe_package(package_name)
207
- # [type]
208
- # OCI8#describe_type(type_name)
209
- # [synonym]
210
- # OCI8#describe_synonym(synonym_name, check_public_also = false)
211
- # [sequence]
212
- # OCI8#describe_sequence(sequence_name)
213
- # [schema]
214
- # OCI8#describe_schema(schema_name)
215
- # [database]
216
- # OCI8#describe_database(database_name)
11
+ # OCI8 has methods to obtain information about database objects such
12
+ # as tables, views, procedures, functions ans so on. The obtained
13
+ # data are called metadata and retrived as an instance of
14
+ # OCI8::Metadata::Base's subclass.
217
15
  #
218
- # The name can be supplied as 'OBJECT_NAME' or 'SCHEMA_NAME.OBJECT_NAME'.
219
- # For example: 'emp', 'scott.emp'.
16
+ # List of methods which return OCI8::Metadata::Base.
17
+ # * OCI8#describe_any(object_name)
18
+ # * OCI8#describe_table(table_name, table_only = false)
19
+ # * OCI8#describe_view(view_name)
20
+ # * OCI8#describe_procedure(procedure_name)
21
+ # * OCI8#describe_function(function_name)
22
+ # * OCI8#describe_package(package_name)
23
+ # * OCI8#describe_type(type_name)
24
+ # * OCI8#describe_synonym(synonym_name, check_public_also = true)
25
+ # * OCI8#describe_sequence(sequence_name)
26
+ # * OCI8#describe_schema(schema_name)
27
+ # * OCI8#describe_database(database_name)
28
+ # * OCI8::Metadata::Type#map_method
29
+ # * OCI8::Metadata::Type#order_method
30
+ # * OCI8::Metadata::Type#collection_element
220
31
  #
221
- # = Retrieving Column Datatypes for a Table
32
+ # List of methods which return an array of OCI8::Metadata::Base.
33
+ # * OCI8::Cursor#column_metadata
34
+ # * OCI8::Metadata::Database#schemas
35
+ # * OCI8::Metadata::Schema#all_objects
36
+ # * OCI8::Metadata::Schema#objects
37
+ # * OCI8::Metadata::Table#columns
38
+ # * OCI8::Metadata::Package#subprograms
39
+ # * OCI8::Metadata::Procedure#arguments
40
+ # * OCI8::Metadata::Function#arguments
41
+ # * OCI8::Metadata::Type#type_attrs
42
+ # * OCI8::Metadata::Type#type_methods
43
+ # * OCI8::Metadata::TypeMethod#arguments
222
44
  #
223
- # conn = OCI8.new('ruby', 'oci8')
224
- # table = conn.describe_table('EMPLOYEES')
225
- # table.columns.each do |col|
226
- # if col.char_used
227
- # col_width = col.char_size
228
- # else
229
- # col_width = col.data_size
230
- # end
231
- # end
45
+ # Example:
46
+ # conn = OCI8.new('username/passord')
47
+ # table = conn.describe_table('scott.emp')
48
+ # table.columns.each do |col|
49
+ # puts "#{col.name} #{col.data_type_string}"
50
+ # end
232
51
  module Metadata
233
- # Abstract super class for Metadata classes.
52
+ # Abstract super class of Metadata classes.
234
53
  class Base
235
54
  # Table 6-1 Attributes Belonging to All Parameters
236
55
 
237
- # don't use this. The number of parameters
238
- def num_params
239
- __ub2(OCI_ATTR_NUM_PARAMS)
56
+ # Returns the number of parameters.
57
+ def num_params # :nodoc:
58
+ attr_get_ub2(OCI_ATTR_NUM_PARAMS)
240
59
  end
241
60
  private :num_params
242
61
 
243
- # object or schema ID
62
+ # call-seq:
63
+ # obj_id -> integer or nil
64
+ #
65
+ # Returns the object ID, which is the same as the value of the
66
+ # OBJECT_ID column from ALL_OBJECTS. It returns +nil+
67
+ # if the database object doesn't have ID.
244
68
  def obj_id
245
- __ub4(OCI_ATTR_OBJ_ID)
69
+ attr_get_ub4(OCI_ATTR_OBJ_ID)
246
70
  end
247
71
 
248
- # database name or object name in a schema
72
+ # call-seq:
73
+ # obj_name -> string
74
+ #
75
+ # Retruns the object name such as table name, view name,
76
+ # procedure name, and so on.
249
77
  def obj_name
250
- __text(OCI_ATTR_OBJ_NAME)
78
+ attr_get_string(OCI_ATTR_OBJ_NAME)
251
79
  end
252
80
 
253
- # schema name where the object is located
81
+ # call-seq:
82
+ # obj_schema -> string
83
+ #
84
+ # Retruns the schema name. It returns +nil+
85
+ # if the database object is not defined just under a schema.
254
86
  def obj_schema
255
- __text(OCI_ATTR_OBJ_SCHEMA)
87
+ attr_get_string(OCI_ATTR_OBJ_SCHEMA)
256
88
  end
257
89
 
258
90
  # The timestamp of the object
259
- def timestamp
260
- __oradate(OCI_ATTR_TIMESTAMP)
261
- end
91
+ #-
92
+ # As far as I checked, it is current timestamp, not the object's timestamp. Why?
93
+ #+
94
+ #def timestamp
95
+ # attr_get_oradate(OCI_ATTR_TIMESTAMP)
96
+ #end
262
97
 
263
98
  def inspect # :nodoc:
264
99
  "#<#{self.class.name}:(#{obj_id}) #{obj_schema}.#{obj_name}>"
@@ -266,9 +101,9 @@ class OCI8
266
101
  private
267
102
 
268
103
  def __boolean(idx)
269
- __ub1(idx) == 0 ? false : true
104
+ attr_get_ub1(idx) == 0 ? false : true
270
105
  end
271
- alias __word __sb4
106
+ alias __word attr_get_sb4
272
107
  def __anydata(idx); raise NotImplementedError; end
273
108
 
274
109
  # SQLT values to name
@@ -349,7 +184,7 @@ class OCI8
349
184
  # SQLT_REF
350
185
  DATA_TYPE_MAP[110] = [:ref,
351
186
  Proc.new do |p|
352
- "#{p.schema_name}.#{p.type_name}"
187
+ "REF #{p.schema_name}.#{p.type_name}"
353
188
  end]
354
189
  # SQLT_CLOB
355
190
  DATA_TYPE_MAP[112] = [:clob,
@@ -418,16 +253,16 @@ class OCI8
418
253
  end
419
254
  end]
420
255
 
421
- def __data_type
256
+ def __data_type # :nodoc:
422
257
  return @data_type if defined? @data_type
423
- entry = DATA_TYPE_MAP[__ub2(OCI_ATTR_DATA_TYPE)]
424
- type = entry.nil? ? __ub2(OCI_ATTR_DATA_TYPE) : entry[0]
258
+ entry = DATA_TYPE_MAP[attr_get_ub2(OCI_ATTR_DATA_TYPE)]
259
+ type = entry.nil? ? attr_get_ub2(OCI_ATTR_DATA_TYPE) : entry[0]
425
260
  type = type.call(self) if type.is_a? Proc
426
261
  @data_type = type
427
262
  end
428
263
 
429
- def __duration
430
- case __ub2(OCI_ATTR_DURATION)
264
+ def __duration # :nodoc:
265
+ case attr_get_ub2(OCI_ATTR_DURATION)
431
266
  when OCI_DURATION_SESSION
432
267
  :session
433
268
  when OCI_DURATION_TRANS
@@ -437,8 +272,8 @@ class OCI8
437
272
  end
438
273
  end
439
274
 
440
- def __charset_form
441
- case __ub1(OCI_ATTR_CHARSET_FORM)
275
+ def __charset_form # :nodoc:
276
+ case attr_get_ub1(OCI_ATTR_CHARSET_FORM)
442
277
  when 1; :implicit # for CHAR, VARCHAR2, CLOB w/o a specified set
443
278
  when 2; :nchar # for NCHAR, NCHAR VARYING, NCLOB
444
279
  when 3; :explicit # for CHAR, etc, with "CHARACTER SET ..." syntax
@@ -447,9 +282,9 @@ class OCI8
447
282
  end
448
283
  end
449
284
 
450
- def __type_string
451
- entry = DATA_TYPE_MAP[__ub2(OCI_ATTR_DATA_TYPE)]
452
- type = entry.nil? ? "unknown(#{__ub2(OCI_ATTR_DATA_TYPE)})" : entry[1]
285
+ def __data_type_string # :nodoc:
286
+ entry = DATA_TYPE_MAP[attr_get_ub2(OCI_ATTR_DATA_TYPE)]
287
+ type = entry.nil? ? "unknown(#{attr_get_ub2(OCI_ATTR_DATA_TYPE)})" : entry[1]
453
288
  type = type.call(self) if type.is_a? Proc
454
289
  if respond_to?(:nullable?) && !nullable?
455
290
  type + " NOT NULL"
@@ -458,8 +293,8 @@ class OCI8
458
293
  end
459
294
  end
460
295
 
461
- def __typecode(idx)
462
- case __ub2(idx)
296
+ def __typecode(idx) # :nodoc:
297
+ case attr_get_ub2(idx)
463
298
  when 110; :ref # OCI_TYPECODE_REF
464
299
  when 12; :date # OCI_TYPECODE_DATE
465
300
  when 27; :signed8 # OCI_TYPECODE_SIGNED8
@@ -510,18 +345,18 @@ class OCI8
510
345
  end
511
346
  end
512
347
 
513
- # metadata for a object which cannot be classified into other
514
- # metadata classes.
348
+ # Information about database objects which cannot be classified
349
+ # into other metadata classes.
515
350
  #
516
- # This is returned by:
351
+ # An instance of this class is returned by:
517
352
  # * OCI8::Metadata::Schema#all_objects
518
353
  class Unknown < Base
519
354
  register_ptype OCI_PTYPE_UNK
520
355
  end
521
356
 
522
- # Metadata for a table.
357
+ # Information about tables
523
358
  #
524
- # This is returned by:
359
+ # An instance of this class is returned by:
525
360
  # * OCI8#describe_any(name)
526
361
  # * OCI8#describe_table(name)
527
362
  # * OCI8::Metadata::Schema#all_objects
@@ -535,76 +370,126 @@ class OCI8
535
370
 
536
371
  ## Table 6-2 Attributes Belonging to Tables or Views
537
372
 
538
- # number of columns
373
+ # call-seq:
374
+ # num_cols -> integer
375
+ #
376
+ # Returns number of columns
539
377
  def num_cols
540
- __ub2(OCI_ATTR_NUM_COLS)
378
+ attr_get_ub2(OCI_ATTR_NUM_COLS)
541
379
  end
542
380
 
543
381
  # column list
544
- def list_columns
382
+ def list_columns # :nodoc:
545
383
  __param(OCI_ATTR_LIST_COLUMNS)
546
384
  end
547
385
  private :list_columns
548
386
 
549
- # to type metadata if possible
387
+ # call-seq:
388
+ # type_metadata -> an OCI8::Metadata::Type or nil
389
+ #
390
+ # Retruns an instance of OCI8::Metadata::Type if the table is an
391
+ # {object table}[http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjint.htm#sthref61].
392
+ # Otherwise, +nil+.
550
393
  def type_metadata
551
- __type_metadata(OCI8::Metadata::Type)
394
+ __type_metadata(OCI8::Metadata::Type) if is_typed?
552
395
  end
553
396
 
554
- # indicates the table is temporary.
397
+ # call-seq:
398
+ # is_temporary? -> true or false
399
+ #
400
+ # Returns +true+ if the table is a
401
+ # {temporary table}[http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/schema.htm#i16096].
402
+ # Otherwise, +false+.
555
403
  def is_temporary?
556
- __boolean(OCI_ATTR_IS_TEMPORARY)
404
+ attr_get_ub1(OCI_ATTR_IS_TEMPORARY) != 0
557
405
  end
558
406
 
559
- # indicates the table is typed.
407
+ # call-seq:
408
+ # is_typed? -> true or false
409
+ #
410
+ # Returns +true+ if the table is a object table. Otherwise, +false+.
560
411
  def is_typed?
561
- __boolean(OCI_ATTR_IS_TYPED)
412
+ attr_get_ub1(OCI_ATTR_IS_TYPED) != 0
562
413
  end
563
414
 
564
- # Duration of a temporary table. Values can be <tt>:session</tt> or
565
- # <tt>:transaction</tt>. nil if not a temporary table.
415
+ # call-seq:
416
+ # duration -> :transaction, :session or nil
417
+ #
418
+ # Retruns +:transaction+ if the table is a
419
+ # {transaction-specific temporary table}[http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_7002.htm#i2189569].
420
+ # +:session+ if it is a
421
+ # {session-specific temporary table}[http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_7002.htm#i2189569].
422
+ # Otherwise, +nil+.
566
423
  def duration
567
424
  __duration
568
425
  end
569
426
 
570
427
  ## Table 6-3 Attributes Specific to Tables
571
428
 
572
- # data block address of the segment header. (How to use this?)
429
+ # call-seq:
430
+ # dba -> integer
431
+ #
432
+ # Returns a Data Block Address(DBA) of the segment header.
433
+ #
434
+ # The dba is converted to the file number and the block number
435
+ # by DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE and
436
+ # DBMS_UTILITY.DATA_BLOCK_ADDRESS_BLOCK respectively.
573
437
  def dba
574
- __ub4(OCI_ATTR_RDBA)
438
+ attr_get_ub4(OCI_ATTR_RDBA)
575
439
  end
576
440
 
577
- # tablespace the table resides in. (How to use this?)
441
+ # call-seq:
442
+ # tablespace -> integer
443
+ #
444
+ # Returns a tablespace number the table resides in.
578
445
  def tablespace
579
446
  __word(OCI_ATTR_TABLESPACE)
580
447
  end
581
448
 
582
- # indicates the table is clustered.
449
+ # call-seq:
450
+ # clustered? -> true or false
451
+ #
452
+ # Returns +true+ if the table is part of a
453
+ # cluster[http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/schema.htm#CNCPT608].
454
+ # Otherwise, +false+.
583
455
  def clustered?
584
- __boolean(OCI_ATTR_CLUSTERED)
456
+ attr_get_ub1(OCI_ATTR_CLUSTERED) != 0
585
457
  end
586
458
 
587
- # indicates the table is partitioned.
459
+ # call-seq:
460
+ # partitioned? -> true or false
461
+ #
462
+ # Returns +true+ if the table is a
463
+ # {partitioned table}[http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/partconc.htm#i449863].
464
+ # Otherwise, +false+.
588
465
  def partitioned?
589
- __boolean(OCI_ATTR_PARTITIONED)
466
+ attr_get_ub1(OCI_ATTR_PARTITIONED) != 0
590
467
  end
591
468
 
592
- # indicates the table is index-only.
469
+ # call-seq:
470
+ # index_only? -> true or false
471
+ #
472
+ # Returns +true+ if the table is an
473
+ # {index-organized table}[http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/schema.htm#i23877]
474
+ # Otherwise, +false+.
593
475
  def index_only?
594
- __boolean(OCI_ATTR_INDEX_ONLY)
476
+ attr_get_ub1(OCI_ATTR_INDEX_ONLY) != 0
595
477
  end
596
478
 
597
- # array of Column objects in a table.
479
+ # call-seq:
480
+ # columns -> list of column information
481
+ #
482
+ # Returns an array of OCI8::Metadata::Column of the table.
598
483
  def columns
599
484
  @columns ||= list_columns.to_a
600
485
  end
601
486
  end
602
487
 
603
- # Metadata for a view.
488
+ # Information about views
604
489
  #
605
- # This is returned by:
490
+ # An instance of this class is returned by:
606
491
  # * OCI8#describe_any(name)
607
- # * OCI8#describe_table(name, true)
492
+ # * OCI8#describe_table(name, false)
608
493
  # * OCI8#describe_view(name)
609
494
  # * OCI8::Metadata::Schema#all_objects
610
495
  # * OCI8::Metadata::Schema#objects
@@ -617,125 +502,163 @@ class OCI8
617
502
 
618
503
  ## Table 6-2 Attributes Belonging to Tables or Views
619
504
 
620
- # number of columns
505
+ # call-seq:
506
+ # num_cols -> integer
507
+ #
508
+ # Returns number of columns
621
509
  def num_cols
622
- __ub2(OCI_ATTR_NUM_COLS)
510
+ attr_get_ub2(OCI_ATTR_NUM_COLS)
623
511
  end
624
512
 
625
513
  # column list
626
- def list_columns
514
+ def list_columns # :nodoc:
627
515
  __param(OCI_ATTR_LIST_COLUMNS)
628
516
  end
629
517
  private :list_columns
630
518
 
631
- # to type metadata if possible
632
- def type_metadata
633
- __type_metadata(OCI8::Metadata::Type)
634
- end
519
+ # This does't work for view.
520
+ #def type_metadata
521
+ # __type_metadata(OCI8::Metadata::Type)
522
+ #end
635
523
 
636
- # indicates the table is temporary.
637
- def is_temporary?
638
- __boolean(OCI_ATTR_IS_TEMPORARY)
639
- end
524
+ # This does't work for view.
525
+ #def is_temporary?
526
+ # attr_get_ub1(OCI_ATTR_IS_TEMPORARY) != 0
527
+ #end
640
528
 
641
- # indicates the table is typed.
642
- def is_typed?
643
- __boolean(OCI_ATTR_IS_TYPED)
644
- end
529
+ # This does't work for view.
530
+ #def is_typed?
531
+ # attr_get_ub1(OCI_ATTR_IS_TYPED) != 0
532
+ #end
645
533
 
646
- # Duration of a temporary table. Values can be <tt>:session</tt> or
647
- # <tt>:transaction</tt>. nil if not a temporary table.
648
- def duration
649
- __duration
650
- end
534
+ # This does't work for view.
535
+ #def duration
536
+ # __duration
537
+ #end
651
538
 
652
- # array of Column objects in a table.
539
+ # call-seq:
540
+ # columns -> list of column information
541
+ #
542
+ # Returns an array of OCI8::Metadata::Column of the table.
653
543
  def columns
654
544
  @columns ||= list_columns.to_a
655
545
  end
656
546
  end
657
547
 
658
- # Abstract super class of Procedure and Function.
548
+ # Information about PL/SQL subprograms
659
549
  #
660
- #--
661
- # How can I know whether FUNCTION or PROCEDURE?
662
- #++
663
- class ProcBase < Base
550
+ # A PL/SQL subprogram is a named PL/SQL block that can be invoked
551
+ # with a set of parameters. A subprogram can be either a procedure
552
+ # or a function.
553
+ #
554
+ # This is the abstract base class of OCI8::Metadata::Procedure and
555
+ # OCI8::Metadata::Function.
556
+ class Subprogram < Base
664
557
  ## Table 6-4 Attribute Belonging to Procedures or Functions
665
558
 
666
559
  # Argument list
667
- def list_arguments
560
+ def list_arguments # :nodoc:
668
561
  __param(OCI_ATTR_LIST_ARGUMENTS)
669
562
  end
670
563
  private :list_arguments
671
564
 
672
- # indicates the procedure or function has invoker's rights
565
+ def obj_id # :nodoc:
566
+ super if is_standalone?
567
+ end
568
+
569
+ def obj_name # :nodoc:
570
+ is_standalone? ? super : attr_get_string(OCI_ATTR_NAME)
571
+ end
572
+
573
+ def obj_schema # :nodoc:
574
+ super if is_standalone?
575
+ end
576
+
577
+ # call-seq:
578
+ # is_invoker_rights? -> true or false
579
+ #
580
+ # Returns +true+ if the subprogram has
581
+ # {invoker's rights}[http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/subprograms.htm#i18574].
582
+ # Otherwise, +false+.
673
583
  def is_invoker_rights?
674
- __boolean(OCI_ATTR_IS_INVOKER_RIGHTS)
584
+ attr_get_ub1(OCI_ATTR_IS_INVOKER_RIGHTS) != 0
675
585
  end
676
586
 
677
587
  ## Table 6-5 Attributes Specific to Package Subprograms
678
588
 
679
- # name of the procedure or function.
589
+ # name of the subprogram
680
590
  #
681
- # available only for a Package subprogram.
682
- def name
683
- __text(OCI_ATTR_NAME)
684
- end
591
+ #def name
592
+ # attr_get_string(OCI_ATTR_NAME)
593
+ #end
594
+ alias name obj_name # :nodoc: for backward compatibility
685
595
 
686
- # overloading ID number (relevant in case the procedure or
687
- # function is part of a package and is overloaded). Values
688
- # returned may be different from direct query of a PL/SQL
689
- # function or procedure. (What this means?)
596
+ # call-seq:
597
+ # overload_id -> integer or nil
690
598
  #
691
- # available only for a Package subprogram.
599
+ # Returns +nil+ for a standalone stored subprogram,
600
+ # positive integer for a
601
+ # {overloaded packaged subprogram}[http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/subprograms.htm#i12352].
602
+ # , otherwise zero.
692
603
  def overload_id
693
- __ub2(OCI_ATTR_OVERLOAD_ID)
604
+ attr_get_ub2(OCI_ATTR_OVERLOAD_ID) unless is_standalone?
694
605
  end
695
606
 
696
- # array of Argument objects.
607
+ # call-seq:
608
+ # arguments -> list of argument information
697
609
  #
698
- # The first element is the return type in case of Function.
610
+ # Returns an array of OCI8::Metadata::Argument of the subprogram.
611
+ # If it is a function, the first array element is information of its return type.
699
612
  def arguments
700
613
  @arguments ||= list_arguments.to_a
701
614
  end
702
615
 
616
+ # call-seq:
617
+ # is_standalone? -> true or false
618
+ #
619
+ # Returns +true+ if the subprogram is standalone, +false+
620
+ # if packaged.
621
+ def is_standalone?
622
+ @is_standalone = true unless defined? @is_standalone
623
+ @is_standalone
624
+ end
625
+
703
626
  def inspect # :nodoc:
704
627
  "#<#{self.class.name}: #{name}>"
705
628
  end
706
629
  end
707
630
 
708
- # Metadata for a procedure.
631
+ # Information about procedures
709
632
  #
710
- # This is returned by:
633
+ # An instance of this class is returned by:
711
634
  # * OCI8#describe_any(name)
712
635
  # * OCI8#describe_procedure(name)
713
636
  # * OCI8::Metadata::Schema#all_objects
714
637
  # * OCI8::Metadata::Schema#objects
715
638
  # * OCI8::Metadata::Package#subprograms
716
639
  #
717
- # See ProcBase's methods.
718
- class Procedure < ProcBase
640
+ # See OCI8::Metadata::Subprogram.
641
+ class Procedure < Subprogram
719
642
  register_ptype OCI_PTYPE_PROC
720
643
  end
721
644
 
722
- # Metadata for a function.
645
+ # Information about functions
723
646
  #
724
- # This is returned by:
647
+ # An instance of this class is returned by:
725
648
  # * OCI8#describe_any(name)
726
649
  # * OCI8#describe_function(name)
727
650
  # * OCI8::Metadata::Schema#all_objects
728
651
  # * OCI8::Metadata::Schema#objects
729
652
  # * OCI8::Metadata::Package#subprograms
730
653
  #
731
- # See ProcBase's methods.
732
- class Function < ProcBase
654
+ # See OCI8::Metadata::Subprogram.
655
+ class Function < Subprogram
733
656
  register_ptype OCI_PTYPE_FUNC
734
657
  end
735
658
 
736
- # Metadata for a package.
659
+ # Information about packages.
737
660
  #
738
- # This is returned by:
661
+ # An instance of this class is returned by:
739
662
  # * OCI8#describe_any(name)
740
663
  # * OCI8#describe_package(name)
741
664
  # * OCI8::Metadata::Schema#all_objects
@@ -746,25 +669,35 @@ class OCI8
746
669
  ## Table 6-6 Attributes Belonging to Packages
747
670
 
748
671
  # subprogram list
749
- def list_subprograms
672
+ def list_subprograms # :nodoc:
750
673
  __param(OCI_ATTR_LIST_SUBPROGRAMS)
751
674
  end
752
675
  private :list_subprograms
753
676
 
754
- # is the package invoker's rights?
677
+ # call-seq:
678
+ # is_invoker_rights? -> true or false
679
+ #
680
+ # Returns +true+ if the package subprograms have
681
+ # {invoker's rights}[http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/subprograms.htm#i18574].
682
+ # Otherwise, +false+.
755
683
  def is_invoker_rights?
756
- __boolean(OCI_ATTR_IS_INVOKER_RIGHTS)
684
+ attr_get_ub1(OCI_ATTR_IS_INVOKER_RIGHTS) != 0
757
685
  end
758
686
 
759
- # array of Procedure or Function objects.
687
+ # call-seq:
688
+ # subprograms -> array
689
+ #
690
+ # Returns an array of Function and Procedure defined within the Package.
760
691
  def subprograms
761
- @subprograms ||= list_subprograms.to_a
692
+ @subprograms ||= list_subprograms.to_a.each do |prog|
693
+ prog.instance_variable_set(:@is_standalone, false)
694
+ end
762
695
  end
763
696
  end
764
697
 
765
- # Metadata for a type.
698
+ # Information about types
766
699
  #
767
- # This is returned by:
700
+ # An instance of this class is returned by:
768
701
  # * OCI8#describe_any(name)
769
702
  # * OCI8#describe_type(name)
770
703
  # * OCI8::Metadata::Schema#all_objects
@@ -779,139 +712,250 @@ class OCI8
779
712
  self
780
713
  end
781
714
 
782
- # typecode. :object or :named_collection
715
+ # call-seq:
716
+ # typecode -> :named_type or :named_collection
717
+ #
718
+ # Returns +:named_type+ if the type is an object type,
719
+ # +:named_collection+ if it is a nested table or a varray.
783
720
  def typecode
784
721
  __typecode(OCI_ATTR_TYPECODE)
785
722
  end
786
723
 
787
- # typecode of collection if type is collection. nil if otherwise.
724
+ # call-seq:
725
+ # collection_typecode -> :table, :varray or nil
726
+ #
727
+ # Returns +:table+ if the type is a nested table,
728
+ # +:varray+ if it is a varray. Otherwise, +nil+.
788
729
  def collection_typecode
789
730
  __typecode(OCI_ATTR_COLLECTION_TYPECODE) if typecode == :named_collection
790
731
  end
791
732
 
792
- # indicates this is an incomplete type
733
+ # call-seq:
734
+ # is_incomplete_type? -> boolean
735
+ #
736
+ # Returns +true+ if the type is an
737
+ # {incomplete type}[http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjmng.htm#i1003083],
738
+ # which is used for {forward declaration}[http://en.wikipedia.org/wiki/Forward_declaration].
739
+ # Otherwise, +false+.
793
740
  def is_incomplete_type?
794
- __boolean(OCI_ATTR_IS_INCOMPLETE_TYPE)
741
+ attr_get_ub1(OCI_ATTR_IS_INCOMPLETE_TYPE) != 0
795
742
  end
796
743
 
797
- # indicates this is a system type
798
- def is_system_type?
799
- __boolean(OCI_ATTR_IS_SYSTEM_TYPE)
744
+ # call-seq:
745
+ # is_system_type? -> boolean
746
+ #
747
+ # Always returns +false+ because there is no way to create
748
+ # a type metadata object for a system type such as +NUMBER+,
749
+ # +CHAR+ and +VARCHAR+.
750
+ def is_system_type? # :nodoc:
751
+ attr_get_ub1(OCI_ATTR_IS_SYSTEM_TYPE) != 0
800
752
  end
801
753
 
802
- # indicates this is a predefined type
803
- def is_predefined_type?
804
- __boolean(OCI_ATTR_IS_PREDEFINED_TYPE)
754
+ # call-seq:
755
+ # is_predefined_type? -> boolean
756
+ #
757
+ # Always returns +false+.
758
+ #--
759
+ # I don't know the definition of predefined type...
760
+ def is_predefined_type? # :nodoc:
761
+ attr_get_ub1(OCI_ATTR_IS_PREDEFINED_TYPE) != 0
805
762
  end
806
763
 
807
- # indicates this is a transient type
808
- def is_transient_type?
809
- __boolean(OCI_ATTR_IS_TRANSIENT_TYPE)
764
+ # call-seq:
765
+ # is_transient_type? -> boolean
766
+ #
767
+ # Always returns +false+ because there is no way to create
768
+ # a type metadata object for a transient type, which is a type
769
+ # dynamically created by C API.
770
+ def is_transient_type? # :nodoc:
771
+ attr_get_ub1(OCI_ATTR_IS_TRANSIENT_TYPE) != 0
810
772
  end
811
773
 
812
- # indicates this is a system-generated type
813
- def is_system_generated_type?
814
- __boolean(OCI_ATTR_IS_SYSTEM_GENERATED_TYPE)
774
+ # call-seq:
775
+ # is_predefined_type? -> boolean
776
+ #
777
+ # Always returns +false+.
778
+ #--
779
+ # I don't know the definition of system generated type.
780
+ # What is different with system type and predefined type.
781
+ def is_system_generated_type? # :nodoc:
782
+ attr_get_ub1(OCI_ATTR_IS_SYSTEM_GENERATED_TYPE) != 0
815
783
  end
816
784
 
817
- # indicates this type contains a nested table attribute.
785
+ # call-seq:
786
+ # has_nested_table? -> boolean
787
+ #
788
+ # Returns +true+ if the type is a nested table or
789
+ # has a nested table attribute.
790
+ # Otherwise, +false+.
818
791
  def has_nested_table?
819
- __boolean(OCI_ATTR_HAS_NESTED_TABLE)
792
+ attr_get_ub1(OCI_ATTR_HAS_NESTED_TABLE) != 0
820
793
  end
821
794
 
822
- # indicates this type contains a LOB attribute
795
+ # call-seq:
796
+ # has_lob? -> boolean
797
+ #
798
+ # Returns +true+ if the type has a CLOB, NCLOB or BLOB
799
+ # attribute.
800
+ # Otherwise, +false+.
823
801
  def has_lob?
824
- __boolean(OCI_ATTR_HAS_LOB)
802
+ attr_get_ub1(OCI_ATTR_HAS_LOB) != 0
825
803
  end
826
804
 
827
- # indicates this type contains a BFILE attribute
805
+ # call-seq:
806
+ # has_file? -> boolean
807
+ #
808
+ # Returns +true+ if the type has a BFILE attribute.
809
+ # Otherwise, +false+.
828
810
  def has_file?
829
- __boolean(OCI_ATTR_HAS_FILE)
811
+ attr_get_ub1(OCI_ATTR_HAS_FILE) != 0
830
812
  end
831
813
 
832
- # returns OCI8::Metadata::Collection if type is collection. nil if otherwise.
814
+ # call-seq:
815
+ # collection_element -> element information of the collection type
816
+ #
817
+ # Returns an OCI8::Metadata::Collection if the type is a nested
818
+ # table or a varray.
819
+ # Otherwise, +nil+.
833
820
  def collection_element
834
821
  __param(OCI_ATTR_COLLECTION_ELEMENT) if typecode == :named_collection
835
822
  end
836
823
 
837
- # number of type attributes
824
+ # call-seq:
825
+ # num_type_attrs -> integer
826
+ #
827
+ # Returns number of type attributes.
838
828
  def num_type_attrs
839
- __ub2(OCI_ATTR_NUM_TYPE_ATTRS)
829
+ attr_get_ub2(OCI_ATTR_NUM_TYPE_ATTRS)
840
830
  end
841
831
 
842
832
  # list of type attributes
843
- def list_type_attrs
833
+ def list_type_attrs # :nodoc:
844
834
  __param(OCI_ATTR_LIST_TYPE_ATTRS)
845
835
  end
846
836
  private :list_type_attrs
847
837
 
848
- # number of type methods
838
+ # call-seq:
839
+ # num_type_methods -> integer
840
+ #
841
+ # Returns number of type methods.
849
842
  def num_type_methods
850
- __ub2(OCI_ATTR_NUM_TYPE_METHODS)
843
+ attr_get_ub2(OCI_ATTR_NUM_TYPE_METHODS)
851
844
  end
852
845
 
853
846
  # list of type methods
854
- def list_type_methods
847
+ def list_type_methods # :nodoc:
855
848
  __param(OCI_ATTR_LIST_TYPE_METHODS)
856
849
  end
857
850
  private :list_type_methods
858
851
 
859
- # map method of type
852
+ # call-seq:
853
+ # map_method -> map method information
854
+ #
855
+ # Returns an instance of OCI8::Metadata::TypeMethod of a
856
+ # {map method}[http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjbas.htm#sthref180]
857
+ # if it is defined in the type. Otherwise, +nil+.
860
858
  def map_method
861
859
  __param(OCI_ATTR_MAP_METHOD)
862
860
  end
863
861
 
864
- # order method of type
862
+ # call-seq:
863
+ # order_method -> order method information
864
+ #
865
+ # Returns an instance of OCI8::Metadata::TypeMethod of a
866
+ # {order method}[http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjbas.htm#sthref185]
867
+ # if it is defined in the type. Otherwise, +nil+.
865
868
  def order_method
866
869
  __param(OCI_ATTR_ORDER_METHOD)
867
870
  end
868
871
 
869
- # indicates the type has invoker's rights
872
+ # call-seq:
873
+ # is_invoker_rights? -> boolean
874
+ #
875
+ # Returns +true+ if the type has
876
+ # {invoker's rights}[http://download.oracle.com/docs/cd/B28359_01/appdev.111/appdev.111/b28371/adobjdes.htm#ADOBJ00810].
877
+ # Otherwise, +false+.
870
878
  def is_invoker_rights?
871
- __boolean(OCI_ATTR_IS_INVOKER_RIGHTS)
879
+ attr_get_ub1(OCI_ATTR_IS_INVOKER_RIGHTS) != 0
872
880
  end
873
881
 
874
- # type name
882
+ # call-seq:
883
+ # name -> string
884
+ #
885
+ # Returns the type name.
875
886
  def name
876
- __text(OCI_ATTR_NAME)
887
+ attr_get_string(OCI_ATTR_NAME)
877
888
  end
878
889
 
879
- # schema name where the type has been created
890
+ # call-seq:
891
+ # schema_name -> string
892
+ #
893
+ # Returns the schema name where the type has been created.
880
894
  def schema_name
881
- __text(OCI_ATTR_SCHEMA_NAME)
895
+ attr_get_string(OCI_ATTR_SCHEMA_NAME)
882
896
  end
883
897
 
884
- # indicates this is a final type
898
+ # call-seq:
899
+ # is_final_type? -> boolean
900
+ #
901
+ # Returns +true+ if the type is a
902
+ # {final type}[http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjbas.htm#CIHFBHFC];
903
+ # in other words, subtypes cannot be derived from the type.
904
+ # Otherwise, +false+.
885
905
  def is_final_type?
886
- __boolean(OCI_ATTR_IS_FINAL_TYPE)
906
+ attr_get_ub1(OCI_ATTR_IS_FINAL_TYPE) != 0
887
907
  end
888
908
 
889
- # indicates this is an instantiable type
909
+ # call-seq:
910
+ # is_instantiable_type? -> boolean
911
+ #
912
+ # Returns +true+ if the type is not declared without
913
+ # {<tt>NOT INSTANTIABLE</tt>}[http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjbas.htm#i456586].
914
+ # Otherwise, +false+.
890
915
  def is_instantiable_type?
891
- __boolean(OCI_ATTR_IS_INSTANTIABLE_TYPE)
916
+ attr_get_ub1(OCI_ATTR_IS_INSTANTIABLE_TYPE) != 0
892
917
  end
893
918
 
894
- # indicates this is a subtype
919
+ # call-seq:
920
+ # is_subtype? -> boolean
921
+ #
922
+ # Returns +true+ if the type is a
923
+ # {subtype}[http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjbas.htm#BCFJJADG].
924
+ # Otherwise, +false+.
895
925
  def is_subtype?
896
- __boolean(OCI_ATTR_IS_SUBTYPE)
926
+ attr_get_ub1(OCI_ATTR_IS_SUBTYPE) != 0
897
927
  end
898
928
 
899
- # supertype's schema name
929
+ # call-seq:
930
+ # supertype_schema_name -> string or nil
931
+ #
932
+ # Returns the supertype's schema name if the type is a subtype.
933
+ # Otherwise, +nil+.
900
934
  def supertype_schema_name
901
- __text(OCI_ATTR_SUPERTYPE_SCHEMA_NAME) if is_subtype?
935
+ attr_get_string(OCI_ATTR_SUPERTYPE_SCHEMA_NAME) if is_subtype?
902
936
  end
903
937
 
904
- # supertype's name
938
+ # call-seq:
939
+ # supertype_name -> string or nil
940
+ #
941
+ # Returns the supertype's name if the type is a subtype.
942
+ # Otherwise, +nil+.
905
943
  def supertype_name
906
- __text(OCI_ATTR_SUPERTYPE_NAME) if is_subtype?
944
+ attr_get_string(OCI_ATTR_SUPERTYPE_NAME) if is_subtype?
907
945
  end
908
946
 
909
- # array of TypeAttr objects.
947
+ # call-seq:
948
+ # type_attrs -> list of attribute information
949
+ #
950
+ # Returns an array of OCI8::Metadata::TypeAttr which the type has.
910
951
  def type_attrs
911
952
  @type_attrs ||= list_type_attrs.to_a
912
953
  end
913
954
 
914
- # array of TypeMethod objects.
955
+ # call-seq:
956
+ # type_methods -> list of method information
957
+ #
958
+ # Returns an array of OCI8::Metadata::TypeMethod which the type has.
915
959
  def type_methods
916
960
  @type_methods ||= list_type_methods.to_a
917
961
  end
@@ -934,7 +978,7 @@ class OCI8
934
978
  # returned in bytes and not characters for strings and raws. It
935
979
  # returns 22 for NUMBERs.
936
980
  def data_size
937
- __ub2_nc(OCI_ATTR_DATA_SIZE)
981
+ attr_get_ub2(OCI_ATTR_DATA_SIZE)
938
982
  end
939
983
 
940
984
  # typecode
@@ -949,7 +993,7 @@ class OCI8
949
993
 
950
994
  # the type attribute name
951
995
  def name
952
- __text(OCI_ATTR_NAME)
996
+ attr_get_string(OCI_ATTR_NAME)
953
997
  end
954
998
 
955
999
  # The precision of numeric type attributes. If the precision is
@@ -957,7 +1001,7 @@ class OCI8
957
1001
  # NUMBER(precision, scale). For the case when precision is 0,
958
1002
  # NUMBER(precision, scale) can be represented simply as NUMBER.
959
1003
  def precision
960
- __is_implicit? ? __sb2(OCI_ATTR_PRECISION) : __ub1(OCI_ATTR_PRECISION)
1004
+ __is_implicit? ? attr_get_sb2(OCI_ATTR_PRECISION) : attr_get_ub1(OCI_ATTR_PRECISION)
961
1005
  end
962
1006
 
963
1007
  # The scale of numeric type attributes. If the precision is
@@ -965,7 +1009,7 @@ class OCI8
965
1009
  # NUMBER(precision, scale). For the case when precision is 0,
966
1010
  # NUMBER(precision, scale) can be represented simply as NUMBER.
967
1011
  def scale
968
- __sb1(OCI_ATTR_SCALE)
1012
+ attr_get_sb1(OCI_ATTR_SCALE)
969
1013
  end
970
1014
 
971
1015
  # A string which is the type name. The returned value will
@@ -975,12 +1019,12 @@ class OCI8
975
1019
  # is <tt>:ref</tt>, the type name of the named datatype pointed
976
1020
  # to by the REF is returned.
977
1021
  def type_name
978
- __text(OCI_ATTR_TYPE_NAME)
1022
+ attr_get_string(OCI_ATTR_TYPE_NAME)
979
1023
  end
980
1024
 
981
1025
  # schema name where the type has been created.
982
1026
  def schema_name
983
- __text(OCI_ATTR_SCHEMA_NAME)
1027
+ attr_get_string(OCI_ATTR_SCHEMA_NAME)
984
1028
  end
985
1029
 
986
1030
  # to type metadata if possible
@@ -990,7 +1034,7 @@ class OCI8
990
1034
 
991
1035
  # character set id if the type attribute is of a string/character type.
992
1036
  def charset_id
993
- __ub2(OCI_ATTR_CHARSET_ID)
1037
+ attr_get_ub2(OCI_ATTR_CHARSET_ID)
994
1038
  end
995
1039
 
996
1040
  # character set form, if the type attribute is of a string/character type.
@@ -1003,24 +1047,24 @@ class OCI8
1003
1047
  #
1004
1048
  # (unavailable on Oracle 8.1 or lower)
1005
1049
  def fsprecision
1006
- __ub1(OCI_ATTR_FSPRECISION)
1050
+ attr_get_ub1(OCI_ATTR_FSPRECISION)
1007
1051
  end
1008
1052
 
1009
1053
  # The leading field precision of an interval
1010
1054
  #
1011
1055
  # (unavailable on Oracle 8.1 or lower)
1012
1056
  def lfprecision
1013
- __ub1(OCI_ATTR_LFPRECISION)
1057
+ attr_get_ub1(OCI_ATTR_LFPRECISION)
1014
1058
  end
1015
1059
  end
1016
1060
 
1017
1061
  # character set name if the type attribute is of a string/character type.
1018
1062
  def charset_name
1019
- __charset_name(charset_id)
1063
+ __con.charset_id2name(charset_id)
1020
1064
  end
1021
1065
 
1022
1066
  def inspect # :nodoc:
1023
- "#<#{self.class.name}: #{name} #{__type_string}>"
1067
+ "#<#{self.class.name}: #{name} #{__data_type_string}>"
1024
1068
  end
1025
1069
  end
1026
1070
 
@@ -1041,13 +1085,13 @@ class OCI8
1041
1085
 
1042
1086
  # Name of method (procedure or function)
1043
1087
  def name
1044
- __text(OCI_ATTR_NAME)
1088
+ attr_get_string(OCI_ATTR_NAME)
1045
1089
  end
1046
1090
 
1047
1091
  # encapsulation level of the method. Values are <tt>:public</tt>
1048
1092
  # or <tt>:private</tt>.
1049
1093
  def encapsulation
1050
- case __ub4(OCI_ATTR_ENCAPSULATION)
1094
+ case attr_get_ub4(OCI_ATTR_ENCAPSULATION)
1051
1095
  when 0; :private
1052
1096
  when 1; :public
1053
1097
  end
@@ -1154,7 +1198,7 @@ class OCI8
1154
1198
  # returned in bytes and not characters for strings and raws. It
1155
1199
  # returns 22 for NUMBERs.
1156
1200
  def data_size
1157
- __ub2_nc(OCI_ATTR_DATA_SIZE)
1201
+ attr_get_ub2(OCI_ATTR_DATA_SIZE)
1158
1202
  end
1159
1203
 
1160
1204
  # typecode
@@ -1170,7 +1214,7 @@ class OCI8
1170
1214
  # the number of elements in an array. It is only valid for
1171
1215
  # collections that are arrays.
1172
1216
  def num_elems
1173
- __ub4(OCI_ATTR_NUM_ELEMS)
1217
+ attr_get_ub4(OCI_ATTR_NUM_ELEMS)
1174
1218
  end
1175
1219
 
1176
1220
  # The precision of numeric type attributes. If the precision is
@@ -1178,7 +1222,7 @@ class OCI8
1178
1222
  # NUMBER(precision, scale). For the case when precision is 0,
1179
1223
  # NUMBER(precision, scale) can be represented simply as NUMBER.
1180
1224
  def precision
1181
- __is_implicit? ? __sb2(OCI_ATTR_PRECISION) : __ub1(OCI_ATTR_PRECISION)
1225
+ __is_implicit? ? attr_get_sb2(OCI_ATTR_PRECISION) : attr_get_ub1(OCI_ATTR_PRECISION)
1182
1226
  end
1183
1227
 
1184
1228
  # The scale of numeric type attributes. If the precision is
@@ -1186,7 +1230,7 @@ class OCI8
1186
1230
  # NUMBER(precision, scale). For the case when precision is 0,
1187
1231
  # NUMBER(precision, scale) can be represented simply as NUMBER.
1188
1232
  def scale
1189
- __sb1(OCI_ATTR_SCALE)
1233
+ attr_get_sb1(OCI_ATTR_SCALE)
1190
1234
  end
1191
1235
 
1192
1236
  # A string which is the type name. The returned value will
@@ -1195,12 +1239,12 @@ class OCI8
1195
1239
  # type is returned. If the datatype is <tt>:ref</tt>, the type name
1196
1240
  # of the named datatype pointed to by the REF is returned.
1197
1241
  def type_name
1198
- __text(OCI_ATTR_TYPE_NAME)
1242
+ attr_get_string(OCI_ATTR_TYPE_NAME)
1199
1243
  end
1200
1244
 
1201
1245
  # schema name where the type has been created.
1202
1246
  def schema_name
1203
- __text(OCI_ATTR_SCHEMA_NAME)
1247
+ attr_get_string(OCI_ATTR_SCHEMA_NAME)
1204
1248
  end
1205
1249
 
1206
1250
  # to type metadata if possible
@@ -1210,7 +1254,7 @@ class OCI8
1210
1254
 
1211
1255
  # character set id if the type attribute is of a string/character type.
1212
1256
  def charset_id
1213
- __ub2(OCI_ATTR_CHARSET_ID)
1257
+ attr_get_ub2(OCI_ATTR_CHARSET_ID)
1214
1258
  end
1215
1259
 
1216
1260
  # character set form, if the type attribute is of a string/character type.
@@ -1224,7 +1268,7 @@ class OCI8
1224
1268
  end
1225
1269
 
1226
1270
  def inspect # :nodoc:
1227
- "#<#{self.class.name}: #{__type_string}>"
1271
+ "#<#{self.class.name}: #{__data_type_string}>"
1228
1272
  end
1229
1273
  end
1230
1274
 
@@ -1242,22 +1286,22 @@ class OCI8
1242
1286
 
1243
1287
  # object id
1244
1288
  def objid
1245
- @objid ||= __ub4(OCI_ATTR_OBJID)
1289
+ @objid ||= attr_get_ub4(OCI_ATTR_OBJID)
1246
1290
  end
1247
1291
 
1248
1292
  # schema name of the synonym translation
1249
1293
  def schema_name
1250
- @schema_name ||= __text(OCI_ATTR_SCHEMA_NAME)
1294
+ @schema_name ||= attr_get_string(OCI_ATTR_SCHEMA_NAME)
1251
1295
  end
1252
1296
 
1253
1297
  # object name of the synonym translation
1254
1298
  def name
1255
- @name ||= __text(OCI_ATTR_NAME)
1299
+ @name ||= attr_get_string(OCI_ATTR_NAME)
1256
1300
  end
1257
1301
 
1258
1302
  # database link name of the synonym translation or nil
1259
1303
  def link
1260
- @link ||= __text(OCI_ATTR_LINK)
1304
+ @link ||= attr_get_string(OCI_ATTR_LINK)
1261
1305
  @link.size == 0 ? nil : @link
1262
1306
  end
1263
1307
 
@@ -1289,7 +1333,7 @@ class OCI8
1289
1333
 
1290
1334
  # object id
1291
1335
  def objid
1292
- __ub4(OCI_ATTR_OBJID)
1336
+ attr_get_ub4(OCI_ATTR_OBJID)
1293
1337
  end
1294
1338
 
1295
1339
  # minimum value
@@ -1339,14 +1383,14 @@ class OCI8
1339
1383
  #
1340
1384
  # (unavailable on Oracle 8.1 or lower)
1341
1385
  def char_used?
1342
- __ub4(OCI_ATTR_CHAR_USED) != 0
1386
+ attr_get_ub1(OCI_ATTR_CHAR_USED) != 0
1343
1387
  end
1344
1388
 
1345
1389
  # returns the column character length which is the number of
1346
1390
  # characters allowed in the column. It is the counterpart of
1347
1391
  # OCI8::Metadata::Column#data_size which gets the byte length.
1348
1392
  def char_size
1349
- __ub2(OCI_ATTR_CHAR_SIZE)
1393
+ attr_get_ub2(OCI_ATTR_CHAR_SIZE)
1350
1394
  end
1351
1395
  else
1352
1396
  def char_used?
@@ -1364,7 +1408,7 @@ class OCI8
1364
1408
  # character-length semantics columns when using Oracle 9i
1365
1409
  # or upper.
1366
1410
  def data_size
1367
- __ub2_nc(OCI_ATTR_DATA_SIZE)
1411
+ attr_get_ub2(OCI_ATTR_DATA_SIZE)
1368
1412
  end
1369
1413
 
1370
1414
  # the datatype of the column.
@@ -1374,7 +1418,7 @@ class OCI8
1374
1418
 
1375
1419
  # column name
1376
1420
  def name
1377
- __text(OCI_ATTR_NAME)
1421
+ attr_get_string(OCI_ATTR_NAME)
1378
1422
  end
1379
1423
 
1380
1424
  # The precision of numeric columns. If the precision is nonzero
@@ -1382,7 +1426,7 @@ class OCI8
1382
1426
  # NUMBER(precision, scale). For the case when precision is 0,
1383
1427
  # NUMBER(precision, scale) can be represented simply as NUMBER.
1384
1428
  def precision
1385
- __is_implicit? ? __sb2(OCI_ATTR_PRECISION) : __ub1(OCI_ATTR_PRECISION)
1429
+ __is_implicit? ? attr_get_sb2(OCI_ATTR_PRECISION) : attr_get_ub1(OCI_ATTR_PRECISION)
1386
1430
  end
1387
1431
 
1388
1432
  # The scale of numeric columns. If the precision is nonzero and
@@ -1390,7 +1434,7 @@ class OCI8
1390
1434
  # NUMBER(precision, scale). For the case when precision is 0,
1391
1435
  # NUMBER(precision, scale) can be represented simply as NUMBER.
1392
1436
  def scale
1393
- __sb1(OCI_ATTR_SCALE)
1437
+ attr_get_sb1(OCI_ATTR_SCALE)
1394
1438
  end
1395
1439
 
1396
1440
  # Returns 0 if null values are not permitted for the column
@@ -1405,19 +1449,19 @@ class OCI8
1405
1449
  # type name of the named datatype pointed to by the REF is
1406
1450
  # returned
1407
1451
  def type_name
1408
- rv = __text(OCI_ATTR_TYPE_NAME)
1452
+ rv = attr_get_string(OCI_ATTR_TYPE_NAME)
1409
1453
  rv.length == 0 ? nil : rv
1410
1454
  end
1411
1455
 
1412
1456
  # Returns a string with the schema name under which the type has been created
1413
1457
  def schema_name
1414
- rv = __text(OCI_ATTR_SCHEMA_NAME)
1458
+ rv = attr_get_string(OCI_ATTR_SCHEMA_NAME)
1415
1459
  rv.length == 0 ? nil : rv
1416
1460
  end
1417
1461
 
1418
1462
  # to type metadata if possible
1419
1463
  def type_metadata
1420
- case __ub2(OCI_ATTR_DATA_TYPE)
1464
+ case attr_get_ub2(OCI_ATTR_DATA_TYPE)
1421
1465
  when 108, 110 # named_type or ref
1422
1466
  __type_metadata(OCI8::Metadata::Type)
1423
1467
  else
@@ -1427,7 +1471,7 @@ class OCI8
1427
1471
 
1428
1472
  # The character set id, if the column is of a string/character type
1429
1473
  def charset_id
1430
- __ub2(OCI_ATTR_CHARSET_ID)
1474
+ attr_get_ub2(OCI_ATTR_CHARSET_ID)
1431
1475
  end
1432
1476
 
1433
1477
  # The character set form, if the column is of a string/character type
@@ -1443,14 +1487,14 @@ class OCI8
1443
1487
  #
1444
1488
  # (unavailable on Oracle 8.1 or lower)
1445
1489
  def fsprecision
1446
- __ub1(OCI_ATTR_FSPRECISION)
1490
+ attr_get_ub1(OCI_ATTR_FSPRECISION)
1447
1491
  end
1448
1492
 
1449
1493
  # The leading field precision of an interval
1450
1494
  #
1451
1495
  # (unavailable on Oracle 8.1 or lower)
1452
1496
  def lfprecision
1453
- __ub1(OCI_ATTR_LFPRECISION)
1497
+ attr_get_ub1(OCI_ATTR_LFPRECISION)
1454
1498
  end
1455
1499
  end
1456
1500
 
@@ -1459,16 +1503,17 @@ class OCI8
1459
1503
  __charset_name(charset_id)
1460
1504
  end
1461
1505
 
1462
- def type_string
1463
- __type_string
1506
+ def data_type_string
1507
+ __data_type_string
1464
1508
  end
1509
+ alias :type_string :data_type_string # :nodoc: old name of data_type_string
1465
1510
 
1466
1511
  def to_s
1467
- %Q{"#{name}" #{__type_string}}
1512
+ %Q{"#{name}" #{__data_type_string}}
1468
1513
  end
1469
1514
 
1470
1515
  def inspect # :nodoc:
1471
- "#<#{self.class.name}: #{name} #{__type_string}>"
1516
+ "#<#{self.class.name}: #{name} #{__data_type_string}>"
1472
1517
  end
1473
1518
  end
1474
1519
 
@@ -1478,12 +1523,12 @@ class OCI8
1478
1523
 
1479
1524
  # the argument name
1480
1525
  def name
1481
- __text(OCI_ATTR_NAME)
1526
+ attr_get_string(OCI_ATTR_NAME)
1482
1527
  end
1483
1528
 
1484
1529
  # the position of the argument in the argument list.
1485
1530
  def position
1486
- __ub2(OCI_ATTR_POSITION)
1531
+ attr_get_ub2(OCI_ATTR_POSITION)
1487
1532
  end
1488
1533
 
1489
1534
  # typecode
@@ -1500,7 +1545,7 @@ class OCI8
1500
1545
  # returned in bytes and not characters for strings and raws. It
1501
1546
  # returns 22 for NUMBERs.
1502
1547
  def data_size
1503
- __ub2_nc(OCI_ATTR_DATA_SIZE)
1548
+ attr_get_ub2(OCI_ATTR_DATA_SIZE)
1504
1549
  end
1505
1550
 
1506
1551
  # The precision of numeric arguments. If the precision is
@@ -1508,7 +1553,7 @@ class OCI8
1508
1553
  # NUMBER(precision, scale). For the case when precision is 0,
1509
1554
  # NUMBER(precision, scale) can be represented simply as NUMBER.
1510
1555
  def precision
1511
- __is_implicit? ? __sb2(OCI_ATTR_PRECISION) : __ub1(OCI_ATTR_PRECISION)
1556
+ __is_implicit? ? attr_get_sb2(OCI_ATTR_PRECISION) : attr_get_ub1(OCI_ATTR_PRECISION)
1512
1557
  end
1513
1558
 
1514
1559
  # The scale of numeric arguments. If the precision is nonzero
@@ -1516,17 +1561,17 @@ class OCI8
1516
1561
  # NUMBER(precision, scale). For the case when precision is 0,
1517
1562
  # NUMBER(precision, scale) can be represented simply as NUMBER.
1518
1563
  def scale
1519
- __sb1(OCI_ATTR_SCALE)
1564
+ attr_get_sb1(OCI_ATTR_SCALE)
1520
1565
  end
1521
1566
 
1522
1567
  # The datatype levels. This attribute always returns zero.
1523
1568
  def level
1524
- __ub2(OCI_ATTR_LEVEL)
1569
+ attr_get_ub2(OCI_ATTR_LEVEL)
1525
1570
  end
1526
1571
 
1527
1572
  # Indicates whether an argument has a default
1528
1573
  def has_default
1529
- __ub1(OCI_ATTR_HAS_DEFAULT)
1574
+ attr_get_ub1(OCI_ATTR_HAS_DEFAULT)
1530
1575
  end
1531
1576
 
1532
1577
  # The list of arguments at the next level (when the argument is
@@ -1539,7 +1584,7 @@ class OCI8
1539
1584
  # Indicates the argument mode. Values are <tt>:in</tt>,
1540
1585
  # <tt>:out</tt> or <tt>:inout</tt>
1541
1586
  def iomode
1542
- case __ub4(OCI_ATTR_IOMODE)
1587
+ case attr_get_ub4(OCI_ATTR_IOMODE)
1543
1588
  when 0; :in
1544
1589
  when 1; :out
1545
1590
  when 2; :inout
@@ -1548,7 +1593,7 @@ class OCI8
1548
1593
 
1549
1594
  # Returns a radix (if number type)
1550
1595
  def radix
1551
- __ub1(OCI_ATTR_RADIX)
1596
+ attr_get_ub1(OCI_ATTR_RADIX)
1552
1597
  end
1553
1598
 
1554
1599
  # doesn't work.
@@ -1563,20 +1608,20 @@ class OCI8
1563
1608
  # datatype's type is returned. If the datatype is <tt>:ref</tt>, the type
1564
1609
  # name of the named datatype pointed to by the REF is returned.
1565
1610
  def type_name
1566
- __text(OCI_ATTR_TYPE_NAME)
1611
+ attr_get_string(OCI_ATTR_TYPE_NAME)
1567
1612
  end
1568
1613
 
1569
1614
  # For <tt>:named_type</tt> or <tt>:ref</tt>, returns a string with the schema name
1570
1615
  # under which the type was created, or under which the package
1571
1616
  # was created in the case of package local types
1572
1617
  def schema_name
1573
- __text(OCI_ATTR_SCHEMA_NAME)
1618
+ attr_get_string(OCI_ATTR_SCHEMA_NAME)
1574
1619
  end
1575
1620
 
1576
1621
  # For <tt>:named_type</tt> or <tt>:ref</tt>, returns a string with the type name,
1577
1622
  # in the case of package local types
1578
1623
  def sub_name
1579
- __text(OCI_ATTR_SUB_NAME)
1624
+ attr_get_string(OCI_ATTR_SUB_NAME)
1580
1625
  end
1581
1626
 
1582
1627
  # For <tt>:named_type</tt> or <tt>:ref</tt>, returns a string with the database
@@ -1584,7 +1629,7 @@ class OCI8
1584
1629
  # happen only in the case of package local types, when the
1585
1630
  # package is remote.
1586
1631
  def link
1587
- __text(OCI_ATTR_LINK)
1632
+ attr_get_string(OCI_ATTR_LINK)
1588
1633
  end
1589
1634
 
1590
1635
  # to type metadata if possible
@@ -1595,7 +1640,7 @@ class OCI8
1595
1640
  # Returns the character set ID if the argument is of a
1596
1641
  # string/character type
1597
1642
  def charset_id
1598
- __ub2(OCI_ATTR_CHARSET_ID)
1643
+ attr_get_ub2(OCI_ATTR_CHARSET_ID)
1599
1644
  end
1600
1645
 
1601
1646
  # Returns the character set form if the argument is of a
@@ -1617,7 +1662,7 @@ class OCI8
1617
1662
  end
1618
1663
 
1619
1664
  def inspect # :nodoc:
1620
- "#<#{self.class.name}: #{name} #{__type_string}>"
1665
+ "#<#{self.class.name}: #{name} #{__data_type_string}>"
1621
1666
  end
1622
1667
  end
1623
1668
 
@@ -1664,7 +1709,7 @@ class OCI8
1664
1709
  end
1665
1710
  else
1666
1711
  def ltype
1667
- __ub2(OCI_ATTR_LTYPE)
1712
+ attr_get_ub2(OCI_ATTR_LTYPE)
1668
1713
  end
1669
1714
  end
1670
1715
 
@@ -1715,41 +1760,51 @@ class OCI8
1715
1760
  # array of objects in the schema.
1716
1761
  # This includes unusable objects.
1717
1762
  def all_objects
1718
- unless @all_objects
1763
+ @all_objects ||=
1719
1764
  begin
1720
- objs = list_objects
1721
- rescue OCIError => exc
1722
- if exc.code != -1
1723
- raise
1765
+ begin
1766
+ objs = list_objects
1767
+ rescue OCIError => exc
1768
+ if exc.code != -1
1769
+ raise
1770
+ end
1771
+ # describe again.
1772
+ objs = __con.describe_schema(obj_schema).list_objects
1724
1773
  end
1725
- # describe again.
1726
- objs = __con.describe_schema(obj_schema).list_objects
1774
+ objs.to_a.collect! do |elem|
1775
+ case elem
1776
+ when OCI8::Metadata::Type
1777
+ # to avoid a segmentation fault
1778
+ begin
1779
+ __con.describe_type(elem.obj_schema + '.' + elem.obj_name)
1780
+ rescue OCIError
1781
+ # ignore ORA-24372: invalid object for describe
1782
+ raise if $!.code != 24372
1783
+ end
1784
+ else
1785
+ elem
1786
+ end
1787
+ end.compact
1727
1788
  end
1728
- @all_objects = objs.to_a
1729
- end
1730
- @all_objects
1731
1789
  end
1732
1790
 
1733
1791
  # array of objects in the schema.
1734
1792
  def objects
1735
- unless @objects
1736
- @objects = all_objects.dup.reject! do |obj|
1737
- case obj
1738
- when Unknown
1739
- true
1740
- when Synonym
1741
- begin
1742
- obj.objid
1743
- false
1744
- rescue OCIError
1745
- true
1746
- end
1747
- else
1793
+ @objects ||= all_objects.reject do |obj|
1794
+ case obj
1795
+ when Unknown
1796
+ true
1797
+ when Synonym
1798
+ begin
1799
+ obj.objid
1748
1800
  false
1801
+ rescue OCIError
1802
+ true
1749
1803
  end
1804
+ else
1805
+ false
1750
1806
  end
1751
1807
  end
1752
- @objects
1753
1808
  end
1754
1809
 
1755
1810
  def inspect # :nodoc:
@@ -1768,17 +1823,17 @@ class OCI8
1768
1823
 
1769
1824
  # database version
1770
1825
  def version
1771
- __text(OCI_ATTR_VERSION)
1826
+ attr_get_string(OCI_ATTR_VERSION)
1772
1827
  end
1773
1828
 
1774
1829
  # database character set Id
1775
1830
  def charset_id
1776
- __ub2(OCI_ATTR_CHARSET_ID)
1831
+ attr_get_ub2(OCI_ATTR_CHARSET_ID)
1777
1832
  end
1778
1833
 
1779
1834
  # database national language support character set Id
1780
1835
  def ncharset_id
1781
- __ub2(OCI_ATTR_NCHARSET_ID)
1836
+ attr_get_ub2(OCI_ATTR_NCHARSET_ID)
1782
1837
  end
1783
1838
 
1784
1839
  # List of schemas in the database
@@ -1789,12 +1844,12 @@ class OCI8
1789
1844
 
1790
1845
  # Maximum length of a procedure name
1791
1846
  def max_proc_len
1792
- __ub4(OCI_ATTR_MAX_PROC_LEN)
1847
+ attr_get_ub4(OCI_ATTR_MAX_PROC_LEN)
1793
1848
  end
1794
1849
 
1795
1850
  # Maximum length of a column name
1796
1851
  def max_column_len
1797
- __ub4(OCI_ATTR_MAX_COLUMN_LEN)
1852
+ attr_get_ub4(OCI_ATTR_MAX_COLUMN_LEN)
1798
1853
  end
1799
1854
 
1800
1855
  # How a COMMIT operation affects cursors and prepared statements in
@@ -1805,7 +1860,7 @@ class OCI8
1805
1860
  # application can still re-execute the
1806
1861
  # statement without re-preparing it
1807
1862
  def cursor_commit_behavior
1808
- case __ub1(OCI_ATTR_CURSOR_COMMIT_BEHAVIOR)
1863
+ case attr_get_ub1(OCI_ATTR_CURSOR_COMMIT_BEHAVIOR)
1809
1864
  when 0; :cusror_open
1810
1865
  when 1; :cursor_closed
1811
1866
  end
@@ -1813,13 +1868,13 @@ class OCI8
1813
1868
 
1814
1869
  # Maximum length of a catalog (database) name
1815
1870
  def max_catalog_namelen
1816
- __ub1(OCI_ATTR_MAX_CATALOG_NAMELEN)
1871
+ attr_get_ub1(OCI_ATTR_MAX_CATALOG_NAMELEN)
1817
1872
  end
1818
1873
 
1819
1874
  # Position of the catalog in a qualified table. Values are
1820
1875
  # <tt>:cl_start</tt> and <tt>:cl_end</tt>
1821
1876
  def catalog_location
1822
- case __ub1(OCI_ATTR_CATALOG_LOCATION)
1877
+ case attr_get_ub1(OCI_ATTR_CATALOG_LOCATION)
1823
1878
  when 0; :cl_start
1824
1879
  when 1; :cl_end
1825
1880
  end
@@ -1828,7 +1883,7 @@ class OCI8
1828
1883
  # Does database support savepoints? Values are
1829
1884
  # <tt>:sp_supported</tt> and <tt>:sp_unsupported</tt>
1830
1885
  def savepoint_support
1831
- case __ub1(OCI_ATTR_SAVEPOINT_SUPPORT)
1886
+ case attr_get_ub1(OCI_ATTR_SAVEPOINT_SUPPORT)
1832
1887
  when 0; :sp_supported
1833
1888
  when 1; :sp_unsupported
1834
1889
  end
@@ -1837,7 +1892,7 @@ class OCI8
1837
1892
  # Does database support the nowait clause? Values are
1838
1893
  # <tt>:nw_supported</tt> and <tt>:nw_unsupported</tt>
1839
1894
  def nowait_support
1840
- case __ub1(OCI_ATTR_NOWAIT_SUPPORT)
1895
+ case attr_get_ub1(OCI_ATTR_NOWAIT_SUPPORT)
1841
1896
  when 0; :nw_supported
1842
1897
  when 1; :nw_unsupported
1843
1898
  end
@@ -1846,7 +1901,7 @@ class OCI8
1846
1901
  # Is autocommit mode required for DDL statements? Values are
1847
1902
  # <tt>:ac_ddl</tt> and <tt>:no_ac_ddl</tt>
1848
1903
  def autocommit_ddl
1849
- case __ub1(OCI_ATTR_AUTOCOMMIT_DDL)
1904
+ case attr_get_ub1(OCI_ATTR_AUTOCOMMIT_DDL)
1850
1905
  when 0; :ac_ddl
1851
1906
  when 1; :no_ac_ddl
1852
1907
  end
@@ -1855,7 +1910,7 @@ class OCI8
1855
1910
  # Locking mode for the database. Values are <tt>:lock_immediate</tt> and
1856
1911
  # <tt>:lock_delayed</tt>
1857
1912
  def locking_mode
1858
- case __ub1(OCI_ATTR_LOCKING_MODE)
1913
+ case attr_get_ub1(OCI_ATTR_LOCKING_MODE)
1859
1914
  when 0; :lock_immediate
1860
1915
  when 1; :lock_delayed
1861
1916
  end
@@ -1888,19 +1943,19 @@ class OCI8
1888
1943
  # Table 6-18 Attributes Specific to Rules
1889
1944
 
1890
1945
  def condition
1891
- __text(OCI_ATTR_CONDITION)
1946
+ attr_get_string(OCI_ATTR_CONDITION)
1892
1947
  end
1893
1948
 
1894
1949
  def eval_context_owner
1895
- __text(OCI_ATTR_EVAL_CONTEXT_OWNER)
1950
+ attr_get_string(OCI_ATTR_EVAL_CONTEXT_OWNER)
1896
1951
  end
1897
1952
 
1898
1953
  def eval_context_name
1899
- __text(OCI_ATTR_EVAL_CONTEXT_NAME)
1954
+ attr_get_string(OCI_ATTR_EVAL_CONTEXT_NAME)
1900
1955
  end
1901
1956
 
1902
1957
  def comment
1903
- __text(OCI_ATTR_COMMENT)
1958
+ attr_get_string(OCI_ATTR_COMMENT)
1904
1959
  end
1905
1960
 
1906
1961
  # def list_action_context
@@ -1914,15 +1969,15 @@ class OCI8
1914
1969
  # Table 6-19 Attributes Specific to Rule Sets
1915
1970
 
1916
1971
  def eval_context_owner
1917
- __text(OCI_ATTR_EVAL_CONTEXT_OWNER)
1972
+ attr_get_string(OCI_ATTR_EVAL_CONTEXT_OWNER)
1918
1973
  end
1919
1974
 
1920
1975
  def eval_context_name
1921
- __text(OCI_ATTR_EVAL_CONTEXT_NAME)
1976
+ attr_get_string(OCI_ATTR_EVAL_CONTEXT_NAME)
1922
1977
  end
1923
1978
 
1924
1979
  def comment
1925
- __text(OCI_ATTR_COMMENT)
1980
+ attr_get_string(OCI_ATTR_COMMENT)
1926
1981
  end
1927
1982
 
1928
1983
  # def list_rules
@@ -1936,11 +1991,11 @@ class OCI8
1936
1991
  # Table 6-20 Attributes Specific to Evaluation Contexts
1937
1992
 
1938
1993
  def evaluation_function
1939
- __text(OCI_ATTR_EVALUATION_FUNCTION)
1994
+ attr_get_string(OCI_ATTR_EVALUATION_FUNCTION)
1940
1995
  end
1941
1996
 
1942
1997
  def comment
1943
- __text(OCI_ATTR_COMMENT)
1998
+ attr_get_string(OCI_ATTR_COMMENT)
1944
1999
  end
1945
2000
 
1946
2001
  def list_table_aliases
@@ -1958,11 +2013,11 @@ class OCI8
1958
2013
  # Table 6-21 Attributes Specific to Table Aliases
1959
2014
 
1960
2015
  def name
1961
- __text(OCI_ATTR_NAME)
2016
+ attr_get_string(OCI_ATTR_NAME)
1962
2017
  end
1963
2018
 
1964
2019
  def table_name
1965
- __text(OCI_ATTR_TABLE_NAME)
2020
+ attr_get_string(OCI_ATTR_TABLE_NAME)
1966
2021
  end
1967
2022
  end
1968
2023
 
@@ -1972,19 +2027,19 @@ class OCI8
1972
2027
  # Table 6-22 Attributes Specific to Variable Types
1973
2028
 
1974
2029
  def name
1975
- __text(OCI_ATTR_NAME)
2030
+ attr_get_string(OCI_ATTR_NAME)
1976
2031
  end
1977
2032
 
1978
2033
  def var_type
1979
- __text(OCI_ATTR_VAR_TYPE)
2034
+ attr_get_string(OCI_ATTR_VAR_TYPE)
1980
2035
  end
1981
2036
 
1982
2037
  def var_value_function
1983
- __text(OCI_ATTR_VAR_VALUE_FUNCTION)
2038
+ attr_get_string(OCI_ATTR_VAR_VALUE_FUNCTION)
1984
2039
  end
1985
2040
 
1986
2041
  def var_method_function
1987
- __text(OCI_ATTR_VAR_METHOD_FUNCTION)
2042
+ attr_get_string(OCI_ATTR_VAR_METHOD_FUNCTION)
1988
2043
  end
1989
2044
  end
1990
2045
 
@@ -1994,7 +2049,7 @@ class OCI8
1994
2049
  # Table 6-23 Attributes Specific to Name Value Pair
1995
2050
 
1996
2051
  def name
1997
- __text(OCI_ATTR_NAME)
2052
+ attr_get_string(OCI_ATTR_NAME)
1998
2053
  end
1999
2054
 
2000
2055
  # not implemented