0

I would like to create a windows batch file to execute a procedure in Oracle database. I saved my procedure in my hard disk as procedure.sql and wrote in my batch file

sqlplus username/password@111.111.11.11:1521/orcl "E:\sql scripts\procedure.sql"

When I ran the batch file, it said sqlplus is not a recognized command. My environment: win10, 64 digit orcl_11g. Please advise me what I can do to make this work.

Thanks

davidzxc574
  • 471
  • 1
  • 8
  • 21
  • Are you sure you have `sqlplus` installed? – PKey Jan 24 '18 at 10:52
  • 1
    Here we go again! :) is sqlplus in your path? if not, can you find the location of sqlplus and either run it from the path i.e `"c:\some path\sqlplus" username/pass...` or adding the full path to your environment path if you cannot find sqlplus on your system, perhaps consider installing it.. – Gerhard Jan 24 '18 at 10:56
  • 1
    [here is a good starting point for the error you receive...](https://stackoverflow.com/questions/48321639/is-not-recognized-as-an-internal-or-external-command-operable-program-or-bat) – Gerhard Jan 24 '18 at 10:58
  • a @ is required before the file, so I think `@"E:\sql scripts\procedure.sql"` But I am not familiar with sqlplus on windows, But your problem seems to be that windows does not find sqlplus.exe – miracle173 Jan 25 '18 at 07:24
  • @GerhardBarnard read my answer carefully. Maybe you were to fast. – miracle173 Jan 25 '18 at 07:39
  • @miracle173 it appears I was too fast :) – Gerhard Jan 25 '18 at 07:42

2 Answers2

0

Thanks for the help. Now I have Sqlplus installed and ran the batch file again in cmd. And the following command works.

"D:\setups\instantclient_11_2\sqlplus.exe" username/password@"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=111.111.111.11) (PORT=1521)))(CONNECT_DATA=(SID=orcl)))"  @"E:\sql scripts\procedure.sql"
davidzxc574
  • 471
  • 1
  • 8
  • 21
-1

Windows looks for your sql file from where you start cmd. So you have two ways .

start cmd where from your sql file is or cd to where your sql file is:

cd E:\sql scripts\
sqlplus username/password@111.111.11.11:1521/orcl
@procedure.sql
Gerhard
  • 22,678
  • 7
  • 27
  • 43
  • I suggest you read the question again, then look at your answer again, sqlplus is not found as it is either no installed, or not in path. Your answer purely aids the error as it will be looking for sqlplus in E:\sql scripts\ now, also your CD will fail as there are no double quotes wrapping your path with a space. – Gerhard Jan 25 '18 at 07:44