-
-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exec pl/sql block #55
Comments
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);") |
i can't add something to production database :( |
|
okay. thx |
Does it make sense to support this in |
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. |
@mattn Thanks, should follow golang/go#18417 that aggregates some issues that would make the standard interface support SP param bindings. |
@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 |
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. |
Thanks @mattn, If the goal is to return a non-numerical rowid, then I would need to look at |
Is this now good with adding of SQL out? Can this be closed? |
@mattn Close this? |
This should be fixed. Please reopen you still have issue and it is related on go-oci8. |
Hi
How to execute and read output from pl/sql block?
r, _ := db.Exec("begin dbms_output.put_line('sdsdsdd'); end;")
The text was updated successfully, but these errors were encountered: