hashhashu / sqltools-Oracle-driver

SQLTools Driver for Oracle
MIT License
5 stars 2 forks source link

Support of DBMS_OUTPUT #9

Closed a-langer closed 1 year ago

a-langer commented 1 year ago

I noticed that the DBMS_OUTPUT package does not output anything to the console, for example if you run:

BEGIN
    DBMS_OUTPUT.PUT_LINE('Hello');
END;

Then SQL CONSOLE: MESSAGES will be empty. Is this feature not supported or am I doing something wrong?

hashhashu commented 1 year ago

Hi, it's updated, please see if it satisfy your needs.

a-langer commented 1 year ago

Judging by the commit https://github.com/hashhashu/sqltools-Oracle-driver/commit/33afe65048e0c0daaadd157211babd8d04cdda24, you added the implementation through the pipelined function. I have some concerns about this method:

In this documentation https://node-oracledb.readthedocs.io/en/latest/user_guide/plsql_execution.html#using-dbms-output suggests another way to fetch DBMS_OUTPUT with node-oracledb - bind an output string when calling the DBMS_OUTPUT.GET_LINE() procedure, print the string, and then repeat until there is no more data. An example implementation can be found in the dbmsoutputgetline.js. This way, in my opinion, will be more universal.

hashhashu commented 1 year ago

Thanks for your detailed reply, i will try the way you metioned.

hashhashu commented 1 year ago

Hi, it's updated, see if it has any problems, thanks.

a-langer commented 1 year ago

I have executed the following code:

BEGIN
    DBMS_OUTPUT.PUT_LINE('Hello1');
    DBMS_OUTPUT.PUT_LINE('Hello2');
    DBMS_OUTPUT.PUT_LINE('Hello3');
END;

And got the output to the console with the text of the script: image The output was expected to contain three lines of text:

Hello1
Hello2
Hello3
a-langer commented 1 year ago

Result set includes all messages on single line: image In this case the result set was expected empty, because select query not executed.

hashhashu commented 1 year ago

yes, I put a summary page for the not select querys, and you can see the more detailed result when you right click and choose open editor with ... DD486362-4591-479c-B52E-37AA0AD461E9 image

a-langer commented 1 year ago

OK, if you open it in a text editor, then the messages are displayed correctly. But how convenient is it to open a message in a text editor every time? The DBMS_OUTPUT package is used to debug PL\SQL code, and for this you need to see the sequence of messages output to the console. As far as I understand, this view cannot display multi-line text, then it might make sense to direct the output of debug messages to a separate VSCode channel, which will be displayed on the standard "Output" tab? An example of creating a channel https://stackoverflow.com/a/58139566/19707292.

hashhashu commented 1 year ago

Hi, sorry for late reply, it's been busy lately. it's updated, you can see the output in the "output" tab and choose "SQLTOOLS" channel image

a-langer commented 1 year ago

Looks great, but unfortunately I can't test it:

Driver Oracle is not installed.

I tried reinstalling "sqltools-Oracle-driver" and "sqltools" but it doesn't help. I think that these are my local problems, I suggest closing this issue. Thanks for the work you've done!

hashhashu commented 1 year ago

"Driver Oracle is not installed." i guess it has something to do with the activation rule, i accidently remove the activation sentance and only when you open a sql file it will be activated, it should be good the next update.