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