Error php y procedimiento almacenado de Oracle
Publicado por Jose de Frias (1 intervención) el 13/10/2004 17:27:37
Intento llamar a un procedimiento almacenado en Oracle 9 desde php para que me devuelva
un valor almacenado en un campo. El codigo que utilizo es el siguiente:
PHP:
$cod_pais='ESP';
$consulta="begin PRUEBA('$cod_pais', :NOMPAIS);end;";
$sth = conexion($conn,$consulta);
OCIBindByName($sth, ":NOMPAIS", $nom_pais);
OCIExecute($sth);
OCIResult($sth,$nom_pais);
print $nom_pais;
la función conexión hace lo siguiente:
function conexion($conn,$query){
$stmt = OCIParse($conn, $query);
if (!OCIExecute($stmt)) {
$oerr = OCIError($stmt);
echo "Execute Code:".$oerr["code"];
if ($oerr["code"]) {
echo "Error:".$oerr["message"];
exit;
}
}
OCIFetch($stmt);
return $stmt;
}
PROCEDIMIENTO ALMACENADO:
PL/SQL: (PRUEBA)
(CODPAIS IN VARCHAR2, NOMPAIS OUT VARCHAR2)
AS
begin
SELECT NOM_PAIS INTO NOMPAIS FROM LINC.LOGOGCM_PAIS WHERE COD_PAIS = CODPAIS;
end;
El error es el siguiente:
Execute Code:1008Error:ORA-01008: no todas las variables han sido enlazadas
Agradezco de antemano cualquier ayuda que me podais ofrecer,
Un saludo a todos
un valor almacenado en un campo. El codigo que utilizo es el siguiente:
PHP:
$cod_pais='ESP';
$consulta="begin PRUEBA('$cod_pais', :NOMPAIS);end;";
$sth = conexion($conn,$consulta);
OCIBindByName($sth, ":NOMPAIS", $nom_pais);
OCIExecute($sth);
OCIResult($sth,$nom_pais);
print $nom_pais;
la función conexión hace lo siguiente:
function conexion($conn,$query){
$stmt = OCIParse($conn, $query);
if (!OCIExecute($stmt)) {
$oerr = OCIError($stmt);
echo "Execute Code:".$oerr["code"];
if ($oerr["code"]) {
echo "Error:".$oerr["message"];
exit;
}
}
OCIFetch($stmt);
return $stmt;
}
PROCEDIMIENTO ALMACENADO:
PL/SQL: (PRUEBA)
(CODPAIS IN VARCHAR2, NOMPAIS OUT VARCHAR2)
AS
begin
SELECT NOM_PAIS INTO NOMPAIS FROM LINC.LOGOGCM_PAIS WHERE COD_PAIS = CODPAIS;
end;
El error es el siguiente:
Execute Code:1008Error:ORA-01008: no todas las variables han sido enlazadas
Agradezco de antemano cualquier ayuda que me podais ofrecer,
Un saludo a todos
Valora esta pregunta


0