PLSQL How to execute other scripts from a script?

Its been almost a decade since this was asked, is this still the case?

https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000003430-Execute-SQL-script-with-a-list-of-scripts-files-inside

 

I would like to move from Toad or SQL Developer to Datagrip, but cannot seem to execute scripts that use the @@ reference.

@@set_variables.sql
@@script1.sql

//update tableA

@@script2.sql
@@script3.sql

//update tableB

@script4.sql

 Currently, after setting the dialect, it recognizes the actual sql in the main script but just ignores all script references.  Am I missing something on how to do this?

0
6 comments

Nicholas Aupke, at the moment DataGrip users a bit different paradigm of Run Configurations where you can set a desired order.

1

I would like to use the Run Configuration feature to simplify rebuilding my database. I have two scripts - one that drops and recreates the schema (including all tables) and another that regenerates all views. Both include “use” statements.

In the Run/Debug Configurations dialog, I get a warning that my scripts contain schema switches, which is OK. However, even when I select a data source (DB server) only (no schema), I still see these warnings. It seems that if only a data source is selected, the warnings should not apply.

 

0
Hi,

Yes, that's a warning you'd get when switching schemas in your script:

https://www.jetbrains.com/help/datagrip/run-sql-files.html#run_sql_file

Please provide a sample of your script where schema switching is not applied. You can just include basic statements without specifying routine details.

We'll have a look.
0

Thank you for the response. I understand the need for the warning when a schema is selected as part of the data source. I am just wondering if the warning should be displayed when a schema is not selected. In that case, the script would be required to contain “use” statements, so perhaps it should not trigger a warning in this configuration.

 

0
I have just run a MSSQL script with use statements where I used different databases, but couldn't catch any warnings in the output in 2024.1.1 version. May I know your   current IDE version and the database over which you executed your script  from Run Config section?
0

The warnings are in the dialog, not the script output.

As you can see, I have not selected a schema in my configuration. My scripts would therefore have to include a “use” statement, or they would not work. I am suggesting that the UI not display the warning icon in this case. In fact, it might actually make more sense to display a warning if a script does not include a “use” statement when no schema is selected.

0

Please sign in to leave a comment.