-
Notifications
You must be signed in to change notification settings - Fork 58
/
oci-error.xml
200 lines (194 loc) · 5.67 KB
/
oci-error.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?xml version="1.0" encoding="utf-8" ?>
<!-- $Revision$ -->
<!-- EN-Revision: ed6de1ae20ce16c0c7be0b3fef282b6065bebfac Maintainer: satoruyoshida Status: ready -->
<!-- CREDITS: shimooka -->
<refentry xml:id="function.oci-error" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>oci_error</refname>
<refpurpose>最後に見つかったエラーを返す</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>array</type><type>false</type></type><methodname>oci_error</methodname>
<methodparam choice="opt"><type class="union"><type>resource</type><type>null</type></type><parameter>connection_or_statement</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
最後に見つかったエラーを返します。
</para>
<para>
この関数は、エラーが発生した直後にコールしなければなりません。
文の実行が成功すると、エラーはクリアされてしまいます。
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>connection_or_statement</parameter></term>
<listitem>
<para>
大半のエラーでは、<parameter>connection_or_statement</parameter>
は関数コール時に渡されたリソースハンドルとなります。
<function>oci_connect</function> や
<function>oci_new_connect</function>、
<function>oci_pconnect</function> の接続エラーの場合は &null; を渡します。
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
もしエラーが見つからない場合、<function>oci_error</function> は
&false; を返します。それ以外の場合は、
<function>oci_error</function> はエラーの情報を連想配列で返します。
</para>
<para>
<table>
<title><function>oci_error</function> の配列の形式</title>
<tgroup cols="3">
<thead>
<row>
<entry>配列のキー</entry>
<entry>型</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>code</literal></entry>
<entry><type>int</type></entry>
<entry>
Oracle のエラーコード。
</entry>
</row>
<row>
<entry><literal>message</literal></entry>
<entry><type>string</type></entry>
<entry>
Oracle のエラーメッセージ。
</entry>
</row>
<row>
<entry><literal>offset</literal></entry>
<entry><type>int</type></entry>
<entry>
SQL 文の中でのエラーが発生した場所のバイト位置。SQL 文がない場合は
<literal>0</literal> となります。
</entry>
</row>
<row>
<entry><literal>sqltext</literal></entry>
<entry><type>string</type></entry>
<entry>
SQL 文のテキスト。SQL 文がない場合は空文字列となります。
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.0.0, PECL OCI8 3.0.0</entry>
<entry>
<parameter>connection_or_statement</parameter> は、nullable になりました。
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>接続エラー後の Oracle エラーメッセージの表示</title>
<programlisting role="php">
<![CDATA[
<?php
$conn = oci_connect("hr", "welcome", "localhost/XE");
if (!$conn) {
$e = oci_error(); // oci_connect のエラーの場合、ハンドルを渡しません
trigger_error(htmlentities($e['message']), E_USER_ERROR);
}
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>パースエラー時の Oracle エラーメッセージの表示</title>
<programlisting role="php">
<![CDATA[
<?php
$stid = oci_parse($conn, "select ' from dual"); // クォートが間違っていることに注意
if (!$stid) {
$e = oci_error($conn); // oci_parse エラーの場合は接続ハンドルを渡します
trigger_error(htmlentities($e['message']), E_USER_ERROR);
}
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>実行エラー時の、
Oracle エラーメッセージと問題となった文の表示</title>
<programlisting role="php">
<![CDATA[
<?php
$stid = oci_parse($conn, "select does_not_exist from dual");
$r = oci_execute($stid);
if (!$r) {
$e = oci_error($stid); // oci_execute のエラーの場合、ステートメントハンドルを渡します
print htmlentities($e['message']);
print "\n<pre>\n";
print htmlentities($e['sqltext']);
printf("\n%".($e['offset']+1)."s", "^");
print "\n</pre>\n";
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->