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