Annotation of embedaddon/php/ext/oci8/tests/define6.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: oci_define_by_name tests with REF CURSORs
3: --SKIPIF--
4: <?php
5: $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
6: require(dirname(__FILE__).'/skipif.inc');
7: ?>
8: --FILE--
9: <?php
10:
11: require(dirname(__FILE__).'/connect.inc');
12:
13: // Initialization
14:
15: $stmtarray = array(
16: "drop table define6_tab",
17: "create table define6_tab (id number)",
18: "insert into define6_tab values (1)"
19: );
20:
21: oci8_test_sql_execute($c, $stmtarray);
22:
23: // Run Test
24:
25: $sql =
26: "DECLARE
27: TYPE curtype IS REF CURSOR;
28: cursor_var curtype;
29: BEGIN
30: OPEN cursor_var FOR SELECT id FROM define6_tab;
31: :curs := cursor_var;
32: END;";
33:
34: echo "Test 1 - define last\n";
35:
36: $s1 = oci_parse($c, $sql);
37: $cursor1 = oci_new_cursor($c);
38: oci_bind_by_name($s1, ":curs", $cursor1, -1, OCI_B_CURSOR);
39: oci_execute($s1);
40: oci_execute($cursor1);
41: oci_define_by_name($cursor1, 'ID', $id1);
42: while (oci_fetch_row($cursor1)) {
43: var_dump($id1);
44: }
45:
46:
47: echo "Test 2 - define last with preset var\n";
48:
49: $s2 = oci_parse($c, $sql);
50: $cursor2 = oci_new_cursor($c);
51: oci_bind_by_name($s2, ":curs", $cursor2, -1, OCI_B_CURSOR);
52: oci_execute($s2);
53: oci_execute($cursor2);
54: $id2 = '';
55: oci_define_by_name($cursor2, 'ID', $id2);
56: while (oci_fetch_row($cursor2)) {
57: var_dump($id2);
58: }
59:
60:
61: echo "Test 3 - define before cursor execute\n";
62:
63: $s3 = oci_parse($c, $sql);
64: $cursor3 = oci_new_cursor($c);
65: oci_bind_by_name($s3, ":curs", $cursor3, -1, OCI_B_CURSOR);
66: oci_execute($s3);
67: oci_define_by_name($cursor3, 'ID', $id3);
68: oci_execute($cursor3);
69: while (oci_fetch_row($cursor3)) {
70: var_dump($id3);
71: }
72:
73:
74: echo "Test 4 - define before top level execute\n";
75:
76: $s4 = oci_parse($c, $sql);
77: $cursor4 = oci_new_cursor($c);
78: oci_bind_by_name($s4, ":curs", $cursor4, -1, OCI_B_CURSOR);
79: oci_define_by_name($cursor4, 'ID', $id4);
80: oci_execute($s4);
81: oci_execute($cursor4);
82: while (oci_fetch_row($cursor4)) {
83: var_dump($id4);
84: }
85:
86:
87: echo "Test 5 - define before bind\n";
88:
89: $s5 = oci_parse($c, $sql);
90: $cursor5 = oci_new_cursor($c);
91: oci_define_by_name($cursor5, 'ID', $id5);
92: oci_bind_by_name($s5, ":curs", $cursor5, -1, OCI_B_CURSOR);
93: oci_execute($s5);
94: oci_execute($cursor5);
95: while (oci_fetch_row($cursor5)) {
96: var_dump($id5);
97: }
98:
99:
100: echo "Test 6 - fetch on wrong handle\n";
101:
102: $s6 = oci_parse($c, $sql);
103: $cursor6 = oci_new_cursor($c);
104: oci_define_by_name($cursor6, 'ID', $id6);
105: oci_bind_by_name($s6, ":curs", $cursor6, -1, OCI_B_CURSOR);
106: oci_execute($s6);
107: oci_execute($cursor6);
108: while (oci_fetch_row($s6)) {
109: var_dump($id6);
110: }
111:
112:
113: // Clean up
114:
115: $stmtarray = array(
116: "drop table define6_tab"
117: );
118:
119: oci8_test_sql_execute($c, $stmtarray);
120:
121: ?>
122: ===DONE===
123: <?php exit(0); ?>
124: --EXPECTF--
125: Test 1 - define last
126: NULL
127: Test 2 - define last with preset var
128: string(0) ""
129: Test 3 - define before cursor execute
130: string(1) "1"
131: Test 4 - define before top level execute
132: string(1) "1"
133: Test 5 - define before bind
134: string(1) "1"
135: Test 6 - fetch on wrong handle
136:
137: Warning: oci_fetch_row(): ORA-24374: %s in %sdefine6.php on line %d
138: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>