Closed dbayona closed 1 year ago
I have the same problem, I don't know how to read with PHP the following result of the collection object(OCI-Collection)#188 (1) { ["collection"]=> resource(253) of type (oci8 collection) } How is the correct form to access the output parameter $p2 $stmt->bindParam(":tPAISES", $p2, SQLT_NTY, -1, $options);
Resumen del problema o solicitud de función
Hola chicos, estoy usando yajra / laravel-oci8 para conectarme con la base de datos de Oracle. El problema es cuando llamo a un package.procedure con parámetros in / out. El resultado es el siguiente:
object(OCI-Collection)#188 (1) {
["collection"]=>
resource(253) of type (oci8 collection)
}
[null]
¿Cómo es la forma correcta de acceder al parámetro de salida $ p2?
$stmt->bindParam(":tPAISES", $p2, SQLT_NTY, -1, $options);
Fragmento de código del problema
Tipo de objeto
create or replace TYPE TR_PAIS IS OBJECT
(
CO_PAIS NUMBER,
DESCRIPCION VARCHAR2(50),
CONTINENTE VARCHAR2(20)
);
Tabla de tipos
create or replace TYPE TT_PAISES AS TABLE OF TR_PAIS;
Paquete
PROCEDURE GETCOUNTRY(P_IN_ID_COUNTRY IN NUMBER, P_OUT_TT_COUNTRY OUT TT_PAISES)
IS
BEGIN
SELECT *
BULK COLLECT INTO P_OUT_TT_COUNTRY
FROM (SELECT TR_PAIS(ID_COUNTRY, DESCRIPTION, LOCATION)
FROM TCOUNTRY
WHERE ID_COUNTRY = P_IN_ID_COUNTRY
);
END;
PHP
$pdo = DB::getPdo();
$p1 = 2;
$options = array("type_name" => "TT_PAISES");
$stmt = $pdo->prepare("begin SERVICIOS.GETCOUNTRY(:PI_ID_COUNTRY, :tPAISES); end;");
$stmt->bindParam(":PI_ID_COUNTRY", $p1, PDO::PARAM_INT);
$stmt->bindParam(":tPAISES", $p2, SQLT_NTY, -1, $options);
$stmt->execute();
return response()->json([var_dump ($p2)], 200);
Detalles del sistema
- Sistema operativo: Windows: 7
- Versión de PHP: 7.1.3
- Versión de Laravel: 5.6. *
- Laravel-OCI8 Versión: 5.6. *
me podrías ayudar, como resolviste esto?? ya que no puedo modificar los SP
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.
Summary of problem or feature request
Hi guys, I'm using yajra/laravel-oci8 to connect with oracle database. The problem is when I call a package.procedure with parameters in/out. The result it is as follow:
object(OCI-Collection)#188 (1) {
["collection"]=>
resource(253) of type (oci8 collection)
}
[null]
How is the correct form to access the output parameter $p2
$stmt->bindParam(":tPAISES", $p2, SQLT_NTY, -1, $options);
Code snippet of problem
Type Object
create or replace TYPE TR_PAIS IS OBJECT
(
CO_PAIS NUMBER,
DESCRIPCION VARCHAR2(50),
CONTINENTE VARCHAR2(20)
);
Type Table
create or replace TYPE TT_PAISES AS TABLE OF TR_PAIS;
Package
PROCEDURE GETCOUNTRY(P_IN_ID_COUNTRY IN NUMBER, P_OUT_TT_COUNTRY OUT TT_PAISES)
IS
BEGIN
SELECT *
BULK COLLECT INTO P_OUT_TT_COUNTRY
FROM (SELECT TR_PAIS(ID_COUNTRY, DESCRIPTION, LOCATION)
FROM TCOUNTRY
WHERE ID_COUNTRY = P_IN_ID_COUNTRY
);
END;
PHP
$pdo = DB::getPdo();
$p1 = 2;
$options = array("type_name" => "TT_PAISES");
$stmt = $pdo->prepare("begin SERVICIOS.GETCOUNTRY(:PI_ID_COUNTRY, :tPAISES); end;");
$stmt->bindParam(":PI_ID_COUNTRY", $p1, PDO::PARAM_INT);
$stmt->bindParam(":tPAISES", $p2, SQLT_NTY, -1, $options);
$stmt->execute();
return response()->json([var_dump ($p2)], 200);
System details