Skip to content

Commit 7e2b80c

Browse files
author
Rahul Priyadarshi
committed
To test BigInt datype
1 parent 5e96a54 commit 7e2b80c

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

tests/test_bigint.phpt

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
--TEST--
2+
IBM-DB2: bigint datatype
3+
--SKIPIF--
4+
<?php require_once('skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
8+
require_once('connection.inc');
9+
$conn = db2_connect($database, $user, $password);
10+
11+
if ($conn) {
12+
$drop_table_sql = 'drop table table0';
13+
$stmt = @db2_exec($conn, $drop_table_sql);
14+
15+
//Create table table0 with 2 columns of type bigint
16+
$create_table_sql = 'create table table0( id1 bigint , id2 bigint)';
17+
$stmt = @db2_exec($conn, $create_table_sql);
18+
19+
#Insert into table table0 big values
20+
$sql = 'insert into table0 values(?,?)';
21+
22+
$param1 = 922337203685477580;
23+
$param2 = 922337203685477581;
24+
$param3 = 922337203685477589;
25+
26+
//Prepare statement
27+
$prepared_stmt = db2_prepare($conn, $sql);
28+
db2_bind_param($prepared_stmt, 1, 'param1'); //Bind Parameter 1
29+
db2_bind_param($prepared_stmt, 2, 'param2'); //Bind parameter 2
30+
31+
//Execute statement
32+
db2_execute($prepared_stmt) ;
33+
//Retreive the inserted values
34+
$result = @db2_exec($conn,'select * from table0');
35+
if ($result) {
36+
while($row = db2_fetch_array($result)) {
37+
var_dump($row);
38+
print "\n";
39+
}
40+
}
41+
42+
$drop_proc_sql = 'drop procedure update_bigint_col';
43+
$stmt = @db2_exec(conn,drop_proc_sql);
44+
45+
//Create procedure with 2 IN parameters of type bigint
46+
$create_proc_sql = "CREATE PROCEDURE update_bigint_col (IN param1 bigint, IN param2 bigint)
47+
BEGIN
48+
UPDATE table0 SET (id1) = (param1) WHERE id2 = param2;
49+
END";
50+
$stmt = @db2_exec($conn, $create_proc_sql);
51+
52+
$call_sql = 'call update_bigint_col(?, ?)';
53+
54+
//Prepare statement
55+
$prepared_stmt = db2_prepare($conn, $call_sql);
56+
db2_bind_param($prepared_stmt, 1, 'param3'); //Bind Parameter 1
57+
print db2_stmt_errormsg();
58+
db2_bind_param($prepared_stmt, 2, 'param2'); //Bind Parameter 2
59+
60+
//Execute statement
61+
db2_execute($prepared_stmt);
62+
63+
//Retreive the values updated through the Stored Proc
64+
$result = @db2_exec($conn, 'select * from table0');
65+
if ($result) {
66+
while($row = db2_fetch_array($result)) {
67+
var_dump($row);
68+
print "\n";
69+
}
70+
}
71+
}
72+
?>
73+
74+
--EXPECT--
75+
array(2) {
76+
[0]=>
77+
string(18) "922337203685477580"
78+
[1]=>
79+
string(18) "922337203685477581"
80+
}
81+
82+
array(2) {
83+
[0]=>
84+
string(18) "922337203685477589"
85+
[1]=>
86+
string(18) "922337203685477581"
87+
}

0 commit comments

Comments
 (0)