Code Monkey home page Code Monkey logo

Comments (13)

mattn avatar mattn commented on August 17, 2024

create utility function and do select

CREATE OR REPLACE PACKAGE dbms_output_table IS
   TYPE piped_output IS RECORD (dbms_output VARCHAR2(4000));
   TYPE piped_output_table IS TABLE OF piped_output;
   FUNCTION display RETURN piped_output_table PIPELINED;
END;
/

CREATE OR REPLACE PACKAGE BODY dbms_output_table IS
   FUNCTION display RETURN piped_output_table PIPELINED IS
      rec piped_output;
      p_status NUMBER;
   BEGIN
      DBMS_OUTPUT.GET_LINE(rec.dbms_output, p_status);
      WHILE p_status = 0 LOOP
         PIPE ROW(rec);
         DBMS_OUTPUT.GET_LINE(rec.dbms_output, p_status);
      END LOOP;
      RETURN;
   END;
END;
/
rows, err := db.Query("select * from table(dbms_output_table.display);")

from go-oci8.

zaz600 avatar zaz600 commented on August 17, 2024

i can't add something to production database :(

from go-oci8.

mattn avatar mattn commented on August 17, 2024

go-oci8 is possible to add implementation for fetch output, but database/sql doesn't provide way to set output-buffer for the query. So currently, it's not possible.

from go-oci8.

zaz600 avatar zaz600 commented on August 17, 2024

okay. thx

from go-oci8.

asaf avatar asaf commented on August 17, 2024

@mattn

Does it make sense to support this in go-oci8 out of the database/SQL interface?
Like the supplied functionality in the competitive oracle driver?

from go-oci8.

mattn avatar mattn commented on August 17, 2024

It's possible like go-sqlite3's hook. https://github.com/mattn/go-sqlite3/blob/master/_example/hook/hook.go

But currently, go-oci8 doesn't support yet.

from go-oci8.

asaf avatar asaf commented on August 17, 2024

@mattn Thanks, should follow golang/go#18417 that aggregates some issues that would make the standard interface support SP param bindings.

from go-oci8.

kardianos avatar kardianos commented on August 17, 2024

@mattn and @asaf I'm not familiar with this particular aspect of Oracle PL/SQL. Could someone explain this to me? The docs I found: https://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_output.htm#BABJCAJA

What is this typically used for in production databases? How are ways you might interact with it from your API such as database/sql?

from go-oci8.

mattn avatar mattn commented on August 17, 2024

One of the motivation is rowid in oracle. rowid is not number, so go-oci8 doesn't work correctly for the go's LastInsertId. The second, we have to allocate/free the buffer to get result specific value for the pl/sql.

from go-oci8.

kardianos avatar kardianos commented on August 17, 2024

Thanks @mattn,

If the goal is to return a non-numerical rowid, then I would need to look at sql.Result.LastInsertId. Can the driver receive output lines today? Is it just a matter of piping that to the end user somehow? Can multiple lines be outputted and does that happen commonly?

from go-oci8.

MichaelS11 avatar MichaelS11 commented on August 17, 2024

Is this now good with adding of SQL out? Can this be closed?

from go-oci8.

MichaelS11 avatar MichaelS11 commented on August 17, 2024

@mattn Close this?

from go-oci8.

mattn avatar mattn commented on August 17, 2024

This should be fixed. Please reopen you still have issue and it is related on go-oci8.

from go-oci8.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.