Annotation of embedaddon/php/ext/oci8/tests/bind_char_3_11gR1.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to CHAR parameter
3: --SKIPIF--
4: <?php
5: if (!extension_loaded('oci8')) die ("skip no oci8 extension");
6: require(dirname(__FILE__)."/connect.inc");
7: // The bind buffer size edge cases seem to change each DB version.
1.1.1.2 ! misho 8: if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) {
1.1 misho 9: if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) {
10: die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases");
11: }
12: }
13: ?>
14: --ENV--
15: NLS_LANG=
16: --FILE--
17: <?php
18:
19: require(dirname(__FILE__).'/connect.inc');
20:
21: // Initialization
22:
23: $stmtarray = array(
24: "create or replace function bind_char_3_fn(p1 char) return char as begin return p1; end;",
25: );
26:
27: oci8_test_sql_execute($c, $stmtarray);
28:
29: // Run Test
30:
31: echo "Test 1.1 In Length: default. In Type: default. Out Length: default. Out Type: default\n";
32:
33: $s = oci_parse($c, "begin :bv2 := bind_char_3_fn(:bv1); end;");
34: $bv1 = 'abc';
35: $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2);
36: if ($r)
37: do_e($s);
38: var_dump($bv1, $bv2);
39:
40: echo "Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n";
41:
42: $bv1 = 'abc';
43: $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10);
44: if ($r)
45: do_e($s);
46: var_dump($bv1, $bv2);
47:
48:
49: echo "Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n";
50:
51: $bv1 = 'abc';
52: $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10);
53: if ($r)
54: do_e($s);
55: var_dump($bv1, $bv2);
56:
57:
58:
59: echo "Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n";
60:
61: $bv1 = 'abc';
62: $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC);
63: if ($r)
64: do_e($s);
65: var_dump($bv1, $bv2);
66:
67:
68: echo "Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input). Out Type: AFC\n";
69:
70: $bv1 = 'abc';
71: $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1), SQLT_AFC);
72: if ($r)
73: do_e($s);
74: var_dump($bv1, $bv2);
75:
76:
77: echo "Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input)-1. Out Type: AFC\n";
78:
79: $bv1 = 'abc';
80: $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)-1, SQLT_AFC);
81: if ($r)
82: do_e($s);
83: var_dump($bv1, $bv2);
84:
85:
86: echo "Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input)+1. Out Type: AFC\n";
87:
88: $bv1 = 'abc';
89: $r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)+1, SQLT_AFC);
90: if ($r)
91: do_e($s);
92: var_dump($bv1, $bv2);
93:
94:
95: echo "\n\nTests with ''\n\n";
96:
97: echo "Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n";
98:
99: $bv1 = '';
100: $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC);
101: if ($r)
102: do_e($s);
103: var_dump($bv1, $bv2);
104:
105:
106: echo "Test 2.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n";
107:
108: $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10);
109: if ($r)
110: do_e($s);
111: var_dump($bv1, $bv2);
112:
113:
114:
115: echo "Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n";
116:
117: $bv1 = '';
118: $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10);
119: if ($r)
120: do_e($s);
121: var_dump($bv1, $bv2);
122:
123:
124:
125: echo "Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n";
126:
127: $bv1 = '';
128: $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC);
129: if ($r)
130: do_e($s);
131: var_dump($bv1, $bv2);
132:
133:
134:
135: echo "Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC\n";
136:
137: $bv1 = '';
138: $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC);
139: if ($r)
140: do_e($s);
141: var_dump($bv1, $bv2);
142:
143:
144:
145: echo "Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. Out Type: AFC\n";
146:
147: $bv1 = '';
148: $r = oci_bind_by_name($s, ':bv1', $bv1, 0, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC);
149: if ($r)
150: do_e($s);
151: var_dump($bv1, $bv2);
152:
153:
154:
155: echo "Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. Out Type: AFC\n";
156:
157: $bv1 = '';
158: $r = oci_bind_by_name($s, ':bv1', $bv1, 1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC);
159: if ($r)
160: do_e($s);
161: var_dump($bv1, $bv2);
162:
163:
164:
165: echo "\n\nTests with NULL\n";
166:
167: echo "Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n";
168:
169: $bv1 = null;
170: $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC);
171: if ($r)
172: do_e($s);
173: var_dump($bv1, $bv2);
174:
175:
176: echo "Test 3.2 In Length: default. In Type: default. Out Length: 10. Out Type: default\n";
177:
178: $bv1 = null;
179: $r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 10);
180: if ($r)
181: do_e($s);
182: var_dump($bv1, $bv2);
183:
184:
185:
186: echo "Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default\n";
187:
188: $bv1 = null;
189: $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10);
190: if ($r)
191: do_e($s);
192: var_dump($bv1, $bv2);
193:
194:
195:
196: echo "Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC\n";
197:
198: $bv1 = null;
199: $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 10, SQLT_AFC);
200: if ($r)
201: do_e($s);
202: var_dump($bv1, $bv2);
203:
204:
205: echo "Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC\n";
206:
207: $bv1 = null;
208: $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 0, SQLT_AFC);
209: if ($r)
210: do_e($s);
211: var_dump($bv1, $bv2);
212:
213:
214:
215: echo "Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. Out Type: AFC\n";
216:
217: $bv1 = null;
218: $r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, ':bv2', $bv2, 1, SQLT_AFC);
219: if ($r)
220: do_e($s);
221: var_dump($bv1, $bv2);
222:
223:
224: function do_e($s)
225: {
226: echo " Executing:\n";
227:
228: $r = @oci_execute($s);
229: if (!$r) {
230: $m = oci_error($s);
231: echo " Oci_execute error ORA-".$m['code']."\n";
232: return;
233: }
234: }
235:
236: // Cleanup
237:
238: $stmtarray = array(
239: "drop function bind_char_3_fn"
240: );
241:
242: oci8_test_sql_execute($c, $stmtarray);
243:
244: echo "Done\n";
245:
246: ?>
247: --EXPECTF--
248: Test 1.1 In Length: default. In Type: default. Out Length: default. Out Type: default
249: Executing:
250: Oci_execute error ORA-6502
251: string(3) "abc"
252: NULL
253: Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default
254: Executing:
255: string(3) "abc"
256: string(3) "abc"
257: Test 1.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default
258: Executing:
259: string(3) "abc"
260: string(3) "abc"
261: Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC
262: Executing:
263: string(3) "abc"
264: string(10) "abc "
265: Test 1.5 In Length: strlen. In Type: AFC. Out Length: strlen(input). Out Type: AFC
266: Executing:
267: string(3) "abc"
268: string(3) "abc"
269: Test 1.6 In Length: strlen. In Type: AFC. Out Length: strlen(input)-1. Out Type: AFC
270: Executing:
271: Oci_execute error ORA-6502
272: string(3) "abc"
273: string(3) "abc"
274: Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input)+1. Out Type: AFC
275: Executing:
276: string(3) "abc"
277: string(4) "abc "
278:
279:
280: Tests with ''
281:
282: Test 2.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC
283: Executing:
284: string(0) ""
285: NULL
286: Test 2.2 In Length: default. In Type: default. Out Length: 10. Out Type: default
287: Executing:
288: string(0) ""
289: NULL
290: Test 2.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default
291: Executing:
292: string(0) ""
293: NULL
294: Test 2.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC
295: Executing:
296: string(0) ""
297: NULL
298: Test 2.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC
299: Executing:
300: string(0) ""
301: NULL
302: Test 2.6 In Length: 0. In Type: AFC. Out Length: 0. Out Type: AFC
303: Executing:
304: string(0) ""
305: NULL
306: Test 2.7 In Length: 1. In Type: AFC. Out Length: 1. Out Type: AFC
307: Executing:
308: string(0) ""
309: NULL
310:
311:
312: Tests with NULL
313: Test 3.1 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC
314: Executing:
315: NULL
316: NULL
317: Test 3.2 In Length: default. In Type: default. Out Length: 10. Out Type: default
318: Executing:
319: NULL
320: NULL
321: Test 3.3 In Length: -1. In Type: AFC. Out Length: 10. Out Type: default
322: Executing:
323: NULL
324: NULL
325: Test 3.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC
326: Executing:
327: NULL
328: NULL
329: Test 3.5 In Length: -1. In Type: AFC. Out Length: 0. Out Type: AFC
330: Executing:
331: NULL
332: NULL
333: Test 3.6 In Length: -1. In Type: AFC. Out Length: 1. Out Type: AFC
334: Executing:
335: NULL
336: NULL
337: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>