P. 1
026973

026973

|Views: 617|Likes:

More info:

Published by: Sravanthi Somavajhala on Apr 13, 2012
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

04/13/2012

pdf

text

original

Procedures, functions and triggers can be created using PHP. For example, to create the procedure myproc
the code is:

Script 27: createmyproc.php

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

$plsql = "create or replace procedure "
. "myproc(d_p in varchar2, i_p in number) as "
. "begin "
. "insert into mytab (mydata, myid) values (d_p, i_p);"
. "end;";
$s = oci_parse($c, $plsql);
$r = oci_execute($s);
if ($r) {

echo 'Procedure created';

}

?>

Note the last character of the PL/SQL statement is a semi-colon (after PL/SQL keyword end), which is
different to the way SQL statements are terminated.
PHP string concatenation was used to build the statement. If you don't do this and are on Windows,
see the end-of-line terminator issue mentioned below.
Similar to the performance advice on creating tables, avoid creating packages and procedures at
runtime in an application. Pre-create them as part of application installation.

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)//-->