Annotation of embedaddon/php/ext/oci8/tests/bind_char_2.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: SELECT oci_bind_by_name with SQLT_AFC aka CHAR and dates
! 3: --SKIPIF--
! 4: <?php
! 5: if (!extension_loaded('oci8')) die ("skip no oci8 extension");
! 6: require(dirname(__FILE__)."/connect.inc");
! 7: // The bind buffer size edge cases seem to change each DB version.
! 8: if (preg_match('/Release 10\.2\./', oci_server_version($c), $matches) !== 1) {
! 9: if (preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 2) {
! 10: die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases");
! 11: }
! 12: }
! 13: if (preg_match('/^11\./', oci_client_version()) != 1) {
! 14: die("skip test expected to work only with Oracle 11g or greater version of client");
! 15: }
! 16: ?>
! 17: --ENV--
! 18: NLS_LANG=
! 19: --FILE--
! 20: <?php
! 21:
! 22: require(dirname(__FILE__).'/connect.inc');
! 23:
! 24: // Initialization
! 25:
! 26: $stmtarray = array(
! 27: "alter session set nls_date_format='YYYY-MM-DD'",
! 28: "drop table bind_char_tab",
! 29: "create table bind_char_tab (id number, c1 date)",
! 30: "insert into bind_char_tab values (1, '2008-04-20')",
! 31: );
! 32:
! 33: oci8_test_sql_execute($c, $stmtarray);
! 34:
! 35: // Run Test
! 36:
! 37: $bv1 = '2008-04-20';
! 38:
! 39: echo "Test 1.1: Type: default. Length: default\n";
! 40: $s = oci_parse($c, "select * from bind_char_tab where c1 = :bv");
! 41: $r = oci_bind_by_name($s, ":bv", $bv1);
! 42: if ($r)
! 43: do_e_q($s);
! 44:
! 45: echo "Test 1.2: Type: AFC. Length: default\n";
! 46: $r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC);
! 47: if ($r)
! 48: do_e_q($s);
! 49:
! 50: echo "Test 1.3: Type: AFC: Length: 0\n";
! 51: $r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC);
! 52: if ($r)
! 53: do_e_q($s);
! 54:
! 55: echo "Test 1.4: Type: AFC: Length: strlen\n";
! 56: $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC);
! 57: if ($r)
! 58: do_e_q($s);
! 59:
! 60: echo "Test 1.5: Type: AFC. Length: strlen-1\n";
! 61: $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC);
! 62: if ($r)
! 63: do_e_q($s);
! 64:
! 65: echo "Test 1.6: Type: AFC. Length: strlen+1\n";
! 66: $r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC);
! 67: if ($r)
! 68: do_e_q($s);
! 69:
! 70:
! 71: function do_e_q($s)
! 72: {
! 73: echo " Querying:\n";
! 74:
! 75: $r = @oci_execute($s);
! 76: if (!$r) {
! 77: $m = oci_error($s);
! 78: echo " Oci_execute error ORA-".$m['code']." Exiting Query\n";
! 79: return;
! 80: }
! 81: while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) {
! 82: foreach ($row as $item) {
! 83: echo " :" . $item . ":\n";
! 84: }
! 85: }
! 86: }
! 87:
! 88: // Cleanup
! 89: $stmtarray = array(
! 90: "drop table bind_char_tab"
! 91: );
! 92:
! 93: oci8_test_sql_execute($c, $stmtarray);
! 94:
! 95: echo "Done\n";
! 96:
! 97: ?>
! 98: --EXPECT--
! 99: Test 1.1: Type: default. Length: default
! 100: Querying:
! 101: :1:
! 102: :2008-04-20:
! 103: Test 1.2: Type: AFC. Length: default
! 104: Querying:
! 105: :1:
! 106: :2008-04-20:
! 107: Test 1.3: Type: AFC: Length: 0
! 108: Querying:
! 109: Oci_execute error ORA-1460 Exiting Query
! 110: Test 1.4: Type: AFC: Length: strlen
! 111: Querying:
! 112: :1:
! 113: :2008-04-20:
! 114: Test 1.5: Type: AFC. Length: strlen-1
! 115: Querying:
! 116: :1:
! 117: :2008-04-20:
! 118: Test 1.6: Type: AFC. Length: strlen+1
! 119: Querying:
! 120: :1:
! 121: :2008-04-20:
! 122: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>