A nice and simple function to call a stored procedure in an Oracle DataBase...it works great for me !!!
function ejecutarProcedure ($usuario, $password, $nombre_procedure, $parametros, $conexion = FALSE)
{
$any_error = FALSE;
$msg_error = '';
$error = '';
if (!$conexion){
$conexion = ocilogon($usuario, generarPass($usuario, $password), BD);
if (!$conexion) {
$msg_error = 'El usuario o la contraseña es incorrecto.';
$any_error = TRUE;
} else {
$procedure= "BEGIN " . $nombre_procedure . "(";
for($i=1; $i <= count($parametros); $i++){
$procedure .= ":param" . $i;
if ($i < count($parametros))
$procedure .= ", ";
}
$procedure .= ");END;";
$id_sentencia = ociparse($conexion, $procedure);
if (!$id_sentencia) {
$error = oci_error($conexion);
$msg_error = 'Error al procesar la modificación';
$any_error = TRUE;
}
if (!$any_error){
for($i=1; $i <= count($parametros); $i++){
$valor = $parametros[$i];
$nombre="var".$i;
$$nombre=$valor;
$param = ":param".$i;
if (!ocibindbyname($id_sentencia, $param, $$nombre, 256)){
$any_error = TRUE;
$msg_erroy = 'Error al hacer bin';
break;
}
}
if (!$any_error){
$resultado = ociexecute($id_sentencia);
if (!$resultado) {
$error = oci_error($id_sentencia);
$msg_error = 'Error al realizar la modificación';
$any_error = TRUE;
}
}
}
ocilogoff($conexion);
}
} else {
$procedure= "BEGIN " . $nombre_procedure . "(";
for($i=1; $i <= count($parametros); $i++){
$procedure .= ":param" . $i;
if ($i < count($parametros))
$procedure .= ", ";
}
$procedure .= ");END;";
$id_sentencia = ociparse($conexion, $procedure);
if (!$id_sentencia) {
$error = oci_error($conexion);
$msg_error = 'Error al procesar la modificación';
$any_error = TRUE;
}
if (!$any_error){
for($i=1; $i <= count($parametros); $i++){
$valor = $parametros[$i];
$nombre="var".$i;
$$nombre=$valor;
$param = ":param".$i;
if (!ocibindbyname($id_sentencia, $param, $$nombre, 256)){
$any_error = TRUE;
$msg_erroy = 'Error al hacer bin';
break;
}
}
if (!$any_error){
$resultado = ociexecute($id_sentencia);
if (!$resultado) {
$error = oci_error($id_sentencia);
$msg_error = 'Error al realizar la modificación';
$any_error = TRUE;
}
}
}
}
return array ($any_error, $msg_error);
}
----
Server IP: 69.147.83.197
Probable Submitter: 164.73.129.140
----
Manual Page -- http://www.php.net/manual/en/function.oci-parse.php
Edit -- https://master.php.net/note/edit/98016
Del: integrated -- https://master.php.net/note/delete/98016/integrated
Del: useless -- https://master.php.net/note/delete/98016/useless
Del: bad code -- https://master.php.net/note/delete/98016/bad+code
Del: spam -- https://master.php.net/note/delete/98016/spam
Del: non-english -- https://master.php.net/note/delete/98016/non-english
Del: in docs -- https://master.php.net/note/delete/98016/in+docs
Del: other reasons-- https://master.php.net/note/delete/98016
Reject -- https://master.php.net/note/reject/98016
Search -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.