Can we use spool function in toad - oracle

I am able to use spool using sql*plus
We can use the UTL function for that.
But what I want to know, whether we use a spool in toad for Oracle.
I have tried and received the error Ora-00900.

spool is a SQL*Plus internal command so you cannot use it as plsql command
but you can easily do this through toad itself by
1- Write and Run the query into toad.
2- Right click on your datagrid in toad.
3- click on Export Dataset option and choose the configuration you want.

Related

Oracle SQL Developer running commands and seeing output

I create new connection in oracle SQL, then try to this query but don't why isn't running
Here the query:
I click run statement but it show nothing.
I select all the query and click run and try the shortcut also nothing showed
You aren't running a query, you're running a command.
And your results panel is collapsed. Drag this up.
Then you should see script output with feedback from running your ALTER USER command.

How to added the SQL query used generate the excel file in DATAGRIP IDE?

I'm a SQL developer user, usually, I extract data from Oracle database and store them into excel files on a daily basis, the nice thing about Oracle's SQL Developer when exporting the file into excel file, you get two worksheets one for your data, and another worksheet contain the SQL query that used to generate this report.
Now I'm using DATAGRIP IDE from JetBrains, I noticed when I export the file into excel sheet I only get the data and I don't the SQL query that I used to generate this excel file.
is there any way to add the SQL query to the exported file?
There is no possibility to include the SQL tab automatically. But every grid has it's own "View Query" option where you can see and copy the needed SQL.
To have this tab, please create a feature request here: https://youtrack.jetbrains.com/issues/DBE

Use dbms_output.put_line in Datagrip for .sql files

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.
Turn on this setting in the Output pane:
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:
Open your .sql file
Associate it with a console
Open the console and enable Enable SYS.DBMS_OUTPUT option
Go back to the .sql file and run your code. You'll be able to get the DBMS_OUTPUT in the console output.
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.
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).
For all that are reading this for version(s) > 2021.1
You can enable the output in the connection properties.
Source
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;
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.

Export DDL of View in SQL Developer

I have a view vw_Monitor in database
how can I export DDL of creation of this table into a file in Oracle SQL Developer?
Open Connections window
Expand Connection
Expand Views
Right click on the view and select export
From the pop up window, specify filename (default name being export.sql)
Click next and then finish

Exporting data from Oracle query to excel using query

I am having a select query, the result of which i want to be exported in a excel file using Oracle query and not any in-built operations.
I am using TOAD for Oracle. I am not sure if this is possible or not.
Any help would be of great use.
Thanks in Advance!
In Toad, it's pretty straightforward:
Run your query
click the "Export dataset" button
change export format to "Excel File"
enter a filename
Instead of pushing it into Excel, why not "pull" it into Excel? See get external data. An added bonus is that you can add this to your windows task scheduler that will update it for you.
http://office.microsoft.com/en-us/excel-help/connect-to-import-external-data-HP010089898.aspx

Resources