Capturing stdout output from stored procedures using cx_Oracle

Is there a way in cx_Oracle to capture stdout output from an oracle stored procedure? They appear when using Oracle SQL Developer or SQL Plus, but there seems to be no way to get it using the database drivers.

+3
source share
3 answers

You can get dbms_output with DBMS_OUTPUT.GET_LINE(buffer, status). The state is 0 on success and 1 when there is no more data.

You can also use get_lines(lines, numlines). numlines- enter exit. You set it to the maximum number of lines, and it is set to the actual number in the output. You can call this in a loop and exit if the return is numlinesless than your input. linesis an output array.

+4
source

Whatever you post using put_line, you read using get_line; I believe all of these tools work, possibly including SQL * Plus.

Note that you need to name get_lineenough time to turn off the buffer. If you do not, the unread portion will be overwritten next put_line.

0
source

?

>>> conn = cx_Oracle.connect('user/pw@SCHEMA')
>>> cursor = conn.cursor()
>>> output = cursor.callproc("dbms_output.put_line", ['foo',])
>>> output
['foo']

- , - dict bindvars.

. : http://cx-oracle.sourceforge.net/html/cursor.html

-1

All Articles