1

Is it possible to fetch raw DB output of an Oracle DB within a QSqlQuery, e.g. by something like this:

QSqlQuery sqlQuery;
sqlQuery.prepare("exec dmbs_output.put_line('hello world');");
sqlQuery.exec();

Now I would like to access the output ('hello world' in this example).

1 Answer 1

2

Assuming that you have configured the buffer that DBMS_OUTPUT writes to by calling DBMS_OUTPUT.ENABLE earlier, you should be able to use the DBMS_OUTPUT.GET_LINE or GET_LINES procedure to fetch data from the buffer.

I'm not an expert with the QT libraries, but here is an example of calling a stored procedure that returns a collection in Qt that would appear to be what you'd need to do in order to call the GET_LINES procedure.

Sign up to request clarification or add additional context in comments.

4 Comments

When I bind a QVariant to the first parameter of GET_LINES the SQL query fails with an error message that the number of parameters of GET_LINES was not correct. Any ideas?
@fawick - GET_LINES takes two parameters. The first is an array to fetch the data into. The second is a number indicating how many lines you want to fetch. I'm guessing you didn't pass in the second parameter?
Nope, that's okay, it's the QSqlQuery::bindValue that doesn't actually bind my QVariant...
Okay, I decided to use a different approach and abadoned Qt for this purpose. It seems like QtSql is currently not powerful enough to fetch the SQL output directly. I came to use Python and cx_oracle instead and there using "DBMS_OUTPUT.GET_LINES" works like charm, so this answer really helped me!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.