1--TEST-- 2Bind miscellaneous column types and generating errors 3--SKIPIF-- 4<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?> 5--FILE-- 6<?php 7 8require(__DIR__.'/connect.inc'); 9 10// Initialization 11 12$stmtarray = array( 13 "drop table bind_misccoltypes_errs_tab", 14 15 "create table bind_misccoltypes_errs_tab ( 16 id number, 17 char_t char(1), 18 char_t10 char(10), 19 varchar2_t10 varchar2(10), 20 number_t number, 21 number_t92 number(9,2), 22 number_t6 number(6), 23 date_t date, 24 timestamp_t timestamp, 25 float_t float, 26 binary_float_t binary_float, 27 binary_double_t binary_double, 28 decimal_t decimal, 29 integer_t integer, 30 nchar_t nchar(10), 31 nvarchar2_t10 nvarchar2(10), 32 varchar_t10 varchar(10) )", 33); 34 35oci8_test_sql_execute($c, $stmtarray); 36 37function check_col($c, $colname, $id) 38{ 39 $s = oci_parse($c, "select $colname from bind_misccoltypes_errs_tab where id = :id"); 40 oci_bind_by_name($s, ":id", $id); 41 oci_execute($s); 42 oci_fetch_all($s, $r); 43 var_dump($r); 44} 45 46// Tests 47 48echo "\nTest 1 insert numbers\n"; 49 50$n1 = -23253245.3432467; 51 52$s = oci_parse($c, "INSERT INTO bind_misccoltypes_errs_tab (id, number_t6) VALUES (1, :n1)"); 53oci_bind_by_name($s, ":n1", $n1); 54oci_execute($s); 55 56check_col($c, 'number_t6', 57); 57 58echo "\nTest 2 insert numbers\n"; 59 60$n1 = "Hello"; 61 62$s = oci_parse($c, "INSERT INTO bind_misccoltypes_errs_tab (id, number_t6) VALUES (2, :n1)"); 63oci_bind_by_name($s, ":n1", $n1); 64oci_execute($s); 65 66check_col($c, 'number_t6', 57); 67 68echo "\nTest 3 - too long CHAR\n"; 69 70$s = oci_parse($c, "INSERT INTO bind_misccoltypes_errs_tab (id, char_t) VALUES (3, :c2)"); 71$c2 = "AB"; 72oci_bind_by_name($s, ":c2", $c2, -1, SQLT_AFC); 73oci_execute($s); 74 75echo "\nTest 4 - too long VARCHAR2\n"; 76 77$s = oci_parse($c, "INSERT INTO bind_misccoltypes_errs_tab (id, varchar2_t10) VALUES (4, :c2)"); 78$c2 = "AAAAAAAAAAB"; 79oci_bind_by_name($s, ":c2", $c2, -1, SQLT_AFC); 80oci_execute($s); 81 82echo "\nTest 5 - invalid number\n"; 83 84$s = oci_parse($c, "INSERT INTO bind_misccoltypes_errs_tab (id, number_t) VALUES (5, :c2)"); 85$c2 = "ABC"; 86oci_bind_by_name($s, ":c2", $c2, -1, SQLT_AFC); 87oci_execute($s); 88 89echo "\nTest 6 - insert a VARCHAR2 with SQLT_BIN\n"; 90 91$s = oci_parse($c, "INSERT INTO bind_misccoltypes_errs_tab (id, varchar2_t10) VALUES (6, :c2)"); 92$c2 = "Hood 6"; 93oci_bind_by_name($s, ":c2", $c2, -1, SQLT_BIN); 94oci_execute($s); 95 96check_col($c, 'varchar2_t10', 6); 97 98echo "\nTest 7 - insert a VARCHAR2 with SQLT_LBI\n"; 99 100$s = oci_parse($c, "INSERT INTO bind_misccoltypes_errs_tab (id, varchar2_t10) VALUES (7, :c2)"); 101$c2 = "Hood 7"; 102oci_bind_by_name($s, ":c2", $c2, -1, SQLT_LBI); 103oci_execute($s); 104 105check_col($c, 'varchar2_t10', 7); 106 107 108// Clean up 109 110$stmtarray = array( 111 "drop table bind_misccoltypes_errs_tab" 112); 113 114oci8_test_sql_execute($c, $stmtarray); 115 116oci_close($c); 117 118?> 119--EXPECTF-- 120Test 1 insert numbers 121 122Warning: oci_execute(): ORA-01438: %s in %sbind_misccoltypes_errs.php on line %d 123array(1) { 124 ["NUMBER_T6"]=> 125 array(0) { 126 } 127} 128 129Test 2 insert numbers 130 131Warning: oci_execute(): ORA-01722: %s in %sbind_misccoltypes_errs.php on line %d 132array(1) { 133 ["NUMBER_T6"]=> 134 array(0) { 135 } 136} 137 138Test 3 - too long CHAR 139 140Warning: oci_execute(): ORA-12899: %r(%s "%s"."BIND_MISCCOLTYPES_ERRS_TAB"."CHAR_T" \(%s: 2, %s: 1\)|String data right truncation)%r in %sbind_misccoltypes_errs.php on line %d 141 142Test 4 - too long VARCHAR2 143 144Warning: oci_execute(): ORA-12899: %r(%s "%s"."BIND_MISCCOLTYPES_ERRS_TAB"."VARCHAR2_T10" \(%s: 11, %s: 10\)|%s data right truncation)%r in %sbind_misccoltypes_errs.php on line %d 145 146Test 5 - invalid number 147 148Warning: oci_execute(): ORA-01722: %s in %sbind_misccoltypes_errs.php on line %d 149 150Test 6 - insert a VARCHAR2 with SQLT_BIN 151 152Warning: oci_execute(): ORA-12899: %r(%s "%s"."BIND_MISCCOLTYPES_ERRS_TAB"."VARCHAR2_T10" \(%s: 12, %s: 10\)|String data right truncation)%r in %sbind_misccoltypes_errs.php on line %d 153array(1) { 154 ["VARCHAR2_T10"]=> 155 array(0) { 156 } 157} 158 159Test 7 - insert a VARCHAR2 with SQLT_LBI 160 161Warning: oci_execute(): ORA-12899: %r(%s "%s"."BIND_MISCCOLTYPES_ERRS_TAB"."VARCHAR2_T10" \(%s: 12, %s: 10\)|String data right truncation)%r in %sbind_misccoltypes_errs.php on line %d 162array(1) { 163 ["VARCHAR2_T10"]=> 164 array(0) { 165 } 166} 167