xref: /PHP-5.4/ext/oci8/tests/bind_sqltchr_1.phpt (revision c7a8bd6a)
1--TEST--
2Bind with SQLT_CHR
3--SKIPIF--
4<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
5--FILE--
6<?php
7
8require(dirname(__FILE__).'/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===DONE===
137<?php exit(0); ?>
138--EXPECTF--
139TEST241 bind SQLT_CHR
140array(1) {
141  ["VARCHAR2_T10"]=>
142  array(1) {
143    [0]=>
144    string(7) "Hood241"
145  }
146}
147
148TEST242 insert numbers SQLT_CHR
149array(1) {
150  ["NUMBER_T"]=>
151  array(1) {
152    [0]=>
153    string(2) "42"
154  }
155}
156
157TEST243 insert numbers, SQLT_CHR
158array(1) {
159  ["NUMBER_T"]=>
160  array(1) {
161    [0]=>
162    string(5) "42.69"
163  }
164}
165
166TEST244 insert numbers with SQLT_CHR
167array(1) {
168  ["NUMBER_T"]=>
169  array(1) {
170    [0]=>
171    string(1) "0"
172  }
173}
174
175TEST245 insert numbers with SQLT_CHR
176array(1) {
177  ["NUMBER_T"]=>
178  array(1) {
179    [0]=>
180    string(3) "-23"
181  }
182}
183
184TEST246 insert numbers
185array(1) {
186  ["NUMBER_T"]=>
187  array(1) {
188    [0]=>
189    string(3) "-23"
190  }
191}
192
193TEST247 insert numbers with SQLT_CHR
194array(1) {
195  ["NUMBER_T"]=>
196  array(1) {
197    [0]=>
198    string(2) "23"
199  }
200}
201
202TEST248 insert numbers with SQLT_CHR
203array(1) {
204  ["NUMBER_T92"]=>
205  array(1) {
206    [0]=>
207    string(6) "123.56"
208  }
209}
210
211TEST249 insert numbers with SQLT_CHR
212array(1) {
213  ["NUMBER_T92"]=>
214  array(1) {
215    [0]=>
216    string(6) "123.56"
217  }
218}
219
220TEST250 insert numbers with SQLT_CHR
221array(1) {
222  ["NUMBER_T92"]=>
223  array(1) {
224    [0]=>
225    NULL
226  }
227}
228===DONE===
229