ruby-oci8 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/doc/api.ja.html DELETED
@@ -1,525 +0,0 @@
1
- <?xml version="1.0" ?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
- <html xmlns="http://www.w3.org/1999/xhtml">
6
- <head>
7
- <title>Ruby/OCI8 High-level API</title>
8
- <link href="manual.css" type="text/css" rel="stylesheet" />
9
- </head>
10
- <body>
11
- <h1><a name="label-0" id="label-0">Ruby/OCI8 ���API</a></h1><!-- RDLabel: "Ruby/OCI8 ���API" -->
12
- <p>[ <a href="index.ja.html">Home</a> ] [ <a href="api.en.html">English</a> | Japanese ]</p>
13
- <p>Ruby/OCI8 ��2���ؤ� API ��ʬ����ޤ����ҤȤĤ�"����API"�ǡ��⤦��Ĥ�"
14
- ���API"�Ǥ��������ǤϾ��API�λ���ˡ����⤷�ޤ�������ϲ���API�˽�°
15
- ���륯�饹�Ǥ⡢���API ����Ѥ�����ɬ�פʥ��饹�Ϥ����Dz��⤷�ޤ���</p>
16
- <p>"���API"�� ruby �ǽ񤫤줿�饤�֥��ǡ�"����API"�ξ�˹��ۤ���Ƥ���
17
- ����ʣ���� OCI �ι�¤���ä��ơ��ʤ�٤�ñ��˻Ȥ���褦�ˤ��Ƥ����
18
- ��������Ū�����ӤǤϤ��� API ����Ѥ��Ƥ���������</p>
19
- <p>"����API"�� C ����ǽ񤫤줿�饤�֥��Ǥ���OCI<a name="footmark-1" id="footmark-1" href="#foottext-1"><sup><small>*1</small></sup></a>�Υϥ�ɥ�� ruby �Υ���
20
- ���ˡ�OCI �δؿ��� ruby �Υ᥽�åɤإޥåԥ󥰤��Ƥ���ޤ���ruby �� C
21
- ����θ�����ͤΰ㤤�ˤ�ꡢñ��ʥޥåԥ󥰤��Ǥ��ʤ��Ȥ����⤢��ޤ�
22
- ������ǽ�ʤ����긵�� API ���Ѥ��ʤ��褦�ˤ��Ƥ���ޤ���</p>
23
- <p>�С������ 0.2 �Ǥ� C ����Ǥ�äƾ��API��ľ�ܽ�ľ��������API�Ϥʤ�
24
- �ʤ�ͽ��Ǥ���</p>
25
- <h2><a name="label-1" id="label-1">�ܼ�</a></h2><!-- RDLabel: "�ܼ�" -->
26
- <ul>
27
- <li><a href="#label-2">���饹����</a>
28
- <ul>
29
- <li><a href="#label-3">OCI8</a></li>
30
- <li><a href="#label-4">OCI8::Cursor</a></li>
31
- <li><a href="#label-5">OCI8::BLOB</a></li>
32
- <li><a href="#label-6">OCI�㳰���饹</a></li>
33
- </ul></li>
34
- <li><a href="#label-7">�᥽�åɰ���</a>
35
- <ul>
36
- <li>OCI8
37
- <ul>
38
- <li><a href="#label-9">new</a>(userid, password, dbname = nil, privilege = nil)</li>
39
- <li><a href="#label-10">logoff</a>()</li>
40
- <li><a href="#label-11">exec</a>(sql, *bindvars)</li>
41
- <li><a href="#label-12">parse</a>(sql)</li>
42
- <li><a href="#label-13">commit</a>()</li>
43
- <li><a href="#label-14">rollback</a>()</li>
44
- <li><a href="#label-15">autocommit?</a></li>
45
- <li><a href="#label-16">autocommit</a></li>
46
- <li><a href="#label-17">autocommit=</a></li>
47
- <li><a href="#label-18">non_blocking?</a></li>
48
- <li><a href="#label-19">non_blocking=</a></li>
49
- <li><a href="#label-20">break</a>()</li>
50
- </ul></li>
51
- <li>OCI8::Cursor
52
- <ul>
53
- <li><a href="#label-22">define</a>(pos, type, length = nil)</li>
54
- <li><a href="#label-23">bind_param</a>(key, val, type = nil, length = nil)</li>
55
- <li><a href="#label-24">[]</a>(key)</li>
56
- <li><a href="#label-25">[]=</a>(key, val)</li>
57
- <li><a href="#label-26">keys</a>()</li>
58
- <li><a href="#label-27">exec</a>(*bindvars)</li>
59
- <li><a href="#label-28">type</a></li>
60
- <li><a href="#label-29">row_count</a></li>
61
- <li><a href="#label-30">get_col_names</a></li>
62
- <li><a href="#label-31">getColNames</a></li>
63
- <li><a href="#label-32">fetch</a>()</li>
64
- <li><a href="#label-33">close</a>()</li>
65
- <li><a href="#label-34">rowid</a></li>
66
- </ul></li>
67
- <li>OCI8::BLOB
68
- <ul>
69
- <li><a href="#label-36">available?</a></li>
70
- <li><a href="#label-37">read</a>(size = nil)</li>
71
- <li><a href="#label-38">write</a>(data)</li>
72
- <li><a href="#label-39">size</a></li>
73
- <li><a href="#label-40">size=</a>(len)</li>
74
- <li><a href="#label-41">chunk_size</a></li>
75
- <li><a href="#label-42">truncate</a>(len)</li>
76
- <li><a href="#label-43">pos</a></li>
77
- <li><a href="#label-44">pos=</a>(pos)</li>
78
- <li><a href="#label-46">tell</a></li>
79
- <li><a href="#label-47">seek</a>(pos)</li>
80
- <li><a href="#label-48">rewind</a></li>
81
- <li><a href="#label-45">eof?</a></li>
82
- </ul></li>
83
- </ul></li>
84
- <li><a href="#label-49">���</a>
85
- <ul>
86
- <li><a href="#label-50">�֥��å���/��֥��å��󥰥⡼��</a></li>
87
- </ul></li>
88
- </ul>
89
- <h2><a name="label-2" id="label-2">���饹����</a></h2><!-- RDLabel: "���饹����" -->
90
- <p>���API��ɬ�ܤʥ��饹�ϡ�<a href="#label-3">OCI8</a>, <a href="#label-4">OCI8::Cursor</a>, <a href="#label-5">OCI8::BLOB</a>,
91
- �����<a href="#label-6">OCI�㳰���饹</a>�Ǥ���</p>
92
- <h3><a name="label-3" id="label-3">OCI8</a></h3><!-- RDLabel: "OCI8" -->
93
- <p>���Υ��饹�Υ��󥹥��󥹤ϥǡ����١����ؤ���³���б����ޤ���JDBC ��
94
- java.sql.Connection, Perl/DBI �� database handle: $dbh ���б����ޤ���</p>
95
- <p>ñ��� SQL �μ¹Ԥʤ�С����Υ��饹�ΤߤǼ¹ԤǤ��ޤ���</p>
96
- <h3><a name="label-4" id="label-4">OCI8::Cursor</a></h3><!-- RDLabel: "OCI8::Cursor" -->
97
- <p>���Υ��饹�Υ��󥹥��󥹤ϥ��饯����Ѹ�Ǥϥ���������б����ޤ���JDBC
98
- �� java.sql.Statement, Perl/DBI �� statement handle: $sth ���б����ޤ���</p>
99
- <p>���Υ��饹�Υ��󥹥��󥹤� new �ˤ���������ʤ��Ǥ���������ɬ��
100
- <a href="#label-11">OCI8#exec</a>, <a href="#label-12">OCI8#parse</a> ��ͳ���������Ƥ���������</p>
101
- <h3><a name="label-5" id="label-5">OCI8::BLOB</a></h3><!-- RDLabel: "OCI8::BLOB" -->
102
- <p>BLOB �ΥХ��ʥ�ǡ������ɤ߽񤭤���Ȥ��˻��Ѥ��륯�饹�Ǥ���
103
- select ʸ�� BLOB ���Υ��������򤹤�Ȥ��Υ��饹�Υ��󥹥��󥹤���ư
104
- Ū����������ޤ���</p>
105
- <h3><a name="label-6" id="label-6">OCI�㳰���饹</a></h3><!-- RDLabel: "OCI�㳰���饹" -->
106
- <p>���API��ɬ�פ��㳰���饹�γ��ؤϰʲ��Τ褦�ˤʤäƤ��ޤ���</p>
107
- <ul>
108
- <li><var>OCIException</var>
109
- <ul>
110
- <li><var>OCIError</var></li>
111
- <li><var>OCIInvalidHandle</var></li>
112
- <li><var>OCIBreak</var></li>
113
- </ul></li>
114
- </ul>
115
- <p><var>OCIException</var>�� OCI �㳰����ݿƥ��饹�Ǥ���OCI ���㳰�򤹤٤���
116
- ­�������Ȥ��Ϥ��Υ��饹�� rescue �˻ȤäƤ���������</p>
117
- <p><var>OCIError</var>�ϥ��饯��Υ��顼�����ɤĤ����㳰���饹�Ǥ���
118
- OCIError#message �ǥ�å�������ʸ�����OCIErrror#code �ǥ��顼������
119
- ������Ǥ��ޤ���</p>
120
- <p><var>OCIInvalidHandle</var>��̵���ʥϥ�ɥ���Ф�������Ԥʤä��Ȥ��˵���
121
- ���㳰�Ǥ���</p>
122
- <p><var>OCIBreak</var>��<a href="#label-50">��֥��å��󥰥⡼��</a>
123
- ���̤Υ���åɤ�� OCI �ƽФ�������󥻥뤵�줿�Ȥ��˵������㳰�Ǥ���</p>
124
- <h2><a name="label-7" id="label-7">�᥽�åɰ���</a></h2><!-- RDLabel: "�᥽�åɰ���" -->
125
- <h3><a name="label-8" id="label-8">OCI8</a></h3><!-- RDLabel: "OCI8" -->
126
- <dl>
127
- <dt><a name="label-9" id="label-9"><code>OCI8.new(<var>userid</var>, <var>password</var>, <var>dbname</var> = <var>nil</var>, <var>privilege</var> = <var>nil</var>)</code></a></dt><!-- RDLabel: "OCI8.new" -->
128
- <dd>
129
- <p><var>userid</var>, <var>password</var> �Ǥ�äƥ��饯�����³���ޤ���<var>dbname</var> �� Net8 ��
130
- ��³ʸ����Ǥ���DBA ���¤�ɬ�פʾ��� <var>privilege</var> �� :SYSDBA �ޤ�
131
- �� :SYSOPER����ꤷ�ޤ���</p>
132
- <p>��:</p>
133
- <pre># sqlplus scott/tiger@orcl.world
134
- conn = OCI8.new("scott", "tiger", "orcl.world")</pre>
135
- <p>��:</p>
136
- <pre># sqlplus 'sys/change_on_install as sysdba'
137
- conn = OCI8.new("sys", "change_on_install", nil, :SYSDBA)</pre></dd>
138
- <dt><a name="label-10" id="label-10"><code>OCI8#logoff()</code></a></dt><!-- RDLabel: "OCI8#logoff" -->
139
- <dd>
140
- <p>���饯��Ȥ���³���ڤ�ޤ������ߥåȤ���Ƥʤ��ȥ�󥶥�������
141
- ������Хå�����ޤ���</p>
142
- <p>��:</p>
143
- <pre>conn = OCI8.new("scott", "tiger")
144
- ... do something ...
145
- conn.logoff</pre></dd>
146
- <dt><a name="label-11" id="label-11"><code>OCI8#exec(<var>sql</var>, *<var>bindvars</var>)</code></a></dt><!-- RDLabel: "OCI8#exec" -->
147
- <dd>
148
- <p>sql ʸ��¹Ԥ��ޤ���sql ʸ�� SELECTʸ��INSERT/UPDATE/DELETEʸ��
149
- CREATE/ALTER/DROPʸ��PL/SQLʸ�����줾���������ͤμ��ब�ۤʤ�
150
- �ޤ���</p>
151
- <p>bindvars �������硢�Х�����ѿ��Ȥ��ƥХ���ɤ��Ƥ���¹Ԥ��ޤ���</p>
152
- <p>SELECT ʸ�ǥ֥��å����Ĥ��Ƥʤ���硢OCI8::Cursor �Υ��󥹥���
153
- ���֤��ޤ���</p>
154
- <p>��:</p>
155
- <pre>conn = OCI8.new('scott', 'tiger')
156
- cursor = conn.exec('SELECT * FROM emp')
157
- while r = cursor.fetch()
158
- puts r.join(',')
159
- end
160
- cursor.close
161
- conn.logoff</pre>
162
- <p>SELECT ʸ�ǥ֥��å����Ĥ��Ƥ����硢���ƥ졼���Ȥ���ư��������
163
- �����Կ����֤�ޤ����֥��å��ˤϥե��å������ǡ���������Ǥ錄��
164
- �ޤ���NULL�ͤ� ruby ¦�Ǥ� nil �˥ޥåԥ󥰤��Ƥ���ޤ���</p>
165
- <p>��:</p>
166
- <pre>conn = OCI8.new('scott', 'tiger')
167
- num_rows = conn.exec('SELECT * FROM emp') do |r|
168
- puts r.join(',')
169
- end
170
- puts num_rows.to_s + ' rows were processed.'
171
- conn.logoff</pre>
172
- <p>INSERT/UPDATE/DELETEʸ�ξ�硢���줾����������Կ����֤�ޤ���</p>
173
- <p>��:</p>
174
- <pre>conn = OCI8.new('scott', 'tiger')
175
- num_rows = conn.exec('UPDATE emp SET sal = sal * 1.1')
176
- puts num_rows.to_s + ' rows were updated.'
177
- conn.logoff</pre>
178
- <p>CREATE/ALTER/DROPʸ�ξ�硢true ���֤�ޤ���</p>
179
- <p>��:</p>
180
- <pre>conn = OCI8.new('scott', 'tiger')
181
- conn.exec('CREATE TABLE test (col1 CHAR(6))')
182
- conn.logoff</pre>
183
- <p>PL/SQLʸ�ξ�硢�¹Ը�ΥХ�����ѿ����ͤ�����Ȥʤä��֤�ޤ���</p>
184
- <p>��:</p>
185
- <pre>conn = OCI8.new('scott', 'tiger')
186
- conn.exec("BEGIN :str := TO_CHAR(:num, 'FM0999'); END;", 'ABCD', 123)
187
- # =&gt; ["0123", 123]
188
- conn.logoff</pre>
189
- <p>�嵭����Ǥϡ�<var>:str</var> �� <var>:num</var> �Ȥ���2�ĤΥХ�����ѿ���
190
- ����ޤ�������ͤȤ��Ƥ��줾��"��4���ͤ� ABCD ��ʸ����"��"�� 123
191
- �ο���"�����ꤵ��Ƥ��顢PL/SQLʸ���¹Ԥ��졢�¹Ը�ΥХ�����ѿ�
192
- ���ͤ�����Ȥ����֤äƤ��ޤ�������ν��֤ϥХ�����ѿ��ν��֤�Ʊ
193
- ���Ǥ���</p></dd>
194
- <dt><a name="label-12" id="label-12"><code>OCI8#parse(<var>sql</var>)</code></a></dt><!-- RDLabel: "OCI8#parse" -->
195
- <dd>
196
- ����������������sql ʸ�¹Ԥν����򤷤ޤ���OCI8::Cursor �Υ���
197
- ���󥹤��֤�ޤ���</dd>
198
- <dt><a name="label-13" id="label-13"><code>OCI8#commit()</code></a></dt><!-- RDLabel: "OCI8#commit" -->
199
- <dd>
200
- <p>�ȥ�󥶥������򥳥ߥåȤ��ޤ���</p>
201
- <p>��:</p>
202
- <pre>conn = OCI8.new("scott", "tiger")
203
- conn.exec("UPDATE emp SET sal = sal * 1.1") # yahoo
204
- conn.commit
205
- conn.logoff</pre></dd>
206
- <dt><a name="label-14" id="label-14"><code>OCI8#rollback()</code></a></dt><!-- RDLabel: "OCI8#rollback" -->
207
- <dd>
208
- <p>�ȥ�󥶥������������Хå����ޤ���</p>
209
- <p>��:</p>
210
- <pre>conn = OCI8.new("scott", "tiger")
211
- conn.exec("UPDATE emp SET sal = sal * 0.9") # boos
212
- conn.rollback
213
- conn.logoff</pre></dd>
214
- <dt><a name="label-15" id="label-15"><code>OCI8#autocommit?</code></a></dt><!-- RDLabel: "OCI8#autocommit?" -->
215
- <dd>
216
- autocommit �⡼�ɤξ��֤��֤��ޤ����ǥե���Ȥ� false �Ǥ�������
217
- �ͤ� true �ΤȤ���INSERT/UPDATE/DELETEʸ���¹Ԥ������˼�ưŪ��
218
- ���ߥåȤ���ޤ���</dd>
219
- <dt><a name="label-16" id="label-16"><code>OCI8#autocommit</code></a></dt><!-- RDLabel: "OCI8#autocommit" -->
220
- <dd>
221
- <a href="#label-15">OCI8#autocommit?</a>����̾�Ǥ���</dd>
222
- <dt><a name="label-17" id="label-17"><code>OCI8#autocommit=</code></a></dt><!-- RDLabel: "OCI8#autocommit=" -->
223
- <dd>
224
- <p>autocommit �⡼�ɤξ��֤��ѹ����ޤ���true �� flase �����ꤷ�Ƥ���������</p>
225
- <p>��:</p>
226
- <pre>conn = OCI8.new("scott", "tiger")
227
- conn.autocommit = true
228
- ... do something ...
229
- conn.logoff</pre></dd>
230
- <dt><a name="label-18" id="label-18"><code>OCI8#non_blocking?</code></a></dt><!-- RDLabel: "OCI8#non_blocking?" -->
231
- <dd>
232
- �֥��å���/��֥��å��󥰥⡼�ɤξ��֤��֤��ޤ����ǥե���Ȥ�
233
- false���Ĥޤ�֥��å��󥰥⡼�ɤǤ���<a href="#label-50">�֥��å���/��֥��å��󥰥⡼��</a>
234
- �򻲾Ȥ��Ƥ���������</dd>
235
- <dt><a name="label-19" id="label-19"><code>OCI8#non_blocking=</code></a></dt><!-- RDLabel: "OCI8#non_blocking=" -->
236
- <dd>
237
- �֥��å���/��֥��å��󥰥⡼�ɤξ��֤��ѹ����ޤ���true ��
238
- flase �����ꤷ�Ƥ���������<a href="#label-50">�֥��å���/��֥��å��󥰥⡼��</a>
239
- �򻲾Ȥ��Ƥ���������</dd>
240
- <dt><a name="label-20" id="label-20"><code>OCI8#break()</code></a></dt><!-- RDLabel: "OCI8#break" -->
241
- <dd>
242
- �¹����¾����åɤ� OCI �ƽФ��򥭥�󥻥뤷�ޤ������Υ᥽�åɤ�
243
- �¹Ԥ���ˤ���֥��å��󥰥⡼�ɤǤ���ɬ�פ�����ޤ���
244
- <a href="#label-50">�֥��å���/��֥��å��󥰥⡼��</a>�򻲾Ȥ��Ƥ���������</dd>
245
- </dl>
246
- <h2><a name="label-21" id="label-21">OCI8::Cursor</a></h2><!-- RDLabel: "OCI8::Cursor" -->
247
- <dl>
248
- <dt><a name="label-22" id="label-22"><code>OCI8::Cursor#define(<var>pos</var>, <var>type</var>, <var>length</var> = <var>nil</var>)</code></a></dt><!-- RDLabel: "OCI8::Cursor#define" -->
249
- <dd>
250
- <p>fetch �Ǽ�������ǡ����η�������Ū�˻��ꤹ�롣parse �� exec �δ�
251
- �˼¹Ԥ��Ƥ���������pos �� 1 ��������ޤ���length �� type ��
252
- String ����ꤷ���Ȥ���ͭ���Ǥ���</p>
253
- <p>��:</p>
254
- <pre>cursor = conn.parse("SELECT ename, hiredate FROM emp")
255
- cursor.define(1, String, 20) # 1������ܤ� String �Ȥ��� fetch
256
- cursor.define(2, Time) # 2������ܤ� Time �Ȥ��� fetch
257
- cursor.exec()</pre></dd>
258
- <dt><a name="label-23" id="label-23"><code>OCI8::Cursor#bind_param(<var>key</var>, <var>val</var>, <var>type</var> = <var>nil</var>, <var>length</var> = <var>nil</var>)</code></a></dt><!-- RDLabel: "OCI8::Cursor#bind_param" -->
259
- <dd>
260
- <p>����Ū���ѿ���Х���ɤ��ޤ���</p>
261
- <p>key �����ͤξ��ϡ��Х�����ѿ��ΰ��֤ˤ�äƥХ���ɤ��ޤ�����
262
- �֤�1��������ޤ���key ��ʸ����ξ��ϡ��Х�����ѿ���̾���ˤ��
263
- �ƥХ���ɤ��ޤ���</p>
264
- <p>��:</p>
265
- <pre>cursor = conn.parse("SELECT * FROM emp WHERE ename = :ename")
266
- cursor.bind_param(1, 'SMITH') # bind by position
267
- ...or...
268
- cursor.bind_param(':ename', 'SMITH') # bind by name</pre>
269
- <p>���ͤ�Х���ɤ����硢Fixnum �� Float ���ȤäƤ���������Bignum
270
- �ϻ��ѤǤ��ޤ��󡣽���ͤ� NULL �ˤ�����ϡ�val �� nil �ˤ��ơ�
271
- type ��Fixnum �� Float �ˤ��Ƥ���������</p>
272
- <p>��:</p>
273
- <pre>cursor.bind_param(1, 1234) # bind as Fixnum, Initial value is 1234.
274
- cursor.bind_param(1, 1234.0) # bind as Float, Initial value is 1234.0.
275
- cursor.bind_param(1, nil, Fixnum) # bind as Fixnum, Initial value is NULL.
276
- cursor.bind_param(1, nil, Float) # bind as Float, Initial value is NULL.</pre>
277
- <p>ʸ�����Х���ɤ����硢val �ˤ��ΤޤޥХ���ɤ���ʸ������ꤷ
278
- �Ƥ����������Х���ɤ����ϤȤ��ƻȤ����硢���Ϥ���Τ�ɬ�פ�
279
- Ĺ����ʸ������ꤹ�뤫��type �� String ����ꤷ����� length ���
280
- �ꤷ�Ƥ���������</p>
281
- <p>��:</p>
282
- <pre>cursor = conn.parse("BEGIN :out := :in || '_OUT'; END;")
283
- cursor.bind_param(':in', 'DATA') # bind as String with width 4.
284
- cursor.bind_param(':out', nil, String, 7) # bind as String with width 7.
285
- cursor.exec()
286
- p cursor[':out'] # =&gt; 'DATA_OU'
287
- # PL/SQL�֥��å���Ǥ� :out �� 8�Х��Ȥ�������7��ʸ���Ȥ��ƥХ����
288
- # ���Ƥ���Τǡ�7�Х����ܤ��ڤ�Ƥ���</pre>
289
- <p>ʸ����� RAW ���Ȥ��ƥХ���ɤ������ɬ�� type �� OCI8::RAW ��
290
- ���ꤷ�Ƥ���������</p>
291
- <p>��:</p>
292
- <pre>cursor = conn.parse("INSERT INTO raw_table(raw_column) VALUE (:1)")
293
- cursor.bind_param(1, 'RAW_STRING', OCI8::RAW)
294
- cursor.exec()
295
- cursor.close()</pre></dd>
296
- <dt><a name="label-24" id="label-24"><code>OCI8::Cursor#[<var>key</var>]</code></a></dt><!-- RDLabel: "OCI8::Cursor#[]" -->
297
- <dd>
298
- <p>�Х�����ѿ����ͤ���Ф��ޤ���</p>
299
- <p>����Ū�˥Х���ɤ�����硢<a href="#label-23">OCI8::Cursor#bind_param</a>�ǻ��ꤷ��
300
- key �Ǥ�äƼ��Ф��ޤ������֤ˤ��Х���ɡ�̾���ˤ��Х����
301
- �����ߤ�����硢Ʊ�����Ǥ���ꤷ���Х������ˡ���б����� key ��
302
- �Ѥ��Ƥ���������</p>
303
- <p>��:</p>
304
- <pre>cursor = conn.parse("BEGIN :out := 'BAR'; END;")
305
- cursor.bind_param(':out', 'FOO') # bind by name
306
- p cursor[':out'] # =&gt; 'FOO'
307
- p cursor[1] # =&gt; nil
308
- cursor.exec()
309
- p cursor[':out'] # =&gt; 'BAR'
310
- p cursor[1] # =&gt; nil</pre>
311
- <p>��:</p>
312
- <pre>cursor = conn.parse("BEGIN :out := 'BAR'; END;")
313
- cursor.bind_param(1, 'FOO') # bind by position
314
- p cursor[':out'] # =&gt; nil
315
- p cursor[1] # =&gt; 'FOO'
316
- cursor.exec()
317
- p cursor[':out'] # =&gt; nil
318
- p cursor[1] # =&gt; 'BAR'</pre>
319
- <p><a href="#label-11">OCI8#exec</a>��<a href="#label-27">OCI8::Cursor#exec</a>����Ѥ��ƥХ���ɤ�����
320
- �硢�Х�����ѿ��ΰ��֤Ǥ�äƼ������ޤ���</p>
321
- <p>��:</p>
322
- <pre>cursor = conn.exec("BEGIN :out := 'BAR'; END;", 'FOO')
323
- # 1st bind variable is bound as String with width 3. Its initial value is 'FOO'
324
- # After execute, the value become 'BAR'.
325
- p cursor[1] # =&gt; 'BAR'</pre></dd>
326
- <dt><a name="label-25" id="label-25"><code>OCI8::Cursor#[<var>key</var>] = <var>val</var></code></a></dt><!-- RDLabel: "OCI8::Cursor#[]=" -->
327
- <dd>
328
- <p>�Х�����ѿ����ͤ����ꤷ�ޤ���key �λ�����ˡ��
329
- <a href="#label-24">OCI8::Cursor#[]</a>��Ʊ���Ǥ���<a href="#label-23">OCI8::Cursor#bind_param</a>�ǻ�
330
- �ꤷ�� val �����֤����������Ȥ����ޤ����̤��ͤ��֤������Ʋ��٤�
331
- <a href="#label-27">OCI8::Cursor#exec</a>��¹Ԥ������Ȥ��˻��Ѥ��Ƥ���������</p>
332
- <p>�㣱:</p>
333
- <pre>cursor = conn.parse("INSERT INTO test(col1) VALUES(:1)")
334
- cursor.bind_params(1, nil, String, 3)
335
- ['FOO', 'BAR', 'BAZ'].each do |key|
336
- cursor[1] = key
337
- cursor.exec
338
- end
339
- cursor.close()</pre>
340
- <p>�㣲:</p>
341
- <pre>['FOO', 'BAR', 'BAZ'].each do |key|
342
- conn.exec("INSERT INTO test(col1) VALUES(:1)", key)
343
- end</pre>
344
- <p>�㣱���㣲�Ϸ�̤�Ʊ���Ǥ������㣱�Τۤ�����٤����ʤ��ʤ�ޤ���</p></dd>
345
- <dt><a name="label-26" id="label-26"><code>OCI8::Cursor#keys()</code></a></dt><!-- RDLabel: "OCI8::Cursor#keys" -->
346
- <dd>
347
- �Х�����ѿ��� key ������ˤ����֤��ޤ���</dd>
348
- <dt><a name="label-27" id="label-27"><code>OCI8::Cursor#exec(*<var>bindvars</var>)</code></a></dt><!-- RDLabel: "OCI8::Cursor#exec" -->
349
- <dd>
350
- <p>��������˳����Ƥ�줿 SQL ��¹Ԥ��ޤ���SQL �� SELECTʸ��
351
- INSERT/UPDATE/DELETEʸ��CREATE/ALTER/DROPʸ��PL/SQLʸ�����줾���
352
- �������ͤμ��ब�ۤʤ�ޤ���</p>
353
- <p>SELECTʸ�ξ�硢select-list �ο����֤�ޤ���</p>
354
- <p>INSERT/UPDATE/DELETEʸ�ξ�硢���줾����������Կ����֤�ޤ���</p>
355
- <p>CREATE/ALTER/DROPʸ��PL/SQLʸ�ξ�硢true ���֤�ޤ���
356
- <a href="#label-11">OCI8#exec</a>�Ǥ� PL/SQLʸ�ξ�硢�Х�����ѿ����ͤ�����Ȥʤä�
357
- �֤�ޤ��������Υ᥽�åɤǤ�ñ�� true ���֤�ޤ����Х�����ѿ���
358
- �ͤ�<a href="#label-24">OCI8::Cursor#[]</a>�Ǥ�ä�����Ū�˼������Ƥ���������</p></dd>
359
- <dt><a name="label-28" id="label-28"><code>OCI8::Cursor#type</code></a></dt><!-- RDLabel: "OCI8::Cursor#type" -->
360
- <dd>
361
- <p>SQLʸ�μ����������ޤ�������ͤϡ�</p>
362
- <ul>
363
- <li>OCI8::STMT_SELECT</li>
364
- <li>OCI8::STMT_UPDATE</li>
365
- <li>OCI8::STMT_DELETE</li>
366
- <li>OCI8::STMT_INSERT</li>
367
- <li>OCI8::STMT_CREATE</li>
368
- <li>OCI8::STMT_DROP</li>
369
- <li>OCI8::STMT_ALTER</li>
370
- <li>OCI8::STMT_BEGIN</li>
371
- <li>OCI8::STMT_DECLARE</li>
372
- </ul>
373
- <p>�Τɤ줫�Ǥ���PL/SQLʸ�ξ��ϡ�OCI8::STMT_BEGIN ��
374
- OCI8::STMT_DECLARE �Ȥʤ�ޤ���</p></dd>
375
- <dt><a name="label-29" id="label-29"><code>OCI8::Cursor#row_count</code></a></dt><!-- RDLabel: "OCI8::Cursor#row_count" -->
376
- <dd>
377
- ���������Կ����֤��ޤ���</dd>
378
- <dt><a name="label-30" id="label-30"><code>OCI8::Cursor#get_col_names</code></a></dt><!-- RDLabel: "OCI8::Cursor#get_col_names" -->
379
- <dd>
380
- ����ꥹ�Ȥ�̾��������Ǽ������ޤ���SELECT ʸ�ˤΤ�ͭ���Ǥ���ɬ�� exec ������˻��Ѥ��Ƥ���������</dd>
381
- <dt><a name="label-31" id="label-31"><code>OCI8::Cursor#getColNames</code></a></dt><!-- RDLabel: "OCI8::Cursor#getColNames" -->
382
- <dd>
383
- <a href="#label-30">OCI8::Cursor#get_col_names</a> �ؤΥ����ꥢ���Ǥ���</dd>
384
- <dt><a name="label-32" id="label-32"><code>OCI8::Cursor#fetch()</code></a></dt><!-- RDLabel: "OCI8::Cursor#fetch" -->
385
- <dd>
386
- <p>SELECT ʸ�Τߤ�ͭ���Ǥ����ե��å������ǡ���������Ȥ����֤�ޤ���</p>
387
- <p>��:</p>
388
- <pre>conn = OCI8.new('scott', 'tiger')
389
- cursor = conn.exec('SELECT * FROM emp')
390
- while r = cursor.fetch()
391
- puts r.join(',')
392
- end
393
- cursor.close
394
- conn.logoff</pre></dd>
395
- <dt><a name="label-33" id="label-33"><code>OCI8::Cursor#close()</code></a></dt><!-- RDLabel: "OCI8::Cursor#close" -->
396
- <dd>
397
- ��������򥯥��������ޤ���</dd>
398
- <dt><a name="label-34" id="label-34"><code>OCI8::Cursor#rowid</code></a></dt><!-- RDLabel: "OCI8::Cursor#rowid" -->
399
- <dd>
400
- ���߼¹Ԥ��Ƥ���Ԥ� ROWID ��������ޤ���
401
- ����������줿�ͤϥХ�����ͤȤ��ƻ��ѤǤ��ޤ���
402
- �դ˸����ȡ��Х���ɤ�����Ū�ˤ������ѤǤ��ޤ���</dd>
403
- </dl>
404
- <h2><a name="label-35" id="label-35">OCI8::BLOB</a></h2><!-- RDLabel: "OCI8::BLOB" -->
405
- <dl>
406
- <dt><a name="label-36" id="label-36"><code>OCI8::BLOB#available?</code></a></dt><!-- RDLabel: "OCI8::BLOB#available?" -->
407
- <dd>
408
- <p>BLOB ��ͭ�����ɤ��������å����ޤ���
409
- BLOB ����Ѥ��뤿��ˤϺǽ�˶���BLOB����������ɬ�פ�����ޤ���</p>
410
- <p>��:</p>
411
- <pre>conn.exec("CREATE TABLE photo (name VARCHAR2(50), image BLOB)")
412
- conn.exec("INSERT INTO photo VALUES ('null-data', NULL)")
413
- conn.exec("INSERT INTO photo VALUES ('empty-data', EMPTY_BLOB())")
414
- conn.exec("SELECT name, image FROM photo") do |name, image|
415
- case name
416
- when 'null-data'
417
- puts "#{name} =&gt; #{image.available?.to_s}"
418
- # =&gt; false
419
- when 'empty-data'
420
- puts "#{name} =&gt; #{image.available?.to_s}"
421
- # =&gt; true
422
- end
423
- end</pre></dd>
424
- <dt><a name="label-37" id="label-37"><code>OCI8::BLOB#read(<var>size</var> = <var>nil</var>)</code></a></dt><!-- RDLabel: "OCI8::BLOB#read" -->
425
- <dd>
426
- <p>BLOB ���ǡ������ɤ߹��ߤޤ���size �λ��꤬�ʤ����ϥǡ����κ�
427
- ��ޤ��ɤ߹��ߤޤ���</p>
428
- <p>�㣱: BLOB �Υ���󥯥���������ɤ߹��ߡ�</p>
429
- <pre>conn.exec("SELECT name, image FROM photo") do |name, image|
430
- chunk_size = image.chunk_size
431
- File.open(name, 'w') do |f|
432
- until image.eof?
433
- f.write(image.read(chunk_size))
434
- end
435
- end
436
- end</pre>
437
- <p>�㣲: �����ɤ߹��ߡ�</p>
438
- <pre>conn.exec("SELECT name, image FROM photo") do |name, image|
439
- File.open(name, 'w') do |f|
440
- f.write(image.read)
441
- end
442
- end</pre></dd>
443
- <dt><a name="label-38" id="label-38"><code>OCI8::BLOB#write(<var>data</var>)</code></a></dt><!-- RDLabel: "OCI8::BLOB#write" -->
444
- <dd>
445
- <p>BLOB �إǡ�����񤭹��ߤޤ���
446
- BLOB �˸������äƤ����ǡ�����Ĺ�����񤭹�����ǡ������Ĺ������
447
- <a href="#label-40">OCI8::BLOB#size=</a> ��Ĺ���κ������ԤäƤ���������</p>
448
- <p>�㣱: BLOB �Υ���󥯥�������˽񤭹���</p>
449
- <pre>cursor = conn.parse("INSERT INTO photo VALUES(:name, EMPTY_BLOB())")
450
- Dir["*.png"].each do |fname|
451
- cursor.exec(fname)
452
- end
453
- conn.exec("SELECT name, image FROM photo") do |name, image|
454
- chunk_size = image.chunk_size
455
- File.open(name, 'r') do |f|
456
- until f.eof?
457
- image.write(f.read(chunk_size))
458
- end
459
- image.size = f.pos
460
- end
461
- end
462
- conn.commit</pre>
463
- <p>�㣲: ���˽񤭹���</p>
464
- <pre>conn.exec("SELECT name, image FROM photo") do |name, image|
465
- File.open(name, 'r') do |f|
466
- image.write(f.read)
467
- image.size = f.pos
468
- end
469
- end</pre></dd>
470
- <dt><a name="label-39" id="label-39"><code>OCI8::BLOB#size</code></a></dt><!-- RDLabel: "OCI8::BLOB#size" -->
471
- <dd>
472
- BLOB �Υǡ�����Ĺ�����֤��ޤ���</dd>
473
- <dt><a name="label-40" id="label-40"><code>OCI8::BLOB#size=(<var>len</var>)</code></a></dt><!-- RDLabel: "OCI8::BLOB#size=" -->
474
- <dd>
475
- BLOB �Υǡ�����Ĺ���� len �����ꤷ�ޤ���</dd>
476
- <dt><a name="label-41" id="label-41"><code>OCI8::BLOB#chunk_size</code></a></dt><!-- RDLabel: "OCI8::BLOB#chunk_size" -->
477
- <dd>
478
- BLOB �Υ���󥯥��������֤��ޤ���</dd>
479
- <dt><a name="label-42" id="label-42"><code>OCI8::BLOB#truncate(<var>len</var>)</code></a></dt><!-- RDLabel: "OCI8::BLOB#truncate" -->
480
- <dd>
481
- BLOB �Υǡ�����Ĺ���� len �����ꤷ�ޤ���</dd>
482
- <dt><a name="label-43" id="label-43"><code>OCI8::BLOB#pos</code></a></dt><!-- RDLabel: "OCI8::BLOB#pos" -->
483
- <dd>
484
- ����� read/write �γ��ϰ��֤��֤��ޤ���</dd>
485
- <dt><a name="label-44" id="label-44"><code>OCI8::BLOB#pos=(<var>pos</var>)</code></a></dt><!-- RDLabel: "OCI8::BLOB#pos=" -->
486
- <dd>
487
- ����� read/write �γ��ϰ��֤����ꤷ�ޤ���</dd>
488
- <dt><a name="label-45" id="label-45"><code>OCI8::BLOB#eof?</code></a></dt><!-- RDLabel: "OCI8::BLOB#eof?" -->
489
- <dd>
490
- BLOB �κǸ����ã�������ɤ������֤��ޤ���</dd>
491
- <dt><a name="label-46" id="label-46"><code>OCI8::BLOB#tell</code></a></dt><!-- RDLabel: "OCI8::BLOB#tell" -->
492
- <dd>
493
- <a href="#label-43">OCI8::BLOB#pos</a> ��Ʊ���Ǥ���</dd>
494
- <dt><a name="label-47" id="label-47"><code>OCI8::BLOB#seek(<var>pos</var>)</code></a></dt><!-- RDLabel: "OCI8::BLOB#seek" -->
495
- <dd>
496
- <a href="#label-44">OCI8::BLOB#pos=</a> ��Ʊ���Ǥ���</dd>
497
- <dt><a name="label-48" id="label-48"><code>OCI8::BLOB#rewind</code></a></dt><!-- RDLabel: "OCI8::BLOB#rewind" -->
498
- <dd>
499
- ����� read/write �γ��ϰ��֤� 0 �����ꤷ�ޤ���</dd>
500
- </dl>
501
- <h2><a name="label-49" id="label-49">���</a></h2><!-- RDLabel: "���" -->
502
- <h3><a name="label-50" id="label-50">�֥��å���/��֥��å��󥰥⡼��</a></h3><!-- RDLabel: "�֥��å���/��֥��å��󥰥⡼��" -->
503
- <p>�ǥե���Ȥϥ֥��å��󥰥⡼�ɤˤʤäƤ��ޤ���<a href="#label-19">OCI8#non_blocking=</a>
504
- �ǥ⡼�ɤ��ѹ��Ǥ��ޤ���</p>
505
- <p>�֥��å��󥰥⡼�ɤξ�硢�Ť� OCI �θƽФ��򤷤Ƥ���ȡ�����åɤ�Ȥ�
506
- �Ƥ��Ƥ� ruby ���Τ��֥��å�����ޤ�������ϡ�ruby �Υ���åɤϥͥ��ƥ�
507
- �֥���åɤǤϤʤ�����Ǥ���</p>
508
- <p>��֥��å��󥰥⡼�ɤξ�硢�Ť� OCI �θƽФ��Ǥ� ruby ���Τϥ֥��å�
509
- ����ޤ���OCI ��ƽФ��Ƥ��륹��åɤΤߤ��֥��å����ޤ������Τ���ꡢ
510
- OCI �ƽФ�����λ���Ƥ��뤫�ɤ����ݡ���󥰤ˤ�äƥ����å����Ƥ���Τǡ�
511
- �ġ��� OCI �ƽФ��������٤��ʤ�ޤ���</p>
512
- <p><a href="#label-20">OCI8#break</a> ���Ѥ���ȡ��̤Υ���åɤ���Ť� OCI �ƽФ��򥭥�󥻥�Ǥ�
513
- �ޤ�������󥻥뤵�줿����åɤǤ� <var>OCIBreak</var> �Ȥ����㳰��󤲤ޤ���</p>
514
- <p>��֥��å��󥰥⡼�ɤ����»���: �̡��Υ���åɤ�Ʊ����³���Ф���Ʊ����
515
- OCI �ƽФ���Ԥ�ʤ��Ǥ���������OCI �饤�֥��¦����֥��å��󥰥⡼��
516
- �Ǥθ�ߤθƽФ����б����Ƥ��뤫�ɤ��������Ǥ������ޤ���ruby �Υ⥸�塼
517
- ��¦�Ǥ⡢<a href="#label-20">OCI8#break</a> ��¹Ԥ����Ȥ��˥���󥻥뤹��OCI �ƽФ���
518
- ʣ�������硢���ߤμ����Ǥ��б��Ǥ��ޤ���</p>
519
- <hr />
520
- <p class="foottext">
521
- <a name="foottext-1" id="foottext-1" href="#footmark-1"><sup><small>*1</small></sup></a><small>Oracle Call
522
- Interface: ���饯��� C���쥤�󥿡��ե�����</small><br />
523
- </p>
524
- </body>
525
- </html>