PLSQL How to execute other scripts from a script?
Its been almost a decade since this was asked, is this still the case?
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?
Please sign in to leave a comment.
Nicholas Aupke, at the moment DataGrip users a bit different paradigm of Run Configurations where you can set a desired order.
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.
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.
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.
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.
We'll follow up with more information soon.
Thanks for the update. I actually don't want to be prompted for the schema, since my script drops the schema and re-creates it. I use this feature to ensure that I have a clean database before kicking off a test run. Prompting for the schema would break my workflow.
OK, thank you for confirming.