Annotation of embedaddon/php/ext/oci8/tests/bind_number.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bind with NUMBER column variants
! 3: --SKIPIF--
! 4: <?php
! 5: if (!extension_loaded('oci8')) die("skip no oci8 extension");
! 6: if (preg_match('/^1[012]\./', oci_client_version()) != 1) {
! 7: die("skip test expected to work only with Oracle 10g or greater version of client");
! 8: }
! 9: ?>
! 10: --INI--
! 11: precision = 14
! 12: --FILE--
! 13: <?php
! 14:
! 15: require(dirname(__FILE__).'/connect.inc');
! 16:
! 17: // Initialization
! 18:
! 19: $stmtarray = array(
! 20: "drop table bind_number_tab",
! 21: "create table bind_number_tab (
! 22: id number,
! 23: number_t6 number(6),
! 24: float_t float,
! 25: binary_float_t binary_float,
! 26: binary_double_t binary_double,
! 27: decimal_t decimal,
! 28: integer_t integer)"
! 29: );
! 30:
! 31: oci8_test_sql_execute($c, $stmtarray);
! 32:
! 33: function check_col($c, $colname, $id)
! 34: {
! 35: $s = oci_parse($c, "select $colname from bind_number_tab where id = :id");
! 36: oci_bind_by_name($s, ":id", $id);
! 37: oci_execute($s);
! 38: oci_fetch_all($s, $r);
! 39: var_dump($r);
! 40: }
! 41:
! 42: // Run Test
! 43:
! 44: echo "Test 1 - invalid number\n";
! 45:
! 46: $s = oci_parse($c, "INSERT INTO bind_number_tab (id, number_t6) VALUES (1, :n1)");
! 47: $n1 = "Hello";
! 48: oci_bind_by_name($s, ":n1", $n1);
! 49: oci_execute($s);
! 50:
! 51: check_col($c, "number_t6", 1);
! 52:
! 53: echo "\nTEST66 insert a float\n";
! 54:
! 55: $s = oci_parse($c, "INSERT INTO bind_number_tab (id, float_t) VALUES (66, :f1)");
! 56: $f1 = 123.456;
! 57: oci_bind_by_name($s, ":f1", $f1);
! 58: oci_execute($s);
! 59:
! 60: check_col($c, 'float_t', 66);
! 61:
! 62: echo "\nTEST67 insert a binary float\n";
! 63:
! 64: $s = oci_parse($c, "INSERT INTO bind_number_tab (id, binary_float_t) VALUES (67, :f1)");
! 65: $f1 = 567.456;
! 66: oci_bind_by_name($s, ":f1", $f1);
! 67: oci_execute($s);
! 68:
! 69: check_col($c, 'binary_float_t', 67);
! 70:
! 71: echo "\nTEST69 insert a binary double\n";
! 72:
! 73: $s = oci_parse($c, "INSERT INTO bind_number_tab (id, binary_double_t) VALUES (69, :f1)");
! 74: $f1 = 567.456;
! 75: oci_bind_by_name($s, ":f1", $f1);
! 76: oci_execute($s);
! 77:
! 78: check_col($c, 'binary_double_t', 69);
! 79:
! 80: echo "\nTEST71 insert a decimal\n";
! 81:
! 82: $s = oci_parse($c, "INSERT INTO bind_number_tab (id, decimal_t) VALUES (71, :f1)");
! 83: $f1 = 123.789;
! 84: oci_bind_by_name($s, ":f1", $f1);
! 85: oci_execute($s);
! 86:
! 87: check_col($c, 'decimal_t', 71);
! 88:
! 89: echo "\nTEST72 insert a decimal\n";
! 90:
! 91: $s = oci_parse($c, "INSERT INTO bind_number_tab (id, decimal_t) VALUES (72, :f1)");
! 92: $f1 = 123.789;
! 93: oci_bind_by_name($s, ":f1", $f1, -1, SQLT_NUM);
! 94: oci_execute($s);
! 95:
! 96: check_col($c, 'decimal_t', 72);
! 97:
! 98: echo "\nTEST73 insert a double\n";
! 99:
! 100: $s = oci_parse($c, "INSERT INTO bind_number_tab (id, binary_double_t) VALUES (73, :f1)");
! 101: $f1 = 483.589;
! 102: oci_bind_by_name($s, ":f1", $f1);
! 103: oci_execute($s);
! 104:
! 105: check_col($c, 'binary_double_t', 73);
! 106:
! 107: echo "\nTEST75 insert a INTEGER\n";
! 108:
! 109: $s = oci_parse($c, "INSERT INTO bind_number_tab (id, integer_t) VALUES (75, :f1)");
! 110: $f1 = 589;
! 111: oci_bind_by_name($s, ":f1", $f1);
! 112: oci_execute($s);
! 113:
! 114: check_col($c, 'integer_t', 75);
! 115:
! 116: echo "\nTEST76 insert a INTEGER\n";
! 117:
! 118: $s = oci_parse($c, "INSERT INTO bind_number_tab (id, integer_t) VALUES (76, :f1)");
! 119: $f1 = 42;
! 120: oci_bind_by_name($s, ":f1", $f1, -1, SQLT_INT);
! 121: oci_execute($s);
! 122:
! 123: check_col($c, 'integer_t', 76);
! 124:
! 125:
! 126: // Clean up
! 127:
! 128: $stmtarray = array(
! 129: "drop table bind_number_tab"
! 130: );
! 131:
! 132: oci8_test_sql_execute($c, $stmtarray);
! 133:
! 134: ?>
! 135: ===DONE===
! 136: <?php exit(0); ?>
! 137: --EXPECTF--
! 138: Test 1 - invalid number
! 139:
! 140: Warning: oci_execute(): ORA-01722: %s in %sbind_number.php on line %d
! 141: array(1) {
! 142: ["NUMBER_T6"]=>
! 143: array(0) {
! 144: }
! 145: }
! 146:
! 147: TEST66 insert a float
! 148: array(1) {
! 149: ["FLOAT_T"]=>
! 150: array(1) {
! 151: [0]=>
! 152: string(7) "123.456"
! 153: }
! 154: }
! 155:
! 156: TEST67 insert a binary float
! 157: array(1) {
! 158: ["BINARY_FLOAT_T"]=>
! 159: array(1) {
! 160: [0]=>
! 161: string(%r15|8%r) "%r(5.67455994E\+002|567.4560)%r"
! 162: }
! 163: }
! 164:
! 165: TEST69 insert a binary double
! 166: array(1) {
! 167: ["BINARY_DOUBLE_T"]=>
! 168: array(1) {
! 169: [0]=>
! 170: string(%r23|16%r) "%r(5.6745600000000002E\+002|567.456000000000)%r"
! 171: }
! 172: }
! 173:
! 174: TEST71 insert a decimal
! 175: array(1) {
! 176: ["DECIMAL_T"]=>
! 177: array(1) {
! 178: [0]=>
! 179: string(3) "124"
! 180: }
! 181: }
! 182:
! 183: TEST72 insert a decimal
! 184: array(1) {
! 185: ["DECIMAL_T"]=>
! 186: array(1) {
! 187: [0]=>
! 188: string(1) "0"
! 189: }
! 190: }
! 191:
! 192: TEST73 insert a double
! 193: array(1) {
! 194: ["BINARY_DOUBLE_T"]=>
! 195: array(1) {
! 196: [0]=>
! 197: string(%r12|16%r) "%r(4.83589E\+002|483.589000000000)%r"
! 198: }
! 199: }
! 200:
! 201: TEST75 insert a INTEGER
! 202: array(1) {
! 203: ["INTEGER_T"]=>
! 204: array(1) {
! 205: [0]=>
! 206: string(3) "589"
! 207: }
! 208: }
! 209:
! 210: TEST76 insert a INTEGER
! 211: array(1) {
! 212: ["INTEGER_T"]=>
! 213: array(1) {
! 214: [0]=>
! 215: string(2) "42"
! 216: }
! 217: }
! 218: ===DONE===
! 219:
! 220:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>