stop reporting of a custom error (it is benign) to the php logfile
[openemr.git] / library / adodb / tests / testoci8cursor.php
bloba80fc9b9392d9382d2210f37856bb4145459905b
1 <?php
2 /*
3 V4.20 22 Feb 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
4 Released under both BSD license and Lesser GPL library license.
5 Whenever there is any discrepancy between the two licenses,
6 the BSD license will take precedence.
7 Set tabs to 4 for best viewing.
9 Latest version is available at http://php.weblogs.com/
13 Test for Oracle Variable Cursors, which are treated as ADOdb recordsets.
15 We have 2 examples. The first shows us using the Parameter statement.
16 The second shows us using the new ExecuteCursor($sql, $cursorName)
17 function.
19 ------------------------------------------------------------------
20 -- TEST PACKAGE YOU NEED TO INSTALL ON ORACLE - run from sql*plus
21 ------------------------------------------------------------------
24 -- TEST PACKAGE
25 CREATE OR REPLACE PACKAGE adodb AS
26 TYPE TabType IS REF CURSOR RETURN tab%ROWTYPE;
27 PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames in varchar);
28 PROCEDURE data_out(input IN varchar, output OUT varchar);
30 procedure myproc (p1 in number, p2 out number);
31 END adodb;
34 CREATE OR REPLACE PACKAGE BODY adodb AS
35 PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames in varchar) IS
36 BEGIN
37 OPEN tabcursor FOR SELECT * FROM tab where tname like tablenames;
38 END open_tab;
40 PROCEDURE data_out(input IN varchar, output OUT varchar) IS
41 BEGIN
42 output := 'Cinta Hati '||input;
43 END;
45 procedure myproc (p1 in number, p2 out number) as
46 begin
47 p2 := p1;
48 end;
49 END adodb;
52 ------------------------------------------------------------------
53 -- END PACKAGE
54 ------------------------------------------------------------------
58 include('../adodb.inc.php');
59 include('../tohtml.inc.php');
61 error_reporting(E_ALL);
62 $db = ADONewConnection('oci8');
63 $db->PConnect('','scott','natsoft');
64 $db->debug = 99;
70 define('MYNUM',5);
74 $stmt = $db->Prepare("BEGIN adodb.open_tab(:RS,'A%'); END;");
75 $db->InParameter($stmt, $cur, 'RS', -1, OCI_B_CURSOR);
76 $rs = $db->Execute($stmt);
78 if ($rs && !$rs->EOF) {
79 print "Test 1 RowCount: ".$rs->RecordCount()."<p>";
80 } else {
81 print "<b>Error in using Cursor Variables 1</b><p>";
85 print "<h4>Testing Stored Procedures for oci8</h4>";
87 $stid = $db->PrepareSP('BEGIN adodb.myproc('.MYNUM.', :myov); END;');
88 $db->OutParameter($stid, $myov, 'myov');
89 $db->Execute($stid);
90 if ($myov != MYNUM) print "<p><b>Error with myproc</b></p>";
93 $stmt = $db->PrepareSP("BEGIN adodb.data_out(:a1, :a2); END;",true);
94 $a1 = 'Malaysia';
95 //$a2 = ''; # a2 doesn't even need to be defined!
96 $db->InParameter($stmt,$a1,'a1');
97 $db->OutParameter($stmt,$a2,'a2');
98 $rs = $db->Execute($stmt);
99 if ($rs) {
100 if ($a2 !== 'Cinta Hati Malaysia') print "<b>Stored Procedure Error: a2 = $a2</b><p>";
101 else echo "OK: a2=$a2<p>";
102 } else {
103 print "<b>Error in using Stored Procedure IN/Out Variables</b><p>";
107 $tname = 'A%';
109 $stmt = $db->PrepareSP('select * from tab where tname like :tablename');
110 $db->Parameter($stmt,$tname,'tablename');
111 $rs = $db->Execute($stmt);
112 rs2html($rs);