Accessing to OUT parameter (t_cursor type) from stored procedure using go and InstantClient

Viewed 199

I'm dealing with an Oracle DB, connecting from go via InstantClient (version 11) (https://github.com/mattn/go-oci8). I need to be able to load this object and browse results... t_cursor output parameter.

I have tried many strategies, I know how to map function parameters to go structures but I don't know how to work with t_cursor type since it seems not being implemented in InstantClient

Example of stored procedure

create or replace procedure EXAMPLE(a IN NUMBER, b IN NUMBER, c OUT T_CURSOR) AS BEGIN

[Edit] We have also tried to execute SQL blocks from code to try to handle this third parameter.

i.e.

If you add something like

declare
  c t_cursor;
begin
  EXAMPLE(:1, :2, c)
end

then I don't know how you can get the block to return a result set that contains the cursor.

declare
  c t_cursor;
begin
  EXAMPLE(:1, :2, c)
  select 1, c from dual
end

The whole block returning the result of that select would be ideal but oracle blocks do not return result sets afaik.

Anyone who can bear a hand on this?

Thank you very much

1 Answers

It can be done with the driver https://github.com/rana/ora instead.

*Rset may be passed to Stmt.Exe when prepared with a stored procedure accepting an OUT SYS_REFCURSOR

The README.me even has that exact example.

Caveats:

  1. It's unclear whether the database/sql interface may be used or you are limited to the lib specific API.
  2. Instant Client gets restricted to versions from 12.1.0.1.0 on.
Related