faqts : Computers : Programming : Languages : PHP : Database Backed Sites : Oracle

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 13 people (54%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How do I get the result from a procedure with an array as OUT parameter?

Apr 20th, 2004 18:30
Eyzen Medina, Tomas Albinsson,


Hi:
You have to use a cursor as out parameter.
First you have to declare a cursor type with the same table definition 
and past to the procedure as Out Parameter.
Sample
TYPE CUR_PHP_LINES IS REF CURSOR RETURN VW_ORDER_LINE%ROWTYPE;
// The type CUR_PHP_LINES AS VW_ORDER_LINE%ROWTYPE  
Use a view when you don't want return a complete table.
In the procedure declare.
PROCEDURE NavigateOrders
( 
Pv_Rec OUT CUR_PHP_LINES 
) 
IS
OPEN Pv_Rec FOR SELECT * FROM MyTable
END;
So in your PHP Code
$db = OCILogon(DBUSER,DBPASSWORD);
$curs = OCINewCursor($db);
$STR_TO_PARCE = "begin NavigateOrders(:Pv_Rec); end;";
$stmt = OCIParse($db,$STR_TO_PARCE);
OCIBindByName($stmt,":Pv_Rec",$curs,-1,OCI_B_CURSOR);
OCIExecute($stmt);
OCIExecute($curs);
while(OCIFetchInto($curs,$data)){
	var_dump($data);
}
@OCIFreeCursor($curs);
@OCIFreeStatement($stmt);
@OCILogoff($db);
Tha's All :)
Eyzen