ruby-oci8 1.0.7 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +1254 -390
- data/Makefile +10 -13
- data/README +56 -385
- data/VERSION +1 -1
- data/dist-files +26 -27
- data/ext/oci8/.document +1 -0
- data/ext/oci8/MANIFEST +0 -4
- data/ext/oci8/apiwrap.c.tmpl +172 -0
- data/ext/oci8/apiwrap.h.tmpl +61 -0
- data/ext/oci8/apiwrap.rb +91 -0
- data/ext/oci8/apiwrap.yml +1243 -0
- data/ext/oci8/attr.c +124 -384
- data/ext/oci8/bind.c +472 -164
- data/ext/oci8/encoding.c +196 -0
- data/ext/oci8/env.c +84 -253
- data/ext/oci8/error.c +196 -127
- data/ext/oci8/extconf.rb +82 -59
- data/ext/oci8/lob.c +710 -370
- data/ext/oci8/metadata.c +359 -0
- data/ext/oci8/object.c +622 -0
- data/ext/oci8/oci8.c +577 -161
- data/ext/oci8/oci8.h +354 -258
- data/ext/oci8/oci8lib.c +493 -0
- data/ext/oci8/ocidatetime.c +473 -0
- data/ext/oci8/ocinumber.c +1123 -24
- data/ext/oci8/oraconf.rb +72 -106
- data/ext/oci8/oradate.c +511 -321
- data/ext/oci8/stmt.c +752 -572
- data/ext/oci8/win32.c +131 -0
- data/ext/oci8/xmldb.c +383 -0
- data/lib/.document +2 -0
- data/lib/dbd/OCI8.rb +2 -17
- data/lib/oci8.rb.in +41 -1622
- data/lib/oci8/.document +5 -0
- data/lib/oci8/compat.rb +108 -0
- data/lib/oci8/datetime.rb +489 -0
- data/lib/oci8/encoding-init.rb +40 -0
- data/lib/oci8/encoding.yml +537 -0
- data/lib/oci8/metadata.rb +2077 -0
- data/lib/oci8/object.rb +548 -0
- data/lib/oci8/oci8.rb +773 -0
- data/lib/oci8/oracle_version.rb +144 -0
- data/metaconfig +3 -3
- data/ruby-oci8.gemspec +5 -5
- data/setup.rb +4 -4
- data/test/config.rb +64 -84
- data/test/test_all.rb +14 -21
- data/test/test_array_dml.rb +317 -0
- data/test/test_bind_raw.rb +18 -25
- data/test/test_bind_time.rb +78 -91
- data/test/test_break.rb +37 -35
- data/test/test_clob.rb +33 -89
- data/test/test_connstr.rb +5 -4
- data/test/test_datetime.rb +469 -0
- data/test/test_dbi.rb +99 -60
- data/test/test_dbi_clob.rb +3 -8
- data/test/test_metadata.rb +65 -51
- data/test/test_oci8.rb +151 -55
- data/test/test_oracle_version.rb +70 -0
- data/test/test_oradate.rb +76 -83
- data/test/test_oranumber.rb +405 -71
- data/test/test_rowid.rb +6 -11
- metadata +31 -32
- data/NEWS +0 -420
- data/ext/oci8/const.c +0 -165
- data/ext/oci8/define.c +0 -53
- data/ext/oci8/describe.c +0 -81
- data/ext/oci8/descriptor.c +0 -39
- data/ext/oci8/handle.c +0 -273
- data/ext/oci8/oranumber.c +0 -445
- data/ext/oci8/param.c +0 -37
- data/ext/oci8/server.c +0 -182
- data/ext/oci8/session.c +0 -99
- data/ext/oci8/svcctx.c +0 -238
- data/ruby-oci8.spec +0 -62
- data/support/README +0 -4
- data/support/runit/assert.rb +0 -281
- data/support/runit/cui/testrunner.rb +0 -101
- data/support/runit/error.rb +0 -4
- data/support/runit/method_mappable.rb +0 -20
- data/support/runit/robserver.rb +0 -25
- data/support/runit/setuppable.rb +0 -15
- data/support/runit/teardownable.rb +0 -16
- data/support/runit/testcase.rb +0 -113
- data/support/runit/testfailure.rb +0 -25
- data/support/runit/testresult.rb +0 -121
- data/support/runit/testsuite.rb +0 -43
- data/support/runit/version.rb +0 -3
- data/test/test_describe.rb +0 -137
@@ -0,0 +1,2077 @@
|
|
1
|
+
# Implement OCI8::Metadata.
|
2
|
+
# See {'Describing Schema Metadata' in Oracle Call Interface Programmer's Guide}
|
3
|
+
# [http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14250/oci06des.htm]
|
4
|
+
|
5
|
+
#
|
6
|
+
class OCI8
|
7
|
+
|
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)
|
217
|
+
#
|
218
|
+
# The name can be supplied as 'OBJECT_NAME' or 'SCHEMA_NAME.OBJECT_NAME'.
|
219
|
+
# For example: 'emp', 'scott.emp'.
|
220
|
+
#
|
221
|
+
# = Retrieving Column Datatypes for a Table
|
222
|
+
#
|
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
|
232
|
+
module Metadata
|
233
|
+
# Abstract super class for Metadata classes.
|
234
|
+
class Base
|
235
|
+
# Table 6-1 Attributes Belonging to All Parameters
|
236
|
+
|
237
|
+
# don't use this. The number of parameters
|
238
|
+
def num_params
|
239
|
+
__ub2(OCI_ATTR_NUM_PARAMS)
|
240
|
+
end
|
241
|
+
private :num_params
|
242
|
+
|
243
|
+
# object or schema ID
|
244
|
+
def obj_id
|
245
|
+
__ub4(OCI_ATTR_OBJ_ID)
|
246
|
+
end
|
247
|
+
|
248
|
+
# database name or object name in a schema
|
249
|
+
def obj_name
|
250
|
+
__text(OCI_ATTR_OBJ_NAME)
|
251
|
+
end
|
252
|
+
|
253
|
+
# schema name where the object is located
|
254
|
+
def obj_schema
|
255
|
+
__text(OCI_ATTR_OBJ_SCHEMA)
|
256
|
+
end
|
257
|
+
|
258
|
+
# The timestamp of the object
|
259
|
+
def timestamp
|
260
|
+
__oradate(OCI_ATTR_TIMESTAMP)
|
261
|
+
end
|
262
|
+
|
263
|
+
def inspect # :nodoc:
|
264
|
+
"#<#{self.class.name}:(#{obj_id}) #{obj_schema}.#{obj_name}>"
|
265
|
+
end
|
266
|
+
private
|
267
|
+
|
268
|
+
def __boolean(idx)
|
269
|
+
__ub1(idx) == 0 ? false : true
|
270
|
+
end
|
271
|
+
alias __word __sb4
|
272
|
+
def __anydata(idx); raise NotImplementedError; end
|
273
|
+
|
274
|
+
# SQLT values to name
|
275
|
+
DATA_TYPE_MAP = {} # :nodoc:
|
276
|
+
|
277
|
+
# SQLT_CHR
|
278
|
+
DATA_TYPE_MAP[1] = [:varchar2,
|
279
|
+
Proc.new do |p|
|
280
|
+
if p.charset_form == :nchar
|
281
|
+
"NVARCHAR2(#{p.char_size})"
|
282
|
+
elsif p.char_used?
|
283
|
+
"VARCHAR2(#{p.char_size} CHAR)"
|
284
|
+
else
|
285
|
+
"VARCHAR2(#{p.data_size})"
|
286
|
+
end
|
287
|
+
end]
|
288
|
+
# SQLT_NUM
|
289
|
+
DATA_TYPE_MAP[2] = [:number,
|
290
|
+
Proc.new do |p|
|
291
|
+
begin
|
292
|
+
case p.scale
|
293
|
+
when -127
|
294
|
+
case p.precision
|
295
|
+
when 0
|
296
|
+
"NUMBER"
|
297
|
+
when 126
|
298
|
+
"FLOAT"
|
299
|
+
else
|
300
|
+
"FLOAT(#{p.precision})"
|
301
|
+
end
|
302
|
+
when 0
|
303
|
+
case p.precision
|
304
|
+
when 0
|
305
|
+
"NUMBER"
|
306
|
+
else
|
307
|
+
"NUMBER(#{p.precision})"
|
308
|
+
end
|
309
|
+
else
|
310
|
+
"NUMBER(#{p.precision},#{p.scale})"
|
311
|
+
end
|
312
|
+
rescue OCIError
|
313
|
+
"NUMBER"
|
314
|
+
end
|
315
|
+
end]
|
316
|
+
# SQLT_LNG
|
317
|
+
DATA_TYPE_MAP[8] = [:long, "LONG"]
|
318
|
+
# SQLT_DAT
|
319
|
+
DATA_TYPE_MAP[12] = [:date, "DATE"]
|
320
|
+
# SQLT_BIN
|
321
|
+
DATA_TYPE_MAP[23] = [:raw,
|
322
|
+
Proc.new do |p|
|
323
|
+
"RAW(#{p.data_size})"
|
324
|
+
end]
|
325
|
+
# SQLT_LBI
|
326
|
+
DATA_TYPE_MAP[24] = [:long_raw, "LONG RAW"]
|
327
|
+
# SQLT_AFC
|
328
|
+
DATA_TYPE_MAP[96] = [:char,
|
329
|
+
Proc.new do |p|
|
330
|
+
if p.charset_form == :nchar
|
331
|
+
"NCHAR(#{p.char_size})"
|
332
|
+
elsif p.char_used?
|
333
|
+
"CHAR(#{p.char_size} CHAR)"
|
334
|
+
else
|
335
|
+
"CHAR(#{p.data_size})"
|
336
|
+
end
|
337
|
+
end]
|
338
|
+
# SQLT_IBFLOAT
|
339
|
+
DATA_TYPE_MAP[100] = [:binary_float, "BINARY_FLOAT"]
|
340
|
+
# SQLT_IBDOUBLE
|
341
|
+
DATA_TYPE_MAP[101] = [:binary_double, "BINARY_DOUBLE"]
|
342
|
+
# SQLT_RDD
|
343
|
+
DATA_TYPE_MAP[104] = [:rowid, "ROWID"]
|
344
|
+
# SQLT_NTY
|
345
|
+
DATA_TYPE_MAP[108] = [:named_type,
|
346
|
+
Proc.new do |p|
|
347
|
+
"#{p.schema_name}.#{p.type_name}"
|
348
|
+
end]
|
349
|
+
# SQLT_REF
|
350
|
+
DATA_TYPE_MAP[110] = [:ref,
|
351
|
+
Proc.new do |p|
|
352
|
+
"#{p.schema_name}.#{p.type_name}"
|
353
|
+
end]
|
354
|
+
# SQLT_CLOB
|
355
|
+
DATA_TYPE_MAP[112] = [:clob,
|
356
|
+
Proc.new do |p|
|
357
|
+
if p.charset_form == :nchar
|
358
|
+
"NCLOB"
|
359
|
+
else
|
360
|
+
"CLOB"
|
361
|
+
end
|
362
|
+
end]
|
363
|
+
# SQLT_BLOB
|
364
|
+
DATA_TYPE_MAP[113] = [:blob, "BLOB"]
|
365
|
+
# SQLT_BFILE
|
366
|
+
DATA_TYPE_MAP[114] = [:bfile, "BFILE"]
|
367
|
+
# SQLT_RSET
|
368
|
+
DATA_TYPE_MAP[116] = [:cursor, "CURSOR"]
|
369
|
+
# SQLT_TIMESTAMP
|
370
|
+
DATA_TYPE_MAP[187] = [:timestamp,
|
371
|
+
Proc.new do |p|
|
372
|
+
fsprecision = p.fsprecision
|
373
|
+
if fsprecision == 6
|
374
|
+
"TIMESTAMP"
|
375
|
+
else
|
376
|
+
"TIMESTAMP(#{fsprecision})"
|
377
|
+
end
|
378
|
+
end]
|
379
|
+
# SQLT_TIMESTAMP_TZ
|
380
|
+
DATA_TYPE_MAP[188] = [:timestamp_tz,
|
381
|
+
Proc.new do |p|
|
382
|
+
fsprecision = p.fsprecision
|
383
|
+
if fsprecision == 6
|
384
|
+
"TIMESTAMP WITH TIME ZONE"
|
385
|
+
else
|
386
|
+
"TIMESTAMP(#{fsprecision}) WITH TIME ZONE"
|
387
|
+
end
|
388
|
+
end]
|
389
|
+
# SQLT_INTERVAL_YM
|
390
|
+
DATA_TYPE_MAP[189] = [:interval_ym,
|
391
|
+
Proc.new do |p|
|
392
|
+
lfprecision = p.lfprecision
|
393
|
+
if lfprecision == 2
|
394
|
+
"INTERVAL YEAR TO MONTH"
|
395
|
+
else
|
396
|
+
"INTERVAL YEAR(#{lfprecision}) TO MONTH"
|
397
|
+
end
|
398
|
+
end]
|
399
|
+
# SQLT_INTERVAL_DS
|
400
|
+
DATA_TYPE_MAP[190] = [:interval_ds,
|
401
|
+
Proc.new do |p|
|
402
|
+
lfprecision = p.lfprecision
|
403
|
+
fsprecision = p.fsprecision
|
404
|
+
if lfprecision == 2 && fsprecision == 6
|
405
|
+
"INTERVAL DAY TO SECOND"
|
406
|
+
else
|
407
|
+
"INTERVAL DAY(#{lfprecision}) TO SECOND(#{fsprecision})"
|
408
|
+
end
|
409
|
+
end]
|
410
|
+
# SQLT_TIMESTAMP_LTZ
|
411
|
+
DATA_TYPE_MAP[232] = [:timestamp_ltz,
|
412
|
+
Proc.new do |p|
|
413
|
+
fsprecision = p.fsprecision
|
414
|
+
if fsprecision == 6
|
415
|
+
"TIMESTAMP WITH LOCAL TIME ZONE"
|
416
|
+
else
|
417
|
+
"TIMESTAMP(#{fsprecision}) WITH LOCAL TIME ZONE"
|
418
|
+
end
|
419
|
+
end]
|
420
|
+
|
421
|
+
def __data_type
|
422
|
+
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]
|
425
|
+
type = type.call(self) if type.is_a? Proc
|
426
|
+
@data_type = type
|
427
|
+
end
|
428
|
+
|
429
|
+
def __duration
|
430
|
+
case __ub2(OCI_ATTR_DURATION)
|
431
|
+
when OCI_DURATION_SESSION
|
432
|
+
:session
|
433
|
+
when OCI_DURATION_TRANS
|
434
|
+
:transaction
|
435
|
+
when OCI_DURATION_NULL
|
436
|
+
nil
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
def __charset_form
|
441
|
+
case __ub1(OCI_ATTR_CHARSET_FORM)
|
442
|
+
when 1; :implicit # for CHAR, VARCHAR2, CLOB w/o a specified set
|
443
|
+
when 2; :nchar # for NCHAR, NCHAR VARYING, NCLOB
|
444
|
+
when 3; :explicit # for CHAR, etc, with "CHARACTER SET ..." syntax
|
445
|
+
when 4; :flexible # for PL/SQL "flexible" parameters
|
446
|
+
when 5; :lit_null # for typecheck of NULL and empty_clob() lits
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
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]
|
453
|
+
type = type.call(self) if type.is_a? Proc
|
454
|
+
if respond_to?(:nullable?) && !nullable?
|
455
|
+
type + " NOT NULL"
|
456
|
+
else
|
457
|
+
type
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
def __typecode(idx)
|
462
|
+
case __ub2(idx)
|
463
|
+
when 110; :ref # OCI_TYPECODE_REF
|
464
|
+
when 12; :date # OCI_TYPECODE_DATE
|
465
|
+
when 27; :signed8 # OCI_TYPECODE_SIGNED8
|
466
|
+
when 28; :signed16 # OCI_TYPECODE_SIGNED16
|
467
|
+
when 29; :signed32 # OCI_TYPECODE_SIGNED32
|
468
|
+
when 21; :real # OCI_TYPECODE_REAL
|
469
|
+
when 22; :double # OCI_TYPECODE_DOUBLE
|
470
|
+
when 100; :binary_float # OCI_TYPECODE_BFLOAT
|
471
|
+
when 101; :binary_double # OCI_TYPECODE_BDOUBLE
|
472
|
+
when 4; :float # OCI_TYPECODE_FLOAT
|
473
|
+
when 2; :number # OCI_TYPECODE_NUMBER
|
474
|
+
when 7; :decimal # OCI_TYPECODE_DECIMAL
|
475
|
+
when 23; :unsigned8 # OCI_TYPECODE_UNSIGNED8
|
476
|
+
when 25; :unsigned16 # OCI_TYPECODE_UNSIGNED16
|
477
|
+
when 26; :unsigned32 # OCI_TYPECODE_UNSIGNED32
|
478
|
+
when 245; :octet # OCI_TYPECODE_OCTET
|
479
|
+
when 246; :smallint # OCI_TYPECODE_SMALLINT
|
480
|
+
when 3; :integer # OCI_TYPECODE_INTEGER
|
481
|
+
when 95; :raw # OCI_TYPECODE_RAW
|
482
|
+
when 32; :ptr # OCI_TYPECODE_PTR
|
483
|
+
when 9; :varchar2 # OCI_TYPECODE_VARCHAR2
|
484
|
+
when 96; :char # OCI_TYPECODE_CHAR
|
485
|
+
when 1; :varchar # OCI_TYPECODE_VARCHAR
|
486
|
+
when 105; :mlslabel # OCI_TYPECODE_MLSLABEL
|
487
|
+
when 247; :varray # OCI_TYPECODE_VARRAY
|
488
|
+
when 248; :table # OCI_TYPECODE_TABLE
|
489
|
+
when 108; :named_type # OCI_TYPECODE_OBJECT
|
490
|
+
when 58; :opaque # OCI_TYPECODE_OPAQUE
|
491
|
+
when 122; :named_collection # OCI_TYPECODE_NAMEDCOLLECTION
|
492
|
+
when 113; :blob # OCI_TYPECODE_BLOB
|
493
|
+
when 114; :bfile # OCI_TYPECODE_BFILE
|
494
|
+
when 112; :clob # OCI_TYPECODE_CLOB
|
495
|
+
when 115; :cfile # OCI_TYPECODE_CFILE
|
496
|
+
when 185; :time # OCI_TYPECODE_TIME
|
497
|
+
when 186; :time_tz # OCI_TYPECODE_TIME_TZ
|
498
|
+
when 187; :timestamp # OCI_TYPECODE_TIMESTAMP
|
499
|
+
when 188; :timestamp_tz # OCI_TYPECODE_TIMESTAMP_TZ
|
500
|
+
when 232; :timestamp_ltz # OCI_TYPECODE_TIMESTAMP_LTZ
|
501
|
+
when 189; :interval_ym # OCI_TYPECODE_INTERVAL_YM
|
502
|
+
when 190; :interval_ds # OCI_TYPECODE_INTERVAL_DS
|
503
|
+
when 104; :urowid # OCI_TYPECODE_UROWID
|
504
|
+
#when 228; :otmfirst # OCI_TYPECODE_OTMFIRST
|
505
|
+
#when 320; :otmlast # OCI_TYPECODE_OTMLAST
|
506
|
+
#when 228; :sysfirst # OCI_TYPECODE_SYSFIRST
|
507
|
+
#when 235; :syslast # OCI_TYPECODE_SYSLAST
|
508
|
+
when 266; :pls_integer # OCI_TYPECODE_PLS_INTEGER
|
509
|
+
end
|
510
|
+
end
|
511
|
+
end
|
512
|
+
|
513
|
+
# metadata for a object which cannot be classified into other
|
514
|
+
# metadata classes.
|
515
|
+
#
|
516
|
+
# This is returned by:
|
517
|
+
# * OCI8::Metadata::Schema#all_objects
|
518
|
+
class Unknown < Base
|
519
|
+
register_ptype OCI_PTYPE_UNK
|
520
|
+
end
|
521
|
+
|
522
|
+
# Metadata for a table.
|
523
|
+
#
|
524
|
+
# This is returned by:
|
525
|
+
# * OCI8#describe_any(name)
|
526
|
+
# * OCI8#describe_table(name)
|
527
|
+
# * OCI8::Metadata::Schema#all_objects
|
528
|
+
# * OCI8::Metadata::Schema#objects
|
529
|
+
#
|
530
|
+
# See also:
|
531
|
+
# * OCI8::Metadata::Base#obj_name
|
532
|
+
# * OCI8::Metadata::Base#obj_schema
|
533
|
+
class Table < Base
|
534
|
+
register_ptype OCI_PTYPE_TABLE
|
535
|
+
|
536
|
+
## Table 6-2 Attributes Belonging to Tables or Views
|
537
|
+
|
538
|
+
# number of columns
|
539
|
+
def num_cols
|
540
|
+
__ub2(OCI_ATTR_NUM_COLS)
|
541
|
+
end
|
542
|
+
|
543
|
+
# column list
|
544
|
+
def list_columns
|
545
|
+
__param(OCI_ATTR_LIST_COLUMNS)
|
546
|
+
end
|
547
|
+
private :list_columns
|
548
|
+
|
549
|
+
# to type metadata if possible
|
550
|
+
def type_metadata
|
551
|
+
__type_metadata(OCI8::Metadata::Type)
|
552
|
+
end
|
553
|
+
|
554
|
+
# indicates the table is temporary.
|
555
|
+
def is_temporary?
|
556
|
+
__boolean(OCI_ATTR_IS_TEMPORARY)
|
557
|
+
end
|
558
|
+
|
559
|
+
# indicates the table is typed.
|
560
|
+
def is_typed?
|
561
|
+
__boolean(OCI_ATTR_IS_TYPED)
|
562
|
+
end
|
563
|
+
|
564
|
+
# Duration of a temporary table. Values can be <tt>:session</tt> or
|
565
|
+
# <tt>:transaction</tt>. nil if not a temporary table.
|
566
|
+
def duration
|
567
|
+
__duration
|
568
|
+
end
|
569
|
+
|
570
|
+
## Table 6-3 Attributes Specific to Tables
|
571
|
+
|
572
|
+
# data block address of the segment header. (How to use this?)
|
573
|
+
def dba
|
574
|
+
__ub4(OCI_ATTR_RDBA)
|
575
|
+
end
|
576
|
+
|
577
|
+
# tablespace the table resides in. (How to use this?)
|
578
|
+
def tablespace
|
579
|
+
__word(OCI_ATTR_TABLESPACE)
|
580
|
+
end
|
581
|
+
|
582
|
+
# indicates the table is clustered.
|
583
|
+
def clustered?
|
584
|
+
__boolean(OCI_ATTR_CLUSTERED)
|
585
|
+
end
|
586
|
+
|
587
|
+
# indicates the table is partitioned.
|
588
|
+
def partitioned?
|
589
|
+
__boolean(OCI_ATTR_PARTITIONED)
|
590
|
+
end
|
591
|
+
|
592
|
+
# indicates the table is index-only.
|
593
|
+
def index_only?
|
594
|
+
__boolean(OCI_ATTR_INDEX_ONLY)
|
595
|
+
end
|
596
|
+
|
597
|
+
# array of Column objects in a table.
|
598
|
+
def columns
|
599
|
+
@columns ||= list_columns.to_a
|
600
|
+
end
|
601
|
+
end
|
602
|
+
|
603
|
+
# Metadata for a view.
|
604
|
+
#
|
605
|
+
# This is returned by:
|
606
|
+
# * OCI8#describe_any(name)
|
607
|
+
# * OCI8#describe_table(name, true)
|
608
|
+
# * OCI8#describe_view(name)
|
609
|
+
# * OCI8::Metadata::Schema#all_objects
|
610
|
+
# * OCI8::Metadata::Schema#objects
|
611
|
+
#
|
612
|
+
# See also:
|
613
|
+
# * OCI8::Metadata::Base#obj_name
|
614
|
+
# * OCI8::Metadata::Base#obj_schema
|
615
|
+
class View < Base
|
616
|
+
register_ptype OCI_PTYPE_VIEW
|
617
|
+
|
618
|
+
## Table 6-2 Attributes Belonging to Tables or Views
|
619
|
+
|
620
|
+
# number of columns
|
621
|
+
def num_cols
|
622
|
+
__ub2(OCI_ATTR_NUM_COLS)
|
623
|
+
end
|
624
|
+
|
625
|
+
# column list
|
626
|
+
def list_columns
|
627
|
+
__param(OCI_ATTR_LIST_COLUMNS)
|
628
|
+
end
|
629
|
+
private :list_columns
|
630
|
+
|
631
|
+
# to type metadata if possible
|
632
|
+
def type_metadata
|
633
|
+
__type_metadata(OCI8::Metadata::Type)
|
634
|
+
end
|
635
|
+
|
636
|
+
# indicates the table is temporary.
|
637
|
+
def is_temporary?
|
638
|
+
__boolean(OCI_ATTR_IS_TEMPORARY)
|
639
|
+
end
|
640
|
+
|
641
|
+
# indicates the table is typed.
|
642
|
+
def is_typed?
|
643
|
+
__boolean(OCI_ATTR_IS_TYPED)
|
644
|
+
end
|
645
|
+
|
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
|
651
|
+
|
652
|
+
# array of Column objects in a table.
|
653
|
+
def columns
|
654
|
+
@columns ||= list_columns.to_a
|
655
|
+
end
|
656
|
+
end
|
657
|
+
|
658
|
+
# Abstract super class of Procedure and Function.
|
659
|
+
#
|
660
|
+
#--
|
661
|
+
# How can I know whether FUNCTION or PROCEDURE?
|
662
|
+
#++
|
663
|
+
class ProcBase < Base
|
664
|
+
## Table 6-4 Attribute Belonging to Procedures or Functions
|
665
|
+
|
666
|
+
# Argument list
|
667
|
+
def list_arguments
|
668
|
+
__param(OCI_ATTR_LIST_ARGUMENTS)
|
669
|
+
end
|
670
|
+
private :list_arguments
|
671
|
+
|
672
|
+
# indicates the procedure or function has invoker's rights
|
673
|
+
def is_invoker_rights?
|
674
|
+
__boolean(OCI_ATTR_IS_INVOKER_RIGHTS)
|
675
|
+
end
|
676
|
+
|
677
|
+
## Table 6-5 Attributes Specific to Package Subprograms
|
678
|
+
|
679
|
+
# name of the procedure or function.
|
680
|
+
#
|
681
|
+
# available only for a Package subprogram.
|
682
|
+
def name
|
683
|
+
__text(OCI_ATTR_NAME)
|
684
|
+
end
|
685
|
+
|
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?)
|
690
|
+
#
|
691
|
+
# available only for a Package subprogram.
|
692
|
+
def overload_id
|
693
|
+
__ub2(OCI_ATTR_OVERLOAD_ID)
|
694
|
+
end
|
695
|
+
|
696
|
+
# array of Argument objects.
|
697
|
+
#
|
698
|
+
# The first element is the return type in case of Function.
|
699
|
+
def arguments
|
700
|
+
@arguments ||= list_arguments.to_a
|
701
|
+
end
|
702
|
+
|
703
|
+
def inspect # :nodoc:
|
704
|
+
"#<#{self.class.name}: #{name}>"
|
705
|
+
end
|
706
|
+
end
|
707
|
+
|
708
|
+
# Metadata for a procedure.
|
709
|
+
#
|
710
|
+
# This is returned by:
|
711
|
+
# * OCI8#describe_any(name)
|
712
|
+
# * OCI8#describe_procedure(name)
|
713
|
+
# * OCI8::Metadata::Schema#all_objects
|
714
|
+
# * OCI8::Metadata::Schema#objects
|
715
|
+
# * OCI8::Metadata::Package#subprograms
|
716
|
+
#
|
717
|
+
# See ProcBase's methods.
|
718
|
+
class Procedure < ProcBase
|
719
|
+
register_ptype OCI_PTYPE_PROC
|
720
|
+
end
|
721
|
+
|
722
|
+
# Metadata for a function.
|
723
|
+
#
|
724
|
+
# This is returned by:
|
725
|
+
# * OCI8#describe_any(name)
|
726
|
+
# * OCI8#describe_function(name)
|
727
|
+
# * OCI8::Metadata::Schema#all_objects
|
728
|
+
# * OCI8::Metadata::Schema#objects
|
729
|
+
# * OCI8::Metadata::Package#subprograms
|
730
|
+
#
|
731
|
+
# See ProcBase's methods.
|
732
|
+
class Function < ProcBase
|
733
|
+
register_ptype OCI_PTYPE_FUNC
|
734
|
+
end
|
735
|
+
|
736
|
+
# Metadata for a package.
|
737
|
+
#
|
738
|
+
# This is returned by:
|
739
|
+
# * OCI8#describe_any(name)
|
740
|
+
# * OCI8#describe_package(name)
|
741
|
+
# * OCI8::Metadata::Schema#all_objects
|
742
|
+
# * OCI8::Metadata::Schema#objects
|
743
|
+
class Package < Base
|
744
|
+
register_ptype OCI_PTYPE_PKG
|
745
|
+
|
746
|
+
## Table 6-6 Attributes Belonging to Packages
|
747
|
+
|
748
|
+
# subprogram list
|
749
|
+
def list_subprograms
|
750
|
+
__param(OCI_ATTR_LIST_SUBPROGRAMS)
|
751
|
+
end
|
752
|
+
private :list_subprograms
|
753
|
+
|
754
|
+
# is the package invoker's rights?
|
755
|
+
def is_invoker_rights?
|
756
|
+
__boolean(OCI_ATTR_IS_INVOKER_RIGHTS)
|
757
|
+
end
|
758
|
+
|
759
|
+
# array of Procedure or Function objects.
|
760
|
+
def subprograms
|
761
|
+
@subprograms ||= list_subprograms.to_a
|
762
|
+
end
|
763
|
+
end
|
764
|
+
|
765
|
+
# Metadata for a type.
|
766
|
+
#
|
767
|
+
# This is returned by:
|
768
|
+
# * OCI8#describe_any(name)
|
769
|
+
# * OCI8#describe_type(name)
|
770
|
+
# * OCI8::Metadata::Schema#all_objects
|
771
|
+
# * OCI8::Metadata::Schema#objects
|
772
|
+
class Type < Base
|
773
|
+
register_ptype OCI_PTYPE_TYPE
|
774
|
+
|
775
|
+
## Table 6-7 Attributes Belonging to Types
|
776
|
+
|
777
|
+
# to type metadata if possible
|
778
|
+
def type_metadata
|
779
|
+
self
|
780
|
+
end
|
781
|
+
|
782
|
+
# typecode. :object or :named_collection
|
783
|
+
def typecode
|
784
|
+
__typecode(OCI_ATTR_TYPECODE)
|
785
|
+
end
|
786
|
+
|
787
|
+
# typecode of collection if type is collection. nil if otherwise.
|
788
|
+
def collection_typecode
|
789
|
+
__typecode(OCI_ATTR_COLLECTION_TYPECODE) if typecode == :named_collection
|
790
|
+
end
|
791
|
+
|
792
|
+
# indicates this is an incomplete type
|
793
|
+
def is_incomplete_type?
|
794
|
+
__boolean(OCI_ATTR_IS_INCOMPLETE_TYPE)
|
795
|
+
end
|
796
|
+
|
797
|
+
# indicates this is a system type
|
798
|
+
def is_system_type?
|
799
|
+
__boolean(OCI_ATTR_IS_SYSTEM_TYPE)
|
800
|
+
end
|
801
|
+
|
802
|
+
# indicates this is a predefined type
|
803
|
+
def is_predefined_type?
|
804
|
+
__boolean(OCI_ATTR_IS_PREDEFINED_TYPE)
|
805
|
+
end
|
806
|
+
|
807
|
+
# indicates this is a transient type
|
808
|
+
def is_transient_type?
|
809
|
+
__boolean(OCI_ATTR_IS_TRANSIENT_TYPE)
|
810
|
+
end
|
811
|
+
|
812
|
+
# indicates this is a system-generated type
|
813
|
+
def is_system_generated_type?
|
814
|
+
__boolean(OCI_ATTR_IS_SYSTEM_GENERATED_TYPE)
|
815
|
+
end
|
816
|
+
|
817
|
+
# indicates this type contains a nested table attribute.
|
818
|
+
def has_nested_table?
|
819
|
+
__boolean(OCI_ATTR_HAS_NESTED_TABLE)
|
820
|
+
end
|
821
|
+
|
822
|
+
# indicates this type contains a LOB attribute
|
823
|
+
def has_lob?
|
824
|
+
__boolean(OCI_ATTR_HAS_LOB)
|
825
|
+
end
|
826
|
+
|
827
|
+
# indicates this type contains a BFILE attribute
|
828
|
+
def has_file?
|
829
|
+
__boolean(OCI_ATTR_HAS_FILE)
|
830
|
+
end
|
831
|
+
|
832
|
+
# returns OCI8::Metadata::Collection if type is collection. nil if otherwise.
|
833
|
+
def collection_element
|
834
|
+
__param(OCI_ATTR_COLLECTION_ELEMENT) if typecode == :named_collection
|
835
|
+
end
|
836
|
+
|
837
|
+
# number of type attributes
|
838
|
+
def num_type_attrs
|
839
|
+
__ub2(OCI_ATTR_NUM_TYPE_ATTRS)
|
840
|
+
end
|
841
|
+
|
842
|
+
# list of type attributes
|
843
|
+
def list_type_attrs
|
844
|
+
__param(OCI_ATTR_LIST_TYPE_ATTRS)
|
845
|
+
end
|
846
|
+
private :list_type_attrs
|
847
|
+
|
848
|
+
# number of type methods
|
849
|
+
def num_type_methods
|
850
|
+
__ub2(OCI_ATTR_NUM_TYPE_METHODS)
|
851
|
+
end
|
852
|
+
|
853
|
+
# list of type methods
|
854
|
+
def list_type_methods
|
855
|
+
__param(OCI_ATTR_LIST_TYPE_METHODS)
|
856
|
+
end
|
857
|
+
private :list_type_methods
|
858
|
+
|
859
|
+
# map method of type
|
860
|
+
def map_method
|
861
|
+
__param(OCI_ATTR_MAP_METHOD)
|
862
|
+
end
|
863
|
+
|
864
|
+
# order method of type
|
865
|
+
def order_method
|
866
|
+
__param(OCI_ATTR_ORDER_METHOD)
|
867
|
+
end
|
868
|
+
|
869
|
+
# indicates the type has invoker's rights
|
870
|
+
def is_invoker_rights?
|
871
|
+
__boolean(OCI_ATTR_IS_INVOKER_RIGHTS)
|
872
|
+
end
|
873
|
+
|
874
|
+
# type name
|
875
|
+
def name
|
876
|
+
__text(OCI_ATTR_NAME)
|
877
|
+
end
|
878
|
+
|
879
|
+
# schema name where the type has been created
|
880
|
+
def schema_name
|
881
|
+
__text(OCI_ATTR_SCHEMA_NAME)
|
882
|
+
end
|
883
|
+
|
884
|
+
# indicates this is a final type
|
885
|
+
def is_final_type?
|
886
|
+
__boolean(OCI_ATTR_IS_FINAL_TYPE)
|
887
|
+
end
|
888
|
+
|
889
|
+
# indicates this is an instantiable type
|
890
|
+
def is_instantiable_type?
|
891
|
+
__boolean(OCI_ATTR_IS_INSTANTIABLE_TYPE)
|
892
|
+
end
|
893
|
+
|
894
|
+
# indicates this is a subtype
|
895
|
+
def is_subtype?
|
896
|
+
__boolean(OCI_ATTR_IS_SUBTYPE)
|
897
|
+
end
|
898
|
+
|
899
|
+
# supertype's schema name
|
900
|
+
def supertype_schema_name
|
901
|
+
__text(OCI_ATTR_SUPERTYPE_SCHEMA_NAME) if is_subtype?
|
902
|
+
end
|
903
|
+
|
904
|
+
# supertype's name
|
905
|
+
def supertype_name
|
906
|
+
__text(OCI_ATTR_SUPERTYPE_NAME) if is_subtype?
|
907
|
+
end
|
908
|
+
|
909
|
+
# array of TypeAttr objects.
|
910
|
+
def type_attrs
|
911
|
+
@type_attrs ||= list_type_attrs.to_a
|
912
|
+
end
|
913
|
+
|
914
|
+
# array of TypeMethod objects.
|
915
|
+
def type_methods
|
916
|
+
@type_methods ||= list_type_methods.to_a
|
917
|
+
end
|
918
|
+
|
919
|
+
def inspect # :nodoc:
|
920
|
+
"#<#{self.class.name}:(#{obj_id}) #{schema_name}.#{name}>"
|
921
|
+
end
|
922
|
+
end
|
923
|
+
|
924
|
+
# Metadata for a type attribute.
|
925
|
+
#
|
926
|
+
# This is returned by:
|
927
|
+
# * OCI8::Metadata::Type#type_attrs
|
928
|
+
class TypeAttr < Base
|
929
|
+
register_ptype OCI_PTYPE_TYPE_ATTR
|
930
|
+
|
931
|
+
## Table 6-8 Attributes Belonging to Type Attributes
|
932
|
+
|
933
|
+
# The maximum size of the type attribute. This length is
|
934
|
+
# returned in bytes and not characters for strings and raws. It
|
935
|
+
# returns 22 for NUMBERs.
|
936
|
+
def data_size
|
937
|
+
__ub2_nc(OCI_ATTR_DATA_SIZE)
|
938
|
+
end
|
939
|
+
|
940
|
+
# typecode
|
941
|
+
def typecode
|
942
|
+
__typecode(OCI_ATTR_TYPECODE)
|
943
|
+
end
|
944
|
+
|
945
|
+
# the datatype of the type
|
946
|
+
def data_type
|
947
|
+
__data_type
|
948
|
+
end
|
949
|
+
|
950
|
+
# the type attribute name
|
951
|
+
def name
|
952
|
+
__text(OCI_ATTR_NAME)
|
953
|
+
end
|
954
|
+
|
955
|
+
# The precision of numeric type attributes. If the precision is
|
956
|
+
# nonzero and scale is -127, then it is a FLOAT, else it is a
|
957
|
+
# NUMBER(precision, scale). For the case when precision is 0,
|
958
|
+
# NUMBER(precision, scale) can be represented simply as NUMBER.
|
959
|
+
def precision
|
960
|
+
__is_implicit? ? __sb2(OCI_ATTR_PRECISION) : __ub1(OCI_ATTR_PRECISION)
|
961
|
+
end
|
962
|
+
|
963
|
+
# The scale of numeric type attributes. If the precision is
|
964
|
+
# nonzero and scale is -127, then it is a FLOAT, else it is a
|
965
|
+
# NUMBER(precision, scale). For the case when precision is 0,
|
966
|
+
# NUMBER(precision, scale) can be represented simply as NUMBER.
|
967
|
+
def scale
|
968
|
+
__sb1(OCI_ATTR_SCALE)
|
969
|
+
end
|
970
|
+
|
971
|
+
# A string which is the type name. The returned value will
|
972
|
+
# contain the type name if the datatype is <tt>:named_type</tt>
|
973
|
+
# or <tt>:ref</tt>. If the datatype is <tt>:named_type</tt>, the
|
974
|
+
# name of the named datatype's type is returned. If the datatype
|
975
|
+
# is <tt>:ref</tt>, the type name of the named datatype pointed
|
976
|
+
# to by the REF is returned.
|
977
|
+
def type_name
|
978
|
+
__text(OCI_ATTR_TYPE_NAME)
|
979
|
+
end
|
980
|
+
|
981
|
+
# schema name where the type has been created.
|
982
|
+
def schema_name
|
983
|
+
__text(OCI_ATTR_SCHEMA_NAME)
|
984
|
+
end
|
985
|
+
|
986
|
+
# to type metadata if possible
|
987
|
+
def type_metadata
|
988
|
+
__type_metadata(OCI8::Metadata::Type)
|
989
|
+
end
|
990
|
+
|
991
|
+
# character set id if the type attribute is of a string/character type.
|
992
|
+
def charset_id
|
993
|
+
__ub2(OCI_ATTR_CHARSET_ID)
|
994
|
+
end
|
995
|
+
|
996
|
+
# character set form, if the type attribute is of a string/character type.
|
997
|
+
def charset_form
|
998
|
+
__charset_form
|
999
|
+
end
|
1000
|
+
|
1001
|
+
if OCI8.oracle_client_version >= ORAVER_9_0
|
1002
|
+
# The fractional seconds precision of a datetime or interval.
|
1003
|
+
#
|
1004
|
+
# (unavailable on Oracle 8.1 or lower)
|
1005
|
+
def fsprecision
|
1006
|
+
__ub1(OCI_ATTR_FSPRECISION)
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
# The leading field precision of an interval
|
1010
|
+
#
|
1011
|
+
# (unavailable on Oracle 8.1 or lower)
|
1012
|
+
def lfprecision
|
1013
|
+
__ub1(OCI_ATTR_LFPRECISION)
|
1014
|
+
end
|
1015
|
+
end
|
1016
|
+
|
1017
|
+
# character set name if the type attribute is of a string/character type.
|
1018
|
+
def charset_name
|
1019
|
+
__charset_name(charset_id)
|
1020
|
+
end
|
1021
|
+
|
1022
|
+
def inspect # :nodoc:
|
1023
|
+
"#<#{self.class.name}: #{name} #{__type_string}>"
|
1024
|
+
end
|
1025
|
+
end
|
1026
|
+
|
1027
|
+
# Metadata for a type method.
|
1028
|
+
#
|
1029
|
+
# This is returned by:
|
1030
|
+
# * OCI8::Metadata::Type#type_methods
|
1031
|
+
# * OCI8::Metadata::Type#map_method
|
1032
|
+
# * OCI8::Metadata::Type#order_method
|
1033
|
+
#
|
1034
|
+
#--
|
1035
|
+
# How can I know whether FUNCTION or PROCEDURE?
|
1036
|
+
#++
|
1037
|
+
class TypeMethod < Base
|
1038
|
+
register_ptype OCI_PTYPE_TYPE_METHOD
|
1039
|
+
|
1040
|
+
## Table 6-9 Attributes Belonging to Type Methods
|
1041
|
+
|
1042
|
+
# Name of method (procedure or function)
|
1043
|
+
def name
|
1044
|
+
__text(OCI_ATTR_NAME)
|
1045
|
+
end
|
1046
|
+
|
1047
|
+
# encapsulation level of the method. Values are <tt>:public</tt>
|
1048
|
+
# or <tt>:private</tt>.
|
1049
|
+
def encapsulation
|
1050
|
+
case __ub4(OCI_ATTR_ENCAPSULATION)
|
1051
|
+
when 0; :private
|
1052
|
+
when 1; :public
|
1053
|
+
end
|
1054
|
+
end
|
1055
|
+
|
1056
|
+
# argument list
|
1057
|
+
def list_arguments
|
1058
|
+
__param(OCI_ATTR_LIST_ARGUMENTS)
|
1059
|
+
end
|
1060
|
+
private :list_arguments
|
1061
|
+
|
1062
|
+
# indicates method is has rsult
|
1063
|
+
def has_result?
|
1064
|
+
__boolean(OCI_ATTR_HAS_RESULT)
|
1065
|
+
end
|
1066
|
+
|
1067
|
+
# indicates method is a constructor
|
1068
|
+
def is_constructor?
|
1069
|
+
__boolean(OCI_ATTR_IS_CONSTRUCTOR)
|
1070
|
+
end
|
1071
|
+
|
1072
|
+
# indicates method is a destructor
|
1073
|
+
def is_destructor?
|
1074
|
+
__boolean(OCI_ATTR_IS_DESTRUCTOR)
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
# indicates method is an operator
|
1078
|
+
def is_operator?
|
1079
|
+
__boolean(OCI_ATTR_IS_OPERATOR)
|
1080
|
+
end
|
1081
|
+
|
1082
|
+
# indicates method is selfish
|
1083
|
+
def is_selfish?
|
1084
|
+
__boolean(OCI_ATTR_IS_SELFISH)
|
1085
|
+
end
|
1086
|
+
|
1087
|
+
# indicates method is a map method
|
1088
|
+
def is_map?
|
1089
|
+
__boolean(OCI_ATTR_IS_MAP)
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
# Indicates method is an order method
|
1093
|
+
def is_order?
|
1094
|
+
__boolean(OCI_ATTR_IS_ORDER)
|
1095
|
+
end
|
1096
|
+
|
1097
|
+
# indicates "Read No Data State"(does not query database tables) is set.
|
1098
|
+
def is_rnds?
|
1099
|
+
__boolean(OCI_ATTR_IS_RNDS)
|
1100
|
+
end
|
1101
|
+
|
1102
|
+
# Indicates "Read No Package State"(does not reference the values of packaged variables) is set.
|
1103
|
+
def is_rnps?
|
1104
|
+
__boolean(OCI_ATTR_IS_RNPS)
|
1105
|
+
end
|
1106
|
+
|
1107
|
+
# indicates "Write No Data State"(does not modify tables) is set.
|
1108
|
+
def is_wnds?
|
1109
|
+
__boolean(OCI_ATTR_IS_WNDS)
|
1110
|
+
end
|
1111
|
+
|
1112
|
+
# indicates "Write No Package State"(does not change the values of packaged variables) is set.
|
1113
|
+
def is_wnps?
|
1114
|
+
__boolean(OCI_ATTR_IS_WNPS)
|
1115
|
+
end
|
1116
|
+
|
1117
|
+
# indicates this is a final method
|
1118
|
+
def is_final_method?
|
1119
|
+
__boolean(OCI_ATTR_IS_FINAL_METHOD)
|
1120
|
+
end
|
1121
|
+
|
1122
|
+
# indicates this is an instantiable method
|
1123
|
+
def is_instantiable_method?
|
1124
|
+
__boolean(OCI_ATTR_IS_INSTANTIABLE_METHOD)
|
1125
|
+
end
|
1126
|
+
|
1127
|
+
# indicates this is an overriding method
|
1128
|
+
def is_overriding_method?
|
1129
|
+
__boolean(OCI_ATTR_IS_OVERRIDING_METHOD)
|
1130
|
+
end
|
1131
|
+
|
1132
|
+
# array of TypeArgument objects.
|
1133
|
+
#
|
1134
|
+
# The first element is the return type in case of Function.
|
1135
|
+
def arguments
|
1136
|
+
@arguments ||= list_arguments.to_a
|
1137
|
+
end
|
1138
|
+
|
1139
|
+
def inspect # :nodoc:
|
1140
|
+
"#<#{self.class.name}: #{name}>"
|
1141
|
+
end
|
1142
|
+
end
|
1143
|
+
|
1144
|
+
# Metadata for a collection.
|
1145
|
+
#
|
1146
|
+
# This is returned by:
|
1147
|
+
# * OCI8::Metadata::Type.collection_element
|
1148
|
+
class Collection < Base
|
1149
|
+
register_ptype OCI_PTYPE_TYPE_COLL
|
1150
|
+
|
1151
|
+
## Table 6-10 Attributes Belonging to Collection Types
|
1152
|
+
|
1153
|
+
# The maximum size of the type attribute. This length is
|
1154
|
+
# returned in bytes and not characters for strings and raws. It
|
1155
|
+
# returns 22 for NUMBERs.
|
1156
|
+
def data_size
|
1157
|
+
__ub2_nc(OCI_ATTR_DATA_SIZE)
|
1158
|
+
end
|
1159
|
+
|
1160
|
+
# typecode
|
1161
|
+
def typecode
|
1162
|
+
__typecode(OCI_ATTR_TYPECODE)
|
1163
|
+
end
|
1164
|
+
|
1165
|
+
# the datatype of the type
|
1166
|
+
def data_type
|
1167
|
+
__data_type
|
1168
|
+
end
|
1169
|
+
|
1170
|
+
# the number of elements in an array. It is only valid for
|
1171
|
+
# collections that are arrays.
|
1172
|
+
def num_elems
|
1173
|
+
__ub4(OCI_ATTR_NUM_ELEMS)
|
1174
|
+
end
|
1175
|
+
|
1176
|
+
# The precision of numeric type attributes. If the precision is
|
1177
|
+
# nonzero and scale is -127, then it is a FLOAT, else it is a
|
1178
|
+
# NUMBER(precision, scale). For the case when precision is 0,
|
1179
|
+
# NUMBER(precision, scale) can be represented simply as NUMBER.
|
1180
|
+
def precision
|
1181
|
+
__is_implicit? ? __sb2(OCI_ATTR_PRECISION) : __ub1(OCI_ATTR_PRECISION)
|
1182
|
+
end
|
1183
|
+
|
1184
|
+
# The scale of numeric type attributes. If the precision is
|
1185
|
+
# nonzero and scale is -127, then it is a FLOAT, else it is a
|
1186
|
+
# NUMBER(precision, scale). For the case when precision is 0,
|
1187
|
+
# NUMBER(precision, scale) can be represented simply as NUMBER.
|
1188
|
+
def scale
|
1189
|
+
__sb1(OCI_ATTR_SCALE)
|
1190
|
+
end
|
1191
|
+
|
1192
|
+
# A string which is the type name. The returned value will
|
1193
|
+
# contain the type name if the datatype is <tt>:named_type</tt> or <tt>:ref</tt>.
|
1194
|
+
# If the datatype is <tt>:named_type</tt>, the name of the named datatype's
|
1195
|
+
# type is returned. If the datatype is <tt>:ref</tt>, the type name
|
1196
|
+
# of the named datatype pointed to by the REF is returned.
|
1197
|
+
def type_name
|
1198
|
+
__text(OCI_ATTR_TYPE_NAME)
|
1199
|
+
end
|
1200
|
+
|
1201
|
+
# schema name where the type has been created.
|
1202
|
+
def schema_name
|
1203
|
+
__text(OCI_ATTR_SCHEMA_NAME)
|
1204
|
+
end
|
1205
|
+
|
1206
|
+
# to type metadata if possible
|
1207
|
+
def type_metadata
|
1208
|
+
__type_metadata(OCI8::Metadata::Type)
|
1209
|
+
end
|
1210
|
+
|
1211
|
+
# character set id if the type attribute is of a string/character type.
|
1212
|
+
def charset_id
|
1213
|
+
__ub2(OCI_ATTR_CHARSET_ID)
|
1214
|
+
end
|
1215
|
+
|
1216
|
+
# character set form, if the type attribute is of a string/character type.
|
1217
|
+
def charset_form
|
1218
|
+
__charset_form
|
1219
|
+
end
|
1220
|
+
|
1221
|
+
# character set name if the type attribute is of a string/character type.
|
1222
|
+
def charset_name
|
1223
|
+
__charset_name(charset_id)
|
1224
|
+
end
|
1225
|
+
|
1226
|
+
def inspect # :nodoc:
|
1227
|
+
"#<#{self.class.name}: #{__type_string}>"
|
1228
|
+
end
|
1229
|
+
end
|
1230
|
+
|
1231
|
+
# Metadata for a synonym.
|
1232
|
+
#
|
1233
|
+
# This is returned by:
|
1234
|
+
# * OCI8#describe_any(name)
|
1235
|
+
# * OCI8#describe_synonym(name)
|
1236
|
+
# * OCI8::Metadata::Schema#all_objects
|
1237
|
+
# * OCI8::Metadata::Schema#objects
|
1238
|
+
class Synonym < Base
|
1239
|
+
register_ptype OCI_PTYPE_SYN
|
1240
|
+
|
1241
|
+
## Table 6-11 Attributes Belonging to Synonyms
|
1242
|
+
|
1243
|
+
# object id
|
1244
|
+
def objid
|
1245
|
+
@objid ||= __ub4(OCI_ATTR_OBJID)
|
1246
|
+
end
|
1247
|
+
|
1248
|
+
# schema name of the synonym translation
|
1249
|
+
def schema_name
|
1250
|
+
@schema_name ||= __text(OCI_ATTR_SCHEMA_NAME)
|
1251
|
+
end
|
1252
|
+
|
1253
|
+
# object name of the synonym translation
|
1254
|
+
def name
|
1255
|
+
@name ||= __text(OCI_ATTR_NAME)
|
1256
|
+
end
|
1257
|
+
|
1258
|
+
# database link name of the synonym translation or nil
|
1259
|
+
def link
|
1260
|
+
@link ||= __text(OCI_ATTR_LINK)
|
1261
|
+
@link.size == 0 ? nil : @link
|
1262
|
+
end
|
1263
|
+
|
1264
|
+
# full-qualified synonym translation name with schema, object and database link name.
|
1265
|
+
def translated_name
|
1266
|
+
if link.nil?
|
1267
|
+
schema_name + '.' + name
|
1268
|
+
else
|
1269
|
+
schema_name + '.' + name + '@' + link
|
1270
|
+
end
|
1271
|
+
end
|
1272
|
+
|
1273
|
+
def inspect # :nodoc:
|
1274
|
+
"#<#{self.class.name}:(#{obj_id}) #{obj_schema}.#{obj_name}>"
|
1275
|
+
end
|
1276
|
+
end
|
1277
|
+
|
1278
|
+
# Metadata for a sequence.
|
1279
|
+
#
|
1280
|
+
# This is returned by:
|
1281
|
+
# * OCI8#describe_any(name)
|
1282
|
+
# * OCI8#describe_sequence(name)
|
1283
|
+
# * OCI8::Metadata::Schema#all_objects
|
1284
|
+
# * OCI8::Metadata::Schema#objects
|
1285
|
+
class Sequence < Base
|
1286
|
+
register_ptype OCI_PTYPE_SEQ
|
1287
|
+
|
1288
|
+
## Table 6-12 Attributes Belonging to Sequences
|
1289
|
+
|
1290
|
+
# object id
|
1291
|
+
def objid
|
1292
|
+
__ub4(OCI_ATTR_OBJID)
|
1293
|
+
end
|
1294
|
+
|
1295
|
+
# minimum value
|
1296
|
+
def min
|
1297
|
+
__oraint(OCI_ATTR_MIN)
|
1298
|
+
end
|
1299
|
+
|
1300
|
+
# maximum value
|
1301
|
+
def max
|
1302
|
+
__oraint(OCI_ATTR_MAX)
|
1303
|
+
end
|
1304
|
+
|
1305
|
+
# increment
|
1306
|
+
def incr
|
1307
|
+
__oraint(OCI_ATTR_INCR)
|
1308
|
+
end
|
1309
|
+
|
1310
|
+
# number of sequence numbers cached; zero if the sequence is not a cached sequence.
|
1311
|
+
def cache
|
1312
|
+
__oraint(OCI_ATTR_CACHE)
|
1313
|
+
end
|
1314
|
+
|
1315
|
+
# whether the sequence is ordered
|
1316
|
+
def order?
|
1317
|
+
__boolean(OCI_ATTR_ORDER)
|
1318
|
+
end
|
1319
|
+
|
1320
|
+
# high-water mark
|
1321
|
+
def hw_mark
|
1322
|
+
__oraint(OCI_ATTR_HW_MARK)
|
1323
|
+
end
|
1324
|
+
end
|
1325
|
+
|
1326
|
+
# Metadata for a sequence.
|
1327
|
+
#
|
1328
|
+
# This is returned by:
|
1329
|
+
# * OCI8::Metadata::Table#columns
|
1330
|
+
class Column < Base
|
1331
|
+
register_ptype OCI_PTYPE_COL
|
1332
|
+
|
1333
|
+
## Table 6-13 Attributes Belonging to Columns of Tables or Views
|
1334
|
+
|
1335
|
+
if OCI8.oracle_client_version >= ORAVER_9_0
|
1336
|
+
# returns the type of length semantics of the column.
|
1337
|
+
# [<tt>:byte</tt>] byte-length semantics
|
1338
|
+
# [<tt>:char</tt>] character-length semantics.
|
1339
|
+
#
|
1340
|
+
# (unavailable on Oracle 8.1 or lower)
|
1341
|
+
def char_used?
|
1342
|
+
__ub4(OCI_ATTR_CHAR_USED) != 0
|
1343
|
+
end
|
1344
|
+
|
1345
|
+
# returns the column character length which is the number of
|
1346
|
+
# characters allowed in the column. It is the counterpart of
|
1347
|
+
# OCI8::Metadata::Column#data_size which gets the byte length.
|
1348
|
+
def char_size
|
1349
|
+
__ub2(OCI_ATTR_CHAR_SIZE)
|
1350
|
+
end
|
1351
|
+
else
|
1352
|
+
def char_used?
|
1353
|
+
false
|
1354
|
+
end
|
1355
|
+
|
1356
|
+
def char_size
|
1357
|
+
data_size
|
1358
|
+
end
|
1359
|
+
end
|
1360
|
+
|
1361
|
+
# The maximum size of the column. This length is
|
1362
|
+
# returned in bytes and not characters for strings and raws.
|
1363
|
+
# This returns character length multiplied by NLS ratio for
|
1364
|
+
# character-length semantics columns when using Oracle 9i
|
1365
|
+
# or upper.
|
1366
|
+
def data_size
|
1367
|
+
__ub2_nc(OCI_ATTR_DATA_SIZE)
|
1368
|
+
end
|
1369
|
+
|
1370
|
+
# the datatype of the column.
|
1371
|
+
def data_type
|
1372
|
+
__data_type
|
1373
|
+
end
|
1374
|
+
|
1375
|
+
# column name
|
1376
|
+
def name
|
1377
|
+
__text(OCI_ATTR_NAME)
|
1378
|
+
end
|
1379
|
+
|
1380
|
+
# The precision of numeric columns. If the precision is nonzero
|
1381
|
+
# and scale is -127, then it is a FLOAT, else it is a
|
1382
|
+
# NUMBER(precision, scale). For the case when precision is 0,
|
1383
|
+
# NUMBER(precision, scale) can be represented simply as NUMBER.
|
1384
|
+
def precision
|
1385
|
+
__is_implicit? ? __sb2(OCI_ATTR_PRECISION) : __ub1(OCI_ATTR_PRECISION)
|
1386
|
+
end
|
1387
|
+
|
1388
|
+
# The scale of numeric columns. If the precision is nonzero and
|
1389
|
+
# scale is -127, then it is a FLOAT, else it is a
|
1390
|
+
# NUMBER(precision, scale). For the case when precision is 0,
|
1391
|
+
# NUMBER(precision, scale) can be represented simply as NUMBER.
|
1392
|
+
def scale
|
1393
|
+
__sb1(OCI_ATTR_SCALE)
|
1394
|
+
end
|
1395
|
+
|
1396
|
+
# Returns 0 if null values are not permitted for the column
|
1397
|
+
def nullable?
|
1398
|
+
__boolean(OCI_ATTR_IS_NULL)
|
1399
|
+
end
|
1400
|
+
|
1401
|
+
# Returns a string which is the type name. The returned value
|
1402
|
+
# will contain the type name if the datatype is <tt>:named_type</tt> or
|
1403
|
+
# <tt>:ref</tt>. If the datatype is <tt>:named_type</tt>, the name of the named
|
1404
|
+
# datatype's type is returned. If the datatype is <tt>:ref</tt>, the
|
1405
|
+
# type name of the named datatype pointed to by the REF is
|
1406
|
+
# returned
|
1407
|
+
def type_name
|
1408
|
+
rv = __text(OCI_ATTR_TYPE_NAME)
|
1409
|
+
rv.length == 0 ? nil : rv
|
1410
|
+
end
|
1411
|
+
|
1412
|
+
# Returns a string with the schema name under which the type has been created
|
1413
|
+
def schema_name
|
1414
|
+
rv = __text(OCI_ATTR_SCHEMA_NAME)
|
1415
|
+
rv.length == 0 ? nil : rv
|
1416
|
+
end
|
1417
|
+
|
1418
|
+
# to type metadata if possible
|
1419
|
+
def type_metadata
|
1420
|
+
case __ub2(OCI_ATTR_DATA_TYPE)
|
1421
|
+
when 108, 110 # named_type or ref
|
1422
|
+
__type_metadata(OCI8::Metadata::Type)
|
1423
|
+
else
|
1424
|
+
nil
|
1425
|
+
end
|
1426
|
+
end
|
1427
|
+
|
1428
|
+
# The character set id, if the column is of a string/character type
|
1429
|
+
def charset_id
|
1430
|
+
__ub2(OCI_ATTR_CHARSET_ID)
|
1431
|
+
end
|
1432
|
+
|
1433
|
+
# The character set form, if the column is of a string/character type
|
1434
|
+
def charset_form
|
1435
|
+
__charset_form
|
1436
|
+
end
|
1437
|
+
|
1438
|
+
## Table 6-8 Attributes Belonging to Type Attributes
|
1439
|
+
## But Column also have these.
|
1440
|
+
|
1441
|
+
if OCI8.oracle_client_version >= ORAVER_9_0
|
1442
|
+
# The fractional seconds precision of a datetime or interval.
|
1443
|
+
#
|
1444
|
+
# (unavailable on Oracle 8.1 or lower)
|
1445
|
+
def fsprecision
|
1446
|
+
__ub1(OCI_ATTR_FSPRECISION)
|
1447
|
+
end
|
1448
|
+
|
1449
|
+
# The leading field precision of an interval
|
1450
|
+
#
|
1451
|
+
# (unavailable on Oracle 8.1 or lower)
|
1452
|
+
def lfprecision
|
1453
|
+
__ub1(OCI_ATTR_LFPRECISION)
|
1454
|
+
end
|
1455
|
+
end
|
1456
|
+
|
1457
|
+
# The character set name, if the column is of a string/character type
|
1458
|
+
def charset_name
|
1459
|
+
__charset_name(charset_id)
|
1460
|
+
end
|
1461
|
+
|
1462
|
+
def type_string
|
1463
|
+
__type_string
|
1464
|
+
end
|
1465
|
+
|
1466
|
+
def to_s
|
1467
|
+
%Q{"#{name}" #{__type_string}}
|
1468
|
+
end
|
1469
|
+
|
1470
|
+
def inspect # :nodoc:
|
1471
|
+
"#<#{self.class.name}: #{name} #{__type_string}>"
|
1472
|
+
end
|
1473
|
+
end
|
1474
|
+
|
1475
|
+
# Abstract super class of Argument, TypeArgument and TypeResult.
|
1476
|
+
class ArgBase < Base
|
1477
|
+
## Table 6-14 Attributes Belonging to Arguments/Results
|
1478
|
+
|
1479
|
+
# the argument name
|
1480
|
+
def name
|
1481
|
+
__text(OCI_ATTR_NAME)
|
1482
|
+
end
|
1483
|
+
|
1484
|
+
# the position of the argument in the argument list.
|
1485
|
+
def position
|
1486
|
+
__ub2(OCI_ATTR_POSITION)
|
1487
|
+
end
|
1488
|
+
|
1489
|
+
# typecode
|
1490
|
+
def typecode
|
1491
|
+
__typecode(OCI_ATTR_TYPECODE)
|
1492
|
+
end
|
1493
|
+
|
1494
|
+
# the datatype of the argument
|
1495
|
+
def data_type
|
1496
|
+
__data_type
|
1497
|
+
end
|
1498
|
+
|
1499
|
+
# The size of the datatype of the argument. This length is
|
1500
|
+
# returned in bytes and not characters for strings and raws. It
|
1501
|
+
# returns 22 for NUMBERs.
|
1502
|
+
def data_size
|
1503
|
+
__ub2_nc(OCI_ATTR_DATA_SIZE)
|
1504
|
+
end
|
1505
|
+
|
1506
|
+
# The precision of numeric arguments. If the precision is
|
1507
|
+
# nonzero and scale is -127, then it is a FLOAT, else it is a
|
1508
|
+
# NUMBER(precision, scale). For the case when precision is 0,
|
1509
|
+
# NUMBER(precision, scale) can be represented simply as NUMBER.
|
1510
|
+
def precision
|
1511
|
+
__is_implicit? ? __sb2(OCI_ATTR_PRECISION) : __ub1(OCI_ATTR_PRECISION)
|
1512
|
+
end
|
1513
|
+
|
1514
|
+
# The scale of numeric arguments. If the precision is nonzero
|
1515
|
+
# and scale is -127, then it is a FLOAT, else it is a
|
1516
|
+
# NUMBER(precision, scale). For the case when precision is 0,
|
1517
|
+
# NUMBER(precision, scale) can be represented simply as NUMBER.
|
1518
|
+
def scale
|
1519
|
+
__sb1(OCI_ATTR_SCALE)
|
1520
|
+
end
|
1521
|
+
|
1522
|
+
# The datatype levels. This attribute always returns zero.
|
1523
|
+
def level
|
1524
|
+
__ub2(OCI_ATTR_LEVEL)
|
1525
|
+
end
|
1526
|
+
|
1527
|
+
# Indicates whether an argument has a default
|
1528
|
+
def has_default
|
1529
|
+
__ub1(OCI_ATTR_HAS_DEFAULT)
|
1530
|
+
end
|
1531
|
+
|
1532
|
+
# The list of arguments at the next level (when the argument is
|
1533
|
+
# of a record or table type).
|
1534
|
+
def list_arguments
|
1535
|
+
__param(OCI_ATTR_LIST_ARGUMENTS)
|
1536
|
+
end
|
1537
|
+
private :list_arguments
|
1538
|
+
|
1539
|
+
# Indicates the argument mode. Values are <tt>:in</tt>,
|
1540
|
+
# <tt>:out</tt> or <tt>:inout</tt>
|
1541
|
+
def iomode
|
1542
|
+
case __ub4(OCI_ATTR_IOMODE)
|
1543
|
+
when 0; :in
|
1544
|
+
when 1; :out
|
1545
|
+
when 2; :inout
|
1546
|
+
end
|
1547
|
+
end
|
1548
|
+
|
1549
|
+
# Returns a radix (if number type)
|
1550
|
+
def radix
|
1551
|
+
__ub1(OCI_ATTR_RADIX)
|
1552
|
+
end
|
1553
|
+
|
1554
|
+
# doesn't work.
|
1555
|
+
# def nullable?
|
1556
|
+
# __boolean(OCI_ATTR_IS_NULL)
|
1557
|
+
# end
|
1558
|
+
|
1559
|
+
# Returns a string which is the type name, or the package name
|
1560
|
+
# in the case of package local types. The returned value will
|
1561
|
+
# contain the type name if the datatype is <tt>:named_type</tt> or
|
1562
|
+
# <tt>:ref</tt>. If the datatype is <tt>:named_type</tt>, the name of the named
|
1563
|
+
# datatype's type is returned. If the datatype is <tt>:ref</tt>, the type
|
1564
|
+
# name of the named datatype pointed to by the REF is returned.
|
1565
|
+
def type_name
|
1566
|
+
__text(OCI_ATTR_TYPE_NAME)
|
1567
|
+
end
|
1568
|
+
|
1569
|
+
# For <tt>:named_type</tt> or <tt>:ref</tt>, returns a string with the schema name
|
1570
|
+
# under which the type was created, or under which the package
|
1571
|
+
# was created in the case of package local types
|
1572
|
+
def schema_name
|
1573
|
+
__text(OCI_ATTR_SCHEMA_NAME)
|
1574
|
+
end
|
1575
|
+
|
1576
|
+
# For <tt>:named_type</tt> or <tt>:ref</tt>, returns a string with the type name,
|
1577
|
+
# in the case of package local types
|
1578
|
+
def sub_name
|
1579
|
+
__text(OCI_ATTR_SUB_NAME)
|
1580
|
+
end
|
1581
|
+
|
1582
|
+
# For <tt>:named_type</tt> or <tt>:ref</tt>, returns a string with the database
|
1583
|
+
# link name of the database on which the type exists. This can
|
1584
|
+
# happen only in the case of package local types, when the
|
1585
|
+
# package is remote.
|
1586
|
+
def link
|
1587
|
+
__text(OCI_ATTR_LINK)
|
1588
|
+
end
|
1589
|
+
|
1590
|
+
# to type metadata if possible
|
1591
|
+
def type_metadata
|
1592
|
+
__type_metadata(OCI8::Metadata::Type)
|
1593
|
+
end
|
1594
|
+
|
1595
|
+
# Returns the character set ID if the argument is of a
|
1596
|
+
# string/character type
|
1597
|
+
def charset_id
|
1598
|
+
__ub2(OCI_ATTR_CHARSET_ID)
|
1599
|
+
end
|
1600
|
+
|
1601
|
+
# Returns the character set form if the argument is of a
|
1602
|
+
# string/character type
|
1603
|
+
def charset_form
|
1604
|
+
__charset_form
|
1605
|
+
end
|
1606
|
+
|
1607
|
+
# Returns the character set name if the argument is of a
|
1608
|
+
# string/character type
|
1609
|
+
def charset_name
|
1610
|
+
__charset_name(charset_id)
|
1611
|
+
end
|
1612
|
+
|
1613
|
+
# The list of arguments at the next level (when the argument is
|
1614
|
+
# of a record or table type).
|
1615
|
+
def arguments
|
1616
|
+
@arguments ||= list_arguments.to_a
|
1617
|
+
end
|
1618
|
+
|
1619
|
+
def inspect # :nodoc:
|
1620
|
+
"#<#{self.class.name}: #{name} #{__type_string}>"
|
1621
|
+
end
|
1622
|
+
end
|
1623
|
+
|
1624
|
+
# Metadata for a argument.
|
1625
|
+
#
|
1626
|
+
# This is returned by:
|
1627
|
+
# * OCI8::Metadata::Procedure#arguments
|
1628
|
+
# * OCI8::Metadata::Function#arguments
|
1629
|
+
#
|
1630
|
+
# See ArgBase's methods.
|
1631
|
+
class Argument < ArgBase
|
1632
|
+
register_ptype OCI_PTYPE_ARG
|
1633
|
+
end
|
1634
|
+
|
1635
|
+
# Metadata for a argument.
|
1636
|
+
#
|
1637
|
+
# This is returned by:
|
1638
|
+
# * OCI8::Metadata::TypeMethod#arguments
|
1639
|
+
#
|
1640
|
+
# See ArgBase's methods.
|
1641
|
+
class TypeArgument < ArgBase
|
1642
|
+
register_ptype OCI_PTYPE_TYPE_ARG
|
1643
|
+
end
|
1644
|
+
|
1645
|
+
# Metadata for a argument.
|
1646
|
+
#
|
1647
|
+
# This is returned by: .... unknown.
|
1648
|
+
# What's method returns this value?
|
1649
|
+
#
|
1650
|
+
# See ArgBase's methods.
|
1651
|
+
class TypeResult < ArgBase
|
1652
|
+
register_ptype OCI_PTYPE_TYPE_RESULT
|
1653
|
+
end
|
1654
|
+
|
1655
|
+
# internal use only.
|
1656
|
+
class List < Base # :nodoc:
|
1657
|
+
register_ptype OCI_PTYPE_LIST
|
1658
|
+
|
1659
|
+
## Table 6-15 List Attributes
|
1660
|
+
|
1661
|
+
if OCI8::oracle_client_version < OCI8::ORAVER_8_1
|
1662
|
+
def ltype
|
1663
|
+
raise "This feature is unavailable on Oracle 8.0"
|
1664
|
+
end
|
1665
|
+
else
|
1666
|
+
def ltype
|
1667
|
+
__ub2(OCI_ATTR_LTYPE)
|
1668
|
+
end
|
1669
|
+
end
|
1670
|
+
|
1671
|
+
# convert to array
|
1672
|
+
def to_a
|
1673
|
+
# Table 6-15 List Attributes
|
1674
|
+
case ltype
|
1675
|
+
when OCI_LTYPE_COLUMN; offset = 1
|
1676
|
+
when OCI_LTYPE_ARG_PROC; offset = 1
|
1677
|
+
when OCI_LTYPE_ARG_FUNC; offset = 0
|
1678
|
+
when OCI_LTYPE_SUBPRG; offset = 0
|
1679
|
+
when OCI_LTYPE_TYPE_ATTR; offset = 1
|
1680
|
+
when OCI_LTYPE_TYPE_METHOD; offset = 1
|
1681
|
+
when OCI_LTYPE_TYPE_ARG_PROC; offset = 0
|
1682
|
+
when OCI_LTYPE_TYPE_ARG_FUNC; offset = 1
|
1683
|
+
when OCI_LTYPE_SCH_OBJ; offset = 0
|
1684
|
+
when OCI_LTYPE_DB_SCH; offset = 0
|
1685
|
+
#when OCI_LTYPE_TYPE_SUBTYPE; offset = ?
|
1686
|
+
#when OCI_LTYPE_TABLE_ALIAS; offset = ?
|
1687
|
+
#when OCI_LTYPE_VARIABLE_TYPE; offset = ?
|
1688
|
+
#when OCI_LTYPE_NAME_VALUE; offset = ?
|
1689
|
+
else
|
1690
|
+
raise NotImplementedError, "unsupported list type #{list.ltype}"
|
1691
|
+
end
|
1692
|
+
ary = []
|
1693
|
+
0.upto(num_params - 1) do |i|
|
1694
|
+
ary << __param_at(i + offset)
|
1695
|
+
end
|
1696
|
+
ary
|
1697
|
+
end
|
1698
|
+
end
|
1699
|
+
|
1700
|
+
# Metadata for a schema.
|
1701
|
+
#
|
1702
|
+
# This is returned by:
|
1703
|
+
# * OCI8#describe_schema(schema_name)
|
1704
|
+
# * OCI8::Metadata::Database#schemas
|
1705
|
+
class Schema < Base
|
1706
|
+
register_ptype OCI_PTYPE_SCHEMA
|
1707
|
+
|
1708
|
+
## Table 6-16 Attributes Specific to Schemas
|
1709
|
+
|
1710
|
+
def list_objects
|
1711
|
+
__param(OCI_ATTR_LIST_OBJECTS)
|
1712
|
+
end
|
1713
|
+
private :list_objects
|
1714
|
+
|
1715
|
+
# array of objects in the schema.
|
1716
|
+
# This includes unusable objects.
|
1717
|
+
def all_objects
|
1718
|
+
unless @all_objects
|
1719
|
+
begin
|
1720
|
+
objs = list_objects
|
1721
|
+
rescue OCIError => exc
|
1722
|
+
if exc.code != -1
|
1723
|
+
raise
|
1724
|
+
end
|
1725
|
+
# describe again.
|
1726
|
+
objs = __con.describe_schema(obj_schema).list_objects
|
1727
|
+
end
|
1728
|
+
@all_objects = objs.to_a
|
1729
|
+
end
|
1730
|
+
@all_objects
|
1731
|
+
end
|
1732
|
+
|
1733
|
+
# array of objects in the schema.
|
1734
|
+
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
|
1748
|
+
false
|
1749
|
+
end
|
1750
|
+
end
|
1751
|
+
end
|
1752
|
+
@objects
|
1753
|
+
end
|
1754
|
+
|
1755
|
+
def inspect # :nodoc:
|
1756
|
+
"#<#{self.class.name}:(#{obj_id}) #{obj_schema}>"
|
1757
|
+
end
|
1758
|
+
end
|
1759
|
+
|
1760
|
+
# Metadata for a database.
|
1761
|
+
#
|
1762
|
+
# This is returned by:
|
1763
|
+
# * OCI8#describe_database(database_name)
|
1764
|
+
class Database < Base
|
1765
|
+
register_ptype OCI_PTYPE_DATABASE
|
1766
|
+
|
1767
|
+
# Table 6-17 Attributes Specific to Databases
|
1768
|
+
|
1769
|
+
# database version
|
1770
|
+
def version
|
1771
|
+
__text(OCI_ATTR_VERSION)
|
1772
|
+
end
|
1773
|
+
|
1774
|
+
# database character set Id
|
1775
|
+
def charset_id
|
1776
|
+
__ub2(OCI_ATTR_CHARSET_ID)
|
1777
|
+
end
|
1778
|
+
|
1779
|
+
# database national language support character set Id
|
1780
|
+
def ncharset_id
|
1781
|
+
__ub2(OCI_ATTR_NCHARSET_ID)
|
1782
|
+
end
|
1783
|
+
|
1784
|
+
# List of schemas in the database
|
1785
|
+
def list_schemas
|
1786
|
+
__param(OCI_ATTR_LIST_SCHEMAS)
|
1787
|
+
end
|
1788
|
+
private :list_schemas
|
1789
|
+
|
1790
|
+
# Maximum length of a procedure name
|
1791
|
+
def max_proc_len
|
1792
|
+
__ub4(OCI_ATTR_MAX_PROC_LEN)
|
1793
|
+
end
|
1794
|
+
|
1795
|
+
# Maximum length of a column name
|
1796
|
+
def max_column_len
|
1797
|
+
__ub4(OCI_ATTR_MAX_COLUMN_LEN)
|
1798
|
+
end
|
1799
|
+
|
1800
|
+
# How a COMMIT operation affects cursors and prepared statements in
|
1801
|
+
# the database. Values are:
|
1802
|
+
# [<tt>:cusror_open</tt>] preserve cursor state as before the commit
|
1803
|
+
# operation
|
1804
|
+
# [<tt>:cursor_closed</tt>] cursors are closed on COMMIT, but the
|
1805
|
+
# application can still re-execute the
|
1806
|
+
# statement without re-preparing it
|
1807
|
+
def cursor_commit_behavior
|
1808
|
+
case __ub1(OCI_ATTR_CURSOR_COMMIT_BEHAVIOR)
|
1809
|
+
when 0; :cusror_open
|
1810
|
+
when 1; :cursor_closed
|
1811
|
+
end
|
1812
|
+
end
|
1813
|
+
|
1814
|
+
# Maximum length of a catalog (database) name
|
1815
|
+
def max_catalog_namelen
|
1816
|
+
__ub1(OCI_ATTR_MAX_CATALOG_NAMELEN)
|
1817
|
+
end
|
1818
|
+
|
1819
|
+
# Position of the catalog in a qualified table. Values are
|
1820
|
+
# <tt>:cl_start</tt> and <tt>:cl_end</tt>
|
1821
|
+
def catalog_location
|
1822
|
+
case __ub1(OCI_ATTR_CATALOG_LOCATION)
|
1823
|
+
when 0; :cl_start
|
1824
|
+
when 1; :cl_end
|
1825
|
+
end
|
1826
|
+
end
|
1827
|
+
|
1828
|
+
# Does database support savepoints? Values are
|
1829
|
+
# <tt>:sp_supported</tt> and <tt>:sp_unsupported</tt>
|
1830
|
+
def savepoint_support
|
1831
|
+
case __ub1(OCI_ATTR_SAVEPOINT_SUPPORT)
|
1832
|
+
when 0; :sp_supported
|
1833
|
+
when 1; :sp_unsupported
|
1834
|
+
end
|
1835
|
+
end
|
1836
|
+
|
1837
|
+
# Does database support the nowait clause? Values are
|
1838
|
+
# <tt>:nw_supported</tt> and <tt>:nw_unsupported</tt>
|
1839
|
+
def nowait_support
|
1840
|
+
case __ub1(OCI_ATTR_NOWAIT_SUPPORT)
|
1841
|
+
when 0; :nw_supported
|
1842
|
+
when 1; :nw_unsupported
|
1843
|
+
end
|
1844
|
+
end
|
1845
|
+
|
1846
|
+
# Is autocommit mode required for DDL statements? Values are
|
1847
|
+
# <tt>:ac_ddl</tt> and <tt>:no_ac_ddl</tt>
|
1848
|
+
def autocommit_ddl
|
1849
|
+
case __ub1(OCI_ATTR_AUTOCOMMIT_DDL)
|
1850
|
+
when 0; :ac_ddl
|
1851
|
+
when 1; :no_ac_ddl
|
1852
|
+
end
|
1853
|
+
end
|
1854
|
+
|
1855
|
+
# Locking mode for the database. Values are <tt>:lock_immediate</tt> and
|
1856
|
+
# <tt>:lock_delayed</tt>
|
1857
|
+
def locking_mode
|
1858
|
+
case __ub1(OCI_ATTR_LOCKING_MODE)
|
1859
|
+
when 0; :lock_immediate
|
1860
|
+
when 1; :lock_delayed
|
1861
|
+
end
|
1862
|
+
end
|
1863
|
+
|
1864
|
+
# database character set name
|
1865
|
+
def charset_name
|
1866
|
+
__charset_name(charset_id)
|
1867
|
+
end
|
1868
|
+
|
1869
|
+
# database national language support character set name
|
1870
|
+
def ncharset_name
|
1871
|
+
__charset_name(ncharset_id)
|
1872
|
+
end
|
1873
|
+
|
1874
|
+
# array of Schema objects in the database
|
1875
|
+
def schemas
|
1876
|
+
@schemas ||= list_schemas.to_a
|
1877
|
+
end
|
1878
|
+
|
1879
|
+
def inspect # :nodoc:
|
1880
|
+
"#<#{self.class.name}:(#{obj_id}) #{obj_name} #{version}>"
|
1881
|
+
end
|
1882
|
+
end
|
1883
|
+
|
1884
|
+
=begin
|
1885
|
+
class Rule < Base # :nodoc:
|
1886
|
+
register_ptype OCI_PTYPE_RULE
|
1887
|
+
|
1888
|
+
# Table 6-18 Attributes Specific to Rules
|
1889
|
+
|
1890
|
+
def condition
|
1891
|
+
__text(OCI_ATTR_CONDITION)
|
1892
|
+
end
|
1893
|
+
|
1894
|
+
def eval_context_owner
|
1895
|
+
__text(OCI_ATTR_EVAL_CONTEXT_OWNER)
|
1896
|
+
end
|
1897
|
+
|
1898
|
+
def eval_context_name
|
1899
|
+
__text(OCI_ATTR_EVAL_CONTEXT_NAME)
|
1900
|
+
end
|
1901
|
+
|
1902
|
+
def comment
|
1903
|
+
__text(OCI_ATTR_COMMENT)
|
1904
|
+
end
|
1905
|
+
|
1906
|
+
# def list_action_context
|
1907
|
+
# __param(???)
|
1908
|
+
# end
|
1909
|
+
end
|
1910
|
+
|
1911
|
+
class RuleSet < Base # :nodoc:
|
1912
|
+
register_ptype OCI_PTYPE_RULE_SET
|
1913
|
+
|
1914
|
+
# Table 6-19 Attributes Specific to Rule Sets
|
1915
|
+
|
1916
|
+
def eval_context_owner
|
1917
|
+
__text(OCI_ATTR_EVAL_CONTEXT_OWNER)
|
1918
|
+
end
|
1919
|
+
|
1920
|
+
def eval_context_name
|
1921
|
+
__text(OCI_ATTR_EVAL_CONTEXT_NAME)
|
1922
|
+
end
|
1923
|
+
|
1924
|
+
def comment
|
1925
|
+
__text(OCI_ATTR_COMMENT)
|
1926
|
+
end
|
1927
|
+
|
1928
|
+
# def list_rules
|
1929
|
+
# __param(???)
|
1930
|
+
# end
|
1931
|
+
end
|
1932
|
+
|
1933
|
+
class EvaluationContext < Base # :nodoc:
|
1934
|
+
register_ptype OCI_PTYPE_EVALUATION_CONTEXT
|
1935
|
+
|
1936
|
+
# Table 6-20 Attributes Specific to Evaluation Contexts
|
1937
|
+
|
1938
|
+
def evaluation_function
|
1939
|
+
__text(OCI_ATTR_EVALUATION_FUNCTION)
|
1940
|
+
end
|
1941
|
+
|
1942
|
+
def comment
|
1943
|
+
__text(OCI_ATTR_COMMENT)
|
1944
|
+
end
|
1945
|
+
|
1946
|
+
def list_table_aliases
|
1947
|
+
__param(OCI_ATTR_LIST_TABLE_ALIASES)
|
1948
|
+
end
|
1949
|
+
|
1950
|
+
def list_variable_types
|
1951
|
+
__param(OCI_ATTR_LIST_VARIABLE_TYPES)
|
1952
|
+
end
|
1953
|
+
end
|
1954
|
+
|
1955
|
+
class TableAlias < Base # :nodoc:
|
1956
|
+
register_ptype OCI_PTYPE_TABLE_ALIAS
|
1957
|
+
|
1958
|
+
# Table 6-21 Attributes Specific to Table Aliases
|
1959
|
+
|
1960
|
+
def name
|
1961
|
+
__text(OCI_ATTR_NAME)
|
1962
|
+
end
|
1963
|
+
|
1964
|
+
def table_name
|
1965
|
+
__text(OCI_ATTR_TABLE_NAME)
|
1966
|
+
end
|
1967
|
+
end
|
1968
|
+
|
1969
|
+
class VariableType < Base # :nodoc:
|
1970
|
+
register_ptype OCI_PTYPE_VARIABLE_TYPE
|
1971
|
+
|
1972
|
+
# Table 6-22 Attributes Specific to Variable Types
|
1973
|
+
|
1974
|
+
def name
|
1975
|
+
__text(OCI_ATTR_NAME)
|
1976
|
+
end
|
1977
|
+
|
1978
|
+
def var_type
|
1979
|
+
__text(OCI_ATTR_VAR_TYPE)
|
1980
|
+
end
|
1981
|
+
|
1982
|
+
def var_value_function
|
1983
|
+
__text(OCI_ATTR_VAR_VALUE_FUNCTION)
|
1984
|
+
end
|
1985
|
+
|
1986
|
+
def var_method_function
|
1987
|
+
__text(OCI_ATTR_VAR_METHOD_FUNCTION)
|
1988
|
+
end
|
1989
|
+
end
|
1990
|
+
|
1991
|
+
class NameValue < Base # :nodoc:
|
1992
|
+
register_ptype OCI_PTYPE_NAME_VALUE
|
1993
|
+
|
1994
|
+
# Table 6-23 Attributes Specific to Name Value Pair
|
1995
|
+
|
1996
|
+
def name
|
1997
|
+
__text(OCI_ATTR_NAME)
|
1998
|
+
end
|
1999
|
+
|
2000
|
+
# not implemented
|
2001
|
+
def value
|
2002
|
+
__anydata(OCI_ATTR_VALUE)
|
2003
|
+
end
|
2004
|
+
end
|
2005
|
+
=end
|
2006
|
+
end # OCI8::Metadata
|
2007
|
+
|
2008
|
+
# return a subclass of OCI8::Metadata::Base
|
2009
|
+
# which has information about _object_name_.
|
2010
|
+
# OCI8::Metadata::Table, OCI8::Metadata::View,
|
2011
|
+
# OCI8::Metadata::Procedure, OCI8::Metadata::Function,
|
2012
|
+
# OCI8::Metadata::Package, OCI8::Metadata::Type,
|
2013
|
+
# OCI8::Metadata::Synonym or OCI8::Metadata::Sequence
|
2014
|
+
def describe_any(object_name)
|
2015
|
+
__describe(object_name, OCI8::Metadata::Unknown, true)
|
2016
|
+
end
|
2017
|
+
# returns a OCI8::Metadata::Table or a OCI8::Metadata::View. If the
|
2018
|
+
# name is a current schema's synonym name or a public synonym name,
|
2019
|
+
# it returns a OCI8::Metadata::Table or a OCI8::Metadata::View which
|
2020
|
+
# the synonym refers.
|
2021
|
+
#
|
2022
|
+
# If the second argument is true, this returns a
|
2023
|
+
# OCI8::Metadata::Table in the current schema.
|
2024
|
+
def describe_table(table_name, table_only = false)
|
2025
|
+
if table_only
|
2026
|
+
# check my own tables only.
|
2027
|
+
__describe(table_name, OCI8::Metadata::Table, false)
|
2028
|
+
else
|
2029
|
+
# check tables, views, synonyms and public synonyms.
|
2030
|
+
metadata = __describe(table_name, OCI8::Metadata::Unknown, true)
|
2031
|
+
case metadata
|
2032
|
+
when OCI8::Metadata::Table, OCI8::Metadata::View
|
2033
|
+
metadata
|
2034
|
+
when OCI8::Metadata::Synonym
|
2035
|
+
describe_table(metadata.translated_name)
|
2036
|
+
else
|
2037
|
+
raise OCIError.new("ORA-04043: object #{table_name} does not exist", 4043)
|
2038
|
+
end
|
2039
|
+
end
|
2040
|
+
end
|
2041
|
+
# returns a OCI8::Metadata::View in the current schema.
|
2042
|
+
def describe_view(view_name)
|
2043
|
+
__describe(view_name, OCI8::Metadata::View, false)
|
2044
|
+
end
|
2045
|
+
# returns a OCI8::Metadata::Procedure in the current schema.
|
2046
|
+
def describe_procedure(procedure_name)
|
2047
|
+
__describe(procedure_name, OCI8::Metadata::Procedure, false)
|
2048
|
+
end
|
2049
|
+
# returns a OCI8::Metadata::Function in the current schema.
|
2050
|
+
def describe_function(function_name)
|
2051
|
+
__describe(function_name, OCI8::Metadata::Function, false)
|
2052
|
+
end
|
2053
|
+
# returns a OCI8::Metadata::Package in the current schema.
|
2054
|
+
def describe_package(package_name)
|
2055
|
+
__describe(package_name, OCI8::Metadata::Package, false)
|
2056
|
+
end
|
2057
|
+
# returns a OCI8::Metadata::Type in the current schema.
|
2058
|
+
def describe_type(type_name)
|
2059
|
+
__describe(type_name, OCI8::Metadata::Type, false)
|
2060
|
+
end
|
2061
|
+
# returns a OCI8::Metadata::Synonym in the current schema.
|
2062
|
+
def describe_synonym(synonym_name, check_public_also = true)
|
2063
|
+
__describe(synonym_name, OCI8::Metadata::Synonym, check_public_also)
|
2064
|
+
end
|
2065
|
+
# returns a OCI8::Metadata::Sequence in the current schema.
|
2066
|
+
def describe_sequence(sequence_name)
|
2067
|
+
__describe(sequence_name, OCI8::Metadata::Sequence, false)
|
2068
|
+
end
|
2069
|
+
# returns a OCI8::Metadata::Schema in the database.
|
2070
|
+
def describe_schema(schema_name)
|
2071
|
+
__describe(schema_name, OCI8::Metadata::Schema, false)
|
2072
|
+
end
|
2073
|
+
# returns a OCI8::Metadata::Database.
|
2074
|
+
def describe_database(database_name)
|
2075
|
+
__describe(database_name, OCI8::Metadata::Database, false)
|
2076
|
+
end
|
2077
|
+
end # OCI8
|