summaryrefslogtreecommitdiff
path: root/ext/oci8/tests/bind_sqltchr_1.phpt
blob: aabf9bda5c587ff4f1b0ea4cb99fb718bcbe8b40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
--TEST--
Bind with SQLT_CHR
--SKIPIF--
<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
--FILE--
<?php

require(dirname(__FILE__).'/connect.inc');

// Initialization

$stmtarray = array(
    "drop table bind_sqltchr_tab",

    "create table bind_sqltchr_tab (
        id                number,
        varchar2_t10      varchar2(10),
        number_t          number,
        number_t92        number(9,2))"

);

oci8_test_sql_execute($c, $stmtarray);

function check_col($c, $colname, $id)
{
    $s = oci_parse($c, "select $colname from bind_sqltchr_tab where id = :id");
    oci_bind_by_name($s, ":id", $id);
    oci_execute($s);
    oci_fetch_all($s, $r);
    var_dump($r);
}

// Run Test

echo "\nTEST241 bind SQLT_CHR\n";

$c2 = "Hood241";
$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, varchar2_t10) VALUES (241, :c2)");
oci_bind_by_name($s, ":c2", $c2, -1, SQLT_CHR);
oci_execute($s);

check_col($c, 'varchar2_t10', 241);


echo "\nTEST242 insert numbers SQLT_CHR\n";

$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (242, :n1)");
$n1 = 42;
oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
oci_execute($s);

check_col($c, 'number_t', 242);

echo "\nTEST243 insert numbers, SQLT_CHR\n";

$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (243, :n1)");
$n1 = 42.69;
oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
oci_execute($s);

check_col($c, 'number_t', 243);

echo "\nTEST244 insert numbers with SQLT_CHR\n";

$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (244, :n1)");
$n1 = 0;
oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
oci_execute($s);

check_col($c, 'number_t', 244);

echo "\nTEST245 insert numbers with SQLT_CHR\n";

$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (245, :n1)");
$n1 = -23;
oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
oci_execute($s);

check_col($c, 'number_t', 245);

echo "\nTEST246 insert numbers\n";

$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (246, :n1)");
$n1 = "-23";
oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
oci_execute($s);

check_col($c, 'number_t', 246);

echo "\nTEST247 insert numbers with SQLT_CHR\n";

$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (247, :n1)");
$n1 = "23";
oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
oci_execute($s);

check_col($c, 'number_t', 247);

echo "\nTEST248 insert numbers with SQLT_CHR\n";

$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t92) VALUES (248, :n1)");
$n1 = 123.56;
oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
oci_execute($s);

check_col($c, 'number_t92', 248);

echo "\nTEST249 insert numbers with SQLT_CHR\n";

$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t92) VALUES (249, :n1)");
$n1 = "123.56";
oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
oci_execute($s);

check_col($c, 'number_t92', 249);

echo "\nTEST250 insert numbers with SQLT_CHR\n";

$s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t92) VALUES (250, :n1)");
$n1 = "";
oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
oci_execute($s);

check_col($c, 'number_t92', 250);

// Clean up

$stmtarray = array(
    "drop table bind_sqltchr_tab"
);

oci8_test_sql_execute($c, $stmtarray);

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
TEST241 bind SQLT_CHR
array(1) {
  ["VARCHAR2_T10"]=>
  array(1) {
    [0]=>
    string(7) "Hood241"
  }
}

TEST242 insert numbers SQLT_CHR
array(1) {
  ["NUMBER_T"]=>
  array(1) {
    [0]=>
    string(2) "42"
  }
}

TEST243 insert numbers, SQLT_CHR
array(1) {
  ["NUMBER_T"]=>
  array(1) {
    [0]=>
    string(5) "42.69"
  }
}

TEST244 insert numbers with SQLT_CHR
array(1) {
  ["NUMBER_T"]=>
  array(1) {
    [0]=>
    string(1) "0"
  }
}

TEST245 insert numbers with SQLT_CHR
array(1) {
  ["NUMBER_T"]=>
  array(1) {
    [0]=>
    string(3) "-23"
  }
}

TEST246 insert numbers
array(1) {
  ["NUMBER_T"]=>
  array(1) {
    [0]=>
    string(3) "-23"
  }
}

TEST247 insert numbers with SQLT_CHR
array(1) {
  ["NUMBER_T"]=>
  array(1) {
    [0]=>
    string(2) "23"
  }
}

TEST248 insert numbers with SQLT_CHR
array(1) {
  ["NUMBER_T92"]=>
  array(1) {
    [0]=>
    string(6) "123.56"
  }
}

TEST249 insert numbers with SQLT_CHR
array(1) {
  ["NUMBER_T92"]=>
  array(1) {
    [0]=>
    string(6) "123.56"
  }
}

TEST250 insert numbers with SQLT_CHR
array(1) {
  ["NUMBER_T92"]=>
  array(1) {
    [0]=>
    NULL
  }
}
===DONE===