yajra / laravel-oci8

Oracle DB driver for Laravel via OCI8
https://yajrabox.com/docs/laravel-oci8
MIT License
834 stars 237 forks source link

Oci8 bindParam output parameter of type SQLT_NTY #412

Closed dbayona closed 1 year ago

dbayona commented 6 years ago

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

yajra commented 6 years ago

Not sure on this one but I think this SO post might helped?

josereina22 commented 4 years 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);

josereina22 commented 4 years ago

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

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 7 days since being marked as stale.