PHP  
 PHP_HEAD
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/oci8/tests/refcur_prefetch_1.phpt ('Prefetch with REF cursor. Test different values for prefetch with oci_set_prefetch().')

Script

1: <?php
2:
require(dirname(__FILE__)."/connect.inc");
3:
4:
// Creates the necessary package and tables. 
5:
$stmtarray = array(
6:        
"DROP TABLE refcurtest",
7:        
"CREATE TABLE refcurtest (c1 NUMBER, c2 VARCHAR(20))",
8:            
"CREATE or REPLACE PACKAGE refcurpkg is
9:            type refcursortype is ref cursor;
10:            procedure open_ref_cur(cur1 out refcursortype);
11:            procedure fetch_ref_cur(cur1 in refcursortype, c1 out number,c2 out varchar2);
12:            end refcurpkg;"
,
13:           
"CREATE or REPLACE PACKAGE body refcurpkg is
14:           procedure open_ref_cur(cur1 out refcursortype) is
15:               begin
16:             open cur1 for select * from refcurtest order by c1;
17:           end open_ref_cur;
18:            procedure fetch_ref_cur(cur1 in refcursortype, c1 out number,
19:         c2 out varchar2) is
20:             begin
21:             fetch cur1 into c1,c2;
22:         end fetch_ref_cur;
23:          end refcurpkg;"
24:     
);
25:
26:
oci8_test_sql_execute($c$stmtarray);
27:
28:
// Insert 500 rows into the table.
29:
$insert_sql "INSERT INTO refcurtest (c1, c2) VALUES (:c1,:c2)";
30: if (!(
$s oci_parse($c$insert_sql))) {
31:     die(
"oci_parse(insert) failed!\n");
32: }
33:
34: for (
$i 0$i<=500$i++) {
35:     
$val2 'test'.$i;
36:     
oci_bind_by_name($s,':c1',$i);
37:     
oci_bind_by_name($s,':c2',$val2);
38:     if (!
oci_execute($s)) {
39:         die(
"oci_execute(insert) failed!\n");
40:     }
41: }
42:
43:
// Various values for prefetch
44:
$pref = array(0,1,501,499,250,12345,-12345,-1);
45: foreach(
$pref as $value) {
46:     echo
"-----------------------------------------------\n";
47:     echo 
"Test with Prefetch value set to $value \n";
48:     echo
"-----------------------------------------------\n";
49:     
$cur1 oci_new_cursor($c);
50:     
fetch_frm_php($c,$cur1,$value);
51:     
fetch_frm_plsql($c,$cur1);
52: }
53:
54:
55:
// This function sets the prefetch count to the given $value and fetches one row .
56:
57:
function fetch_frm_php($c,$cur1,$value) {
58:     
$sql1 "begin refcurpkg.open_ref_cur(:cur1); end;";
59:     
$s1 oci_parse($c,$sql1);
60:     if (!
oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) {
61:         die(
"oci_bind_by_name(sql1) failed!\n");
62:     }
63:     
oci_execute($s1);
64:     
oci_set_prefetch($cur1,$value);
65:     
oci_execute($cur1);
66:     echo 
"Fetch Row from PHP\n";
67:     
var_dump(oci_fetch_row($cur1));
68: }
69:  
70:
// This function calls the fetch_ref_cur procedure to get the values from the REF cur.
71:
72:
function fetch_frm_plsql($c,$cur1) {
73:     
$sql2 "begin refcurpkg.fetch_ref_cur(:curs1,:c1,:c2); end;";
74:     
$s2 oci_parse($c,$sql2);
75:     if (!
oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) {
76:         die(
"oci_bind_by_name(sql2) failed!\n");
77:     }
78:     if (!
oci_bind_by_name($s2,":c1",$c1,-1,SQLT_INT)) {
79:         die(
"oci_bind_by_name(sql2) failed!\n");
80:     }
81:     if (!
oci_bind_by_name($s2,":c2",$c2,20,SQLT_CHR)) {
82:         die(
"oci_bind_by_name(sql2) failed!\n");
83:     }
84:     
oci_execute($s2);
85:     echo 
"Fetch Row from PL/SQL\n";
86:     
var_dump($c1);
87:     
var_dump($c2);
88: }
89:
90:
// Clean up  here
91:
92:
$stmtarray = array(
93:     
"drop package refcurpkg",
94:     
"drop table refcurtest"
95:
);
96:
97:
oci8_test_sql_execute($c$stmtarray);
98:
99: echo 
"Done\n";
100:
?>
101:

Expected

-----------------------------------------------
Test with Prefetch value set to 0 
-----------------------------------------------
Fetch Row from PHP
array(2) {
  [0]=>
  string(%d) "0"
  [1]=>
  string(%d) "test0"
}
Fetch Row from PL/SQL
int(1)
string(%d) "test1"
-----------------------------------------------
Test with Prefetch value set to 1 
-----------------------------------------------
Fetch Row from PHP
array(2) {
  [0]=>
  string(%d) "0"
  [1]=>
  string(%d) "test0"
}
Fetch Row from PL/SQL
int(2)
string(%d) "test2"
-----------------------------------------------
Test with Prefetch value set to 501 
-----------------------------------------------
Fetch Row from PHP
array(2) {
  [0]=>
  string(%d) "0"
  [1]=>
  string(%d) "test0"
}

Warning: oci_execute(): ORA-01002: %s
ORA-06512: at "%s.REFCURPKG", line %d
ORA-06512: at line %d in %s on line %d
Fetch Row from PL/SQL
int(0)
NULL
-----------------------------------------------
Test with Prefetch value set to 499 
-----------------------------------------------
Fetch Row from PHP
array(2) {
  [0]=>
  string(%d) "0"
  [1]=>
  string(%d) "test0"
}
Fetch Row from PL/SQL
int(500)
string(%d) "test500"
-----------------------------------------------
Test with Prefetch value set to 250 
-----------------------------------------------
Fetch Row from PHP
array(2) {
  [0]=>
  string(%d) "0"
  [1]=>
  string(%d) "test0"
}
Fetch Row from PL/SQL
int(251)
string(%d) "test251"
-----------------------------------------------
Test with Prefetch value set to 12345 
-----------------------------------------------
Fetch Row from PHP
array(2) {
  [0]=>
  string(%d) "0"
  [1]=>
  string(%d) "test0"
}

Warning: oci_execute(): ORA-01002: %s
ORA-06512: at "%s.REFCURPKG", line %d
ORA-06512: at line %d in %s on line %d
Fetch Row from PL/SQL
int(0)
NULL
-----------------------------------------------
Test with Prefetch value set to -12345 
-----------------------------------------------

Warning: oci_set_prefetch(): Number of rows to be prefetched has to be greater than or equal to 0 in %s on line %d
Fetch Row from PHP
array(2) {
  [0]=>
  string(%d) "0"
  [1]=>
  string(%d) "test0"
}
Fetch Row from PL/SQL
int(101)
string(%d) "test101"
-----------------------------------------------
Test with Prefetch value set to -1 
-----------------------------------------------

Warning: oci_set_prefetch(): Number of rows to be prefetched has to be greater than or equal to 0 in %s on line %d
Fetch Row from PHP
array(2) {
  [0]=>
  string(%d) "0"
  [1]=>
  string(%d) "test0"
}
Fetch Row from PL/SQL
int(101)
string(%d) "test101"
Done

Output

***********************************************************************
Fatal NI connect error 12541, connecting to:
 (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=XE)(CID=(PROGRAM=php)(HOST=nex2.php.net)(USER=nlopess)))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))

  VERSION INFORMATION:
	TNS for Linux: Version 11.2.0.2.0 - Beta
	TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.2.0 - Beta
  Time: 17-JUN-2018 06:08:53
  Tracing not turned on.
  Tns error struct:
    ns main err code: 12541
    TNS-12541: TNS:no listener
    ns secondary err code: 12560
    nt main err code: 511
    TNS-00511: No listener

Fatal error: connect.inc: Failed to connect as 'system' to 'localhost/XE': ORA-12541: TNS:no listener in /var/php_gcov/PHP_HEAD/ext/oci8/tests/connect.inc on line 14
    nt secondary err code: 111
    nt OS err code: 0

Diff

001+ ***********************************************************************
002+ Fatal NI connect error 12541, connecting to:
003+  (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=XE)(CID=(PROGRAM=php)(HOST=nex2.php.net)(USER=nlopess)))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))
004+ 
005+   VERSION INFORMATION:
006+ 	TNS for Linux: Version 11.2.0.2.0 - Beta
007+ 	TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.2.0 - Beta
008+   Time: 17-JUN-2018 06:08:53
009+   Tracing not turned on.
010+   Tns error struct:
011+     ns main err code: 12541
012+     TNS-12541: TNS:no listener
013+     ns secondary err code: 12560
014+     nt main err code: 511
015+     TNS-00511: No listener
016+ 
017+ Fatal error: connect.inc: Failed to connect as 'system' to 'localhost/XE': ORA-12541: TNS:no listener in /var/php_gcov/PHP_HEAD/ext/oci8/tests/connect.inc on line 14
018+     nt secondary err code: 111
019+     nt OS err code: 0
001- -----------------------------------------------
002- Test with Prefetch value set to 0 
003- -----------------------------------------------
004- Fetch Row from PHP
005- array(2) {
006-   [0]=>
007-   string(%d) "0"
008-   [1]=>
009-   string(%d) "test0"
010- }
011- Fetch Row from PL/SQL
012- int(1)
013- string(%d) "test1"
014- -----------------------------------------------
015- Test with Prefetch value set to 1 
016- -----------------------------------------------
017- Fetch Row from PHP
018- array(2) {
019-   [0]=>
020-   string(%d) "0"
021-   [1]=>
022-   string(%d) "test0"
023- }
024- Fetch Row from PL/SQL
025- int(2)
026- string(%d) "test2"
027- -----------------------------------------------
028- Test with Prefetch value set to 501 
029- -----------------------------------------------
030- Fetch Row from PHP
031- array(2) {
032-   [0]=>
033-   string(%d) "0"
034-   [1]=>
035-   string(%d) "test0"
036- }
037- 
038- Warning: oci_execute(): ORA-01002: %s
039- ORA-06512: at "%s.REFCURPKG", line %d
040- ORA-06512: at line %d in %s on line %d
041- Fetch Row from PL/SQL
042- int(0)
043- NULL
044- -----------------------------------------------
045- Test with Prefetch value set to 499 
046- -----------------------------------------------
047- Fetch Row from PHP
048- array(2) {
049-   [0]=>
050-   string(%d) "0"
051-   [1]=>
052-   string(%d) "test0"
053- }
054- Fetch Row from PL/SQL
055- int(500)
056- string(%d) "test500"
057- -----------------------------------------------
058- Test with Prefetch value set to 250 
059- -----------------------------------------------
060- Fetch Row from PHP
061- array(2) {
062-   [0]=>
063-   string(%d) "0"
064-   [1]=>
065-   string(%d) "test0"
066- }
067- Fetch Row from PL/SQL
068- int(251)
069- string(%d) "test251"
070- -----------------------------------------------
071- Test with Prefetch value set to 12345 
072- -----------------------------------------------
073- Fetch Row from PHP
074- array(2) {
075-   [0]=>
076-   string(%d) "0"
077-   [1]=>
078-   string(%d) "test0"
079- }
080- 
081- Warning: oci_execute(): ORA-01002: %s
082- ORA-06512: at "%s.REFCURPKG", line %d
083- ORA-06512: at line %d in %s on line %d
084- Fetch Row from PL/SQL
085- int(0)
086- NULL
087- -----------------------------------------------
088- Test with Prefetch value set to -12345 
089- -----------------------------------------------
090- 
091- Warning: oci_set_prefetch(): Number of rows to be prefetched has to be greater than or equal to 0 in %s on line %d
092- Fetch Row from PHP
093- array(2) {
094-   [0]=>
095-   string(%d) "0"
096-   [1]=>
097-   string(%d) "test0"
098- }
099- Fetch Row from PL/SQL
100- int(101)
101- string(%d) "test101"
102- -----------------------------------------------
103- Test with Prefetch value set to -1 
104- -----------------------------------------------
105- 
106- Warning: oci_set_prefetch(): Number of rows to be prefetched has to be greater than or equal to 0 in %s on line %d
107- Fetch Row from PHP
108- array(2) {
109-   [0]=>
110-   string(%d) "0"
111-   [1]=>
112-   string(%d) "test0"
113- }
114- Fetch Row from PL/SQL
115- int(101)
116- string(%d) "test101"
117- Done

 

Generated at Mon, 18 Jun 2018 17:33:50 +0000 (5 days ago)

Copyright © 2005-2018 The PHP Group
All rights reserved.