0

I am trying to run many SQL scripts that are contained within a few directories for an Oracle database. My approach was to use an Oracle SQL*Plus file that could simply run each file (or directory if possible) at once. However, when I run the SQLPlus file using the default intellij run configuration, I notice that it doesn't properly call any of my scripts and then, proceeds to change the SQL Dialect of the file to just Oracle.

Is this approach even possible? I have tried changing the dialects of all the scripts to be PLUS but, with no success. I've used all the methods I have seen: @, @@, SQL > and :r to call my scripts but, everything seems to fail and then, change the dialect of the SQLPlus file. However, running the sql statements themselves inside the SQLPlus file works fine, and does not change the dialect.

techfun679
  • 66
  • 7
  • I should note that when you run an .sql file in intellij it automatically opens a popup where you are required to specify your execution target (database). – techfun679 Dec 26 '19 at 18:51
  • I'm not sure thats even a thing. To call a script with SQLPlus: ```sqlplus /@ @```. – alexherm Dec 26 '19 at 18:51
  • @alexherm Ive never used sqlplus before and definetely not with intellij before but, it seemed to look like a possibility for running all of my sql scripts at once. I also tried to look at simply creating an specific run configuration within my ide but, apparantly that is not supported either for .sql files... – techfun679 Dec 26 '19 at 19:02
  • 1
    For that I would create a shell script that calls each of the SQL programs, and just run the shell script. Check this thread for more info - https://stackoverflow.com/questions/10277983/connect-to-sqlplus-in-a-shell-script-and-run-sql-scripts – alexherm Dec 26 '19 at 19:10
  • Thanks I'll take a look. I'd prefer not to store database credentials in some script file also but, I'm not sure if thats possible unless I could get intellij to handle that for me. – techfun679 Dec 26 '19 at 19:14
  • if you don't want to store credentials in a script file (commendable) then where _do_ you plan to store them? If the answer is "in my head, I'll enter them at run time" then that is fine. Simply don't code the password as part of your scripts, and respond when prompted. – EdStevens Dec 26 '19 at 22:14
  • You can run sql script files without even opening them, see https://www.jetbrains.com/help/datagrip/run-a-query.html#run-an-sql-file-from-a-hard-drive You can also assign sql dialect for the directory: https://www.jetbrains.com/help/datagrip/settings-languages-sql-dialects.html#a5d84743 – Andrey Dec 27 '19 at 08:58

0 Answers0