"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/adodb/adodb/tests/testoci8cursor.php Source File", "datetime" => "Sat Dec 2 19:22:27 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

testoci8cursor.php

00001 <?php
00002 /* 
00003 V4.80 8 Mar 2006  (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
00004   Released under both BSD license and Lesser GPL library license. 
00005   Whenever there is any discrepancy between the two licenses, 
00006   the BSD license will take precedence. 
00007   Set tabs to 4 for best viewing.
00008         
00009   Latest version is available at http://adodb.sourceforge.net
00010 */
00011 
00012 /*
00013         Test for Oracle Variable Cursors, which are treated as ADOdb recordsets.
00014         
00015         We have 2 examples. The first shows us using the Parameter statement. 
00016         The second shows us using the new ExecuteCursor($sql, $cursorName)
00017         function.
00018         
00019 ------------------------------------------------------------------
00020 -- TEST PACKAGE YOU NEED TO INSTALL ON ORACLE - run from sql*plus
00021 ------------------------------------------------------------------
00022 
00023 
00024 -- TEST PACKAGE
00025 CREATE OR REPLACE PACKAGE adodb AS
00026 TYPE TabType IS REF CURSOR RETURN tab%ROWTYPE;
00027 PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames in varchar);
00028 PROCEDURE data_out(input IN varchar, output OUT varchar); 
00029 
00030 procedure myproc (p1 in number, p2 out number);
00031 END adodb;
00032 /
00033 
00034 CREATE OR REPLACE PACKAGE BODY adodb AS
00035 PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames in varchar) IS
00036         BEGIN
00037                 OPEN tabcursor FOR SELECT * FROM tab where tname like tablenames;
00038         END open_tab;
00039         
00040 PROCEDURE data_out(input IN varchar, output OUT varchar) IS
00041         BEGIN
00042                 output := 'Cinta Hati '||input;
00043         END;
00044         
00045 procedure myproc (p1 in number, p2 out number) as
00046 begin
00047 p2 := p1;
00048 end;
00049 END adodb;
00050 /
00051 
00052 ------------------------------------------------------------------
00053 -- END PACKAGE
00054 ------------------------------------------------------------------
00055 
00056 */
00057 
00058 include('../adodb.inc.php');
00059 include('../tohtml.inc.php');
00060 
00061         error_reporting(E_ALL);
00062         $db = ADONewConnection('oci8');
00063         $db->PConnect('','scott','natsoft');
00064         $db->debug = 99;
00065 
00066 
00067 /*
00068 */
00069 
00070         define('MYNUM',5);
00071         
00072 
00073         $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:RS,'A%'); END;");
00074         
00075         if ($rs && !$rs->EOF) {
00076                 print "Test 1 RowCount: ".$rs->RecordCount()."<p>";
00077         } else {
00078                 print "<b>Error in using Cursor Variables 1</b><p>";
00079         }
00080         
00081         print "<h4>Testing Stored Procedures for oci8</h4>";
00082         
00083         $stid = $db->PrepareSP('BEGIN adodb.myproc('.MYNUM.', :myov); END;');
00084         $db->OutParameter($stid, $myov, 'myov');
00085         $db->Execute($stid);
00086         if ($myov != MYNUM) print "<p><b>Error with myproc</b></p>";
00087         
00088         
00089         $stmt = $db->PrepareSP("BEGIN adodb.data_out(:a1, :a2); END;",true);
00090         $a1 = 'Malaysia';
00091         //$a2 = ''; # a2 doesn't even need to be defined!
00092         $db->InParameter($stmt,$a1,'a1');
00093         $db->OutParameter($stmt,$a2,'a2');
00094         $rs = $db->Execute($stmt);
00095         if ($rs) {
00096                 if ($a2 !== 'Cinta Hati Malaysia') print "<b>Stored Procedure Error: a2 = $a2</b><p>";
00097                 else echo  "OK: a2=$a2<p>";
00098         } else {
00099                 print "<b>Error in using Stored Procedure IN/Out Variables</b><p>";
00100         }
00101         
00102         
00103         $tname = 'A%';
00104         
00105         $stmt = $db->PrepareSP('select * from tab where tname like :tablename');
00106         $db->Parameter($stmt,$tname,'tablename');
00107         $rs = $db->Execute($stmt);
00108         rs2html($rs);
00109                 
00110                 
00111 ?>