xref: /PHP-8.2/ext/oci8/tests/bind_sqltchr_1.phpt (revision 74859783)
1--TEST--
2Bind with SQLT_CHR
3--EXTENSIONS--
4oci8
5--FILE--
6<?php
7
8require(__DIR__.'/connect.inc');
9
10// Initialization
11
12$stmtarray = array(
13    "drop table bind_sqltchr_tab",
14
15    "create table bind_sqltchr_tab (
16        id                number,
17        varchar2_t10      varchar2(10),
18        number_t          number,
19        number_t92        number(9,2))"
20
21);
22
23oci8_test_sql_execute($c, $stmtarray);
24
25function check_col($c, $colname, $id)
26{
27    $s = oci_parse($c, "select $colname from bind_sqltchr_tab where id = :id");
28    oci_bind_by_name($s, ":id", $id);
29    oci_execute($s);
30    oci_fetch_all($s, $r);
31    var_dump($r);
32}
33
34// Run Test
35
36echo "\nTEST241 bind SQLT_CHR\n";
37
38$c2 = "Hood241";
39$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, varchar2_t10) VALUES (241, :c2)");
40oci_bind_by_name($s, ":c2", $c2, -1, SQLT_CHR);
41oci_execute($s);
42
43check_col($c, 'varchar2_t10', 241);
44
45
46echo "\nTEST242 insert numbers SQLT_CHR\n";
47
48$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (242, :n1)");
49$n1 = 42;
50oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
51oci_execute($s);
52
53check_col($c, 'number_t', 242);
54
55echo "\nTEST243 insert numbers, SQLT_CHR\n";
56
57$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (243, :n1)");
58$n1 = 42.69;
59oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
60oci_execute($s);
61
62check_col($c, 'number_t', 243);
63
64echo "\nTEST244 insert numbers with SQLT_CHR\n";
65
66$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (244, :n1)");
67$n1 = 0;
68oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
69oci_execute($s);
70
71check_col($c, 'number_t', 244);
72
73echo "\nTEST245 insert numbers with SQLT_CHR\n";
74
75$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (245, :n1)");
76$n1 = -23;
77oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
78oci_execute($s);
79
80check_col($c, 'number_t', 245);
81
82echo "\nTEST246 insert numbers\n";
83
84$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (246, :n1)");
85$n1 = "-23";
86oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
87oci_execute($s);
88
89check_col($c, 'number_t', 246);
90
91echo "\nTEST247 insert numbers with SQLT_CHR\n";
92
93$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (247, :n1)");
94$n1 = "23";
95oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
96oci_execute($s);
97
98check_col($c, 'number_t', 247);
99
100echo "\nTEST248 insert numbers with SQLT_CHR\n";
101
102$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t92) VALUES (248, :n1)");
103$n1 = 123.56;
104oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
105oci_execute($s);
106
107check_col($c, 'number_t92', 248);
108
109echo "\nTEST249 insert numbers with SQLT_CHR\n";
110
111$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t92) VALUES (249, :n1)");
112$n1 = "123.56";
113oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
114oci_execute($s);
115
116check_col($c, 'number_t92', 249);
117
118echo "\nTEST250 insert numbers with SQLT_CHR\n";
119
120$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t92) VALUES (250, :n1)");
121$n1 = "";
122oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
123oci_execute($s);
124
125check_col($c, 'number_t92', 250);
126
127// Clean up
128
129$stmtarray = array(
130    "drop table bind_sqltchr_tab"
131);
132
133oci8_test_sql_execute($c, $stmtarray);
134
135?>
136--EXPECT--
137TEST241 bind SQLT_CHR
138array(1) {
139  ["VARCHAR2_T10"]=>
140  array(1) {
141    [0]=>
142    string(7) "Hood241"
143  }
144}
145
146TEST242 insert numbers SQLT_CHR
147array(1) {
148  ["NUMBER_T"]=>
149  array(1) {
150    [0]=>
151    string(2) "42"
152  }
153}
154
155TEST243 insert numbers, SQLT_CHR
156array(1) {
157  ["NUMBER_T"]=>
158  array(1) {
159    [0]=>
160    string(5) "42.69"
161  }
162}
163
164TEST244 insert numbers with SQLT_CHR
165array(1) {
166  ["NUMBER_T"]=>
167  array(1) {
168    [0]=>
169    string(1) "0"
170  }
171}
172
173TEST245 insert numbers with SQLT_CHR
174array(1) {
175  ["NUMBER_T"]=>
176  array(1) {
177    [0]=>
178    string(3) "-23"
179  }
180}
181
182TEST246 insert numbers
183array(1) {
184  ["NUMBER_T"]=>
185  array(1) {
186    [0]=>
187    string(3) "-23"
188  }
189}
190
191TEST247 insert numbers with SQLT_CHR
192array(1) {
193  ["NUMBER_T"]=>
194  array(1) {
195    [0]=>
196    string(2) "23"
197  }
198}
199
200TEST248 insert numbers with SQLT_CHR
201array(1) {
202  ["NUMBER_T92"]=>
203  array(1) {
204    [0]=>
205    string(6) "123.56"
206  }
207}
208
209TEST249 insert numbers with SQLT_CHR
210array(1) {
211  ["NUMBER_T92"]=>
212  array(1) {
213    [0]=>
214    string(6) "123.56"
215  }
216}
217
218TEST250 insert numbers with SQLT_CHR
219array(1) {
220  ["NUMBER_T92"]=>
221  array(1) {
222    [0]=>
223    NULL
224  }
225}
226