Reputation: 1207
I started to use Datagrip for my PL/SQL (school) projects that need the use of DBMS_OUTPUT.PUT_LINE
. Before this I was using Oracle SQL developer and I was able to use DBMS_OUTPUT by adding the following:
SET serveroutput ON;
There is a related question that shows how to enable or disable showing the contents of the DBMS_OUTPUT buffer but this only works for the Database Console tool window. How can I apply this to any .sql file? Currently, I am copying the content of my .sql files and run it in the Console tool window but there must be a better way.
Upvotes: 27
Views: 21828
Reputation: 256
Press shift+shift and then search for DBMS_OUTPUT and then you can enable/disable
I tried it with new UI
Upvotes: 7
Reputation: 131
Finaly found it! The previous answer didn't read the question and answer for intelij instead of datagrip which have completely different interface.
For 2021.1 right click on the console list in the service window and there should be a enable DBMS_OUTPUT when you right click.
Upvotes: 11
Reputation: 241
For all that are reading this for version(s) > 2021.1
You can enable the output in the connection properties. Source
Upvotes: 4
Reputation: 186
I second the comment from Prometheos II. Jakob also seems to say the same.
As you might know, the .sql scratch files HAVE to be associated with a console. You need to toggle the Enable SYS.DBMS_OUTPUT option icon in the associated console and you do see the effect when executing from the associated .sql file.
Steps:
Suboptimal design by JetBrains, but it works.
My IDE version: IntelliJ 2018.3 Ultimate (DataGrip uses the same code, I think)
Couldn't comment to existing sections due to low rep. Hence, added a new answer.
Upvotes: 16
Reputation: 143
This also works for sql files in DataGrip. Like moscas writes you need to activate the output console toggle button 'Enable SYS.DBMS_OUTPUT'.
Also you need to wrap it with begin end:
begin
dbms_output.put_line('test');
end;
Upvotes: 1
Reputation: 142713
When everything else fails, read the documentation: Showing DBMS_OUTPUT for Oracle:
For Oracle, you can enable or disable showing the contents of the DBMS_OUTPUT buffer in the output pane. To do that, use the apropriate icon (note by LF; can't reference that image) on the toolbar of the Database Console tool window (Ctrl+F8).
Upvotes: 5