Ver Mensaje Individual
  #16 (permalink)  
Antiguo 11/07/2012, 10:54
viga05
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1
Antigüedad: 13 años, 7 meses
Puntos: 0
Respuesta: cursor de oracle - php

Para aquellos que estan buscando como leer curso de oracle desde PHP:
Algunos ejemplos de mi proyecto:
Aqui pongo un extracto de codigo:

function Nombre_funcion($pCedula,$pCurso,$pPeriodo,$pTipoUs er)
{
//EJECUTAR UNA FUNCION CON OCI8
$cn=$this->connect('ora','str'); //obtiene los datos de conexion forma string
$cnn=explode("*",$cn);
$conn = oci_connect($cnn[1],$cnn[2],$cnn[0]);
if (!$conn)
{
$e = oci_error();
$pSalida = $e;
trigger_error(htmlentities($e['message']), E_USER_ERROR);
}
else
{ $pSalida = "conexion exitoza";
//----------------------------------------- leyendo procedimiento ------------------------------------------
// $stid = oci_parse($conn, 'begin :pSalida := NOMBRE_PAQUETE.NOMBRE_PROCEDURE(:pCed,:pCur,:pPer, :pUser); end;');

// oci_bind_by_name($stid, ':pCed', $pCedula);
// oci_bind_by_name($stid, ':pCur', $pCurso);
// oci_bind_by_name($stid, ':pPer', $pPeriodo);
// oci_bind_by_name($stid, ':pUser', $pTipoUser);

// oci_bind_by_name($stid, ':pSalida', $pSalida,8000);

// oci_execute($stid);

// oci_free_statement($stid);


//----------------------------------------- leyendo un cursor ------------------------------------------
$curs = oci_new_cursor($conn);
$stmt = oci_parse($conn, "begin NOMBRE_PAQUETE.NOMBRE_PROCEDURE(:pCed,:pCur,:pPer, :pUser,:data); end;");
oci_bind_by_name($stmt, ':pCed', $pCedula);
oci_bind_by_name($stmt, ':pCur', $pCurso);
oci_bind_by_name($stmt, ':pPer', $pPeriodo);
oci_bind_by_name($stmt, ':pUser', $pTipoUser);

oci_bind_by_name($stmt, "data", $curs, -1, OCI_B_CURSOR);
oci_execute($stmt);
oci_execute($curs);

while ($data = oci_fetch_assoc($curs)) {
$pSalida=$data['CODIGO'].'|'.$data['ASISTENCIA'].'|'.$data['DESCRIPCION'];
}
oci_free_statement($stmt);
oci_free_statement($curs);
}

oci_close($conn);

return $pSalida;
}