php開発–Oracle ストアドプロシージャを呼び出すサンプル

1.プロシージャ
create or replace procedure empuserInfo_Get
(v_deptno in ctnuser.deptno%type,v_res out sys_refcursor)
is
begin
open v_res for select * from ctnuser where deptno=v_deptno;
end empuserInfo_Get;
2.PHPコード:
$Oracle_conn=oci_connect(“toyoUnk","!kanu&","wyhj");
$cur=oci_new_cursor($Oracle_conn);
$query="call empuserInfo_Get(:deptno,:v_cur)";
$statement=oci_parse($Oracle_conn,$query);
$deptno=15;

oci_bind_by_name($statement,":deptno",$deptno,16);
oci_bind_by_name($statement,":v_cur",$cur,-1,OCI_B_CURSOR);
//実行
oci_execute($statement);
oci_execute($cur);
while ($dat = oci_fetch_row($cur)) {
var_dump($dat);
}
oci_free_statement($statement);
oci_close($Oracle_conn);

PHP

Posted by arkgame