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