P. 1
Underground Php Oracle Manual

Underground Php Oracle Manual

|Views: 816|Likes:
Published by SANGARE SOULEYMANE

More info:

Published by: SANGARE SOULEYMANE on Apr 25, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/12/2013

pdf

text

original

Temporary LOBs can also be used to pass data to PL/SQL IN, and returned from OUT parameters. Given a
PL/SQL procedure that accepts a BLOB and inserts it into mybtab:

Script 71: inproc.sql

create or replace procedure inproc(pid in number, pdata in blob) as
begin

insert into mybtab (blobid, blobdata) values (pid, pdata);

end;
/
show errors

PHP code to pass a BLOB to INPROC would look like:

Script 72: inproc.php

$c = oci_connect('hr', 'hrpwd', 'localhost/XE');

$myblobid = 125;
$myv = 'a very large amount of binary data';

$s = oci_parse($c, 'begin inproc(:myblobid, :myblobdata); end;');
$lob = oci_new_descriptor($c, OCI_D_LOB);
oci_bind_by_name($s, ':MYBLOBID', $myblobid);
oci_bind_by_name($s, ':MYBLOBDATA', $lob, -1, OCI_B_BLOB);
$lob->writeTemporary($myv, OCI_TEMP_BLOB);
oci_execute($s);
$lob->close();

?>

If the PL/SQL procedure returns a BLOB as an OUT parameter:

Script 73: outproc.sql

create or replace procedure outproc(pid in number, pdata out blob) as
begin

select blobdata into pdata from mybtab where blobid = pid;

end;
/
show errors

PHP code to fetch and display the BLOB would look like:

196

Working with LOBs

Script 74: outproc.php

$c = oci_connect('hr', 'hrpwd', 'localhost/XE');

$myblobid = 125;

$s = oci_parse($c, "begin outproc(:myblobid, :myblobdata); end;");
$lob = oci_new_descriptor($c, OCI_D_LOB);
oci_bind_by_name($s, ':MYBLOBID', $myblobid);
oci_bind_by_name($s, ':MYBLOBDATA', $lob, -1, OCI_B_BLOB);
oci_execute($s, OCI_DEFAULT);
if (is_object($lob)) { // protect against a NULL LOB
$data = $lob->load();
$lob->free();
echo $data;

}

?>

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->