How to use sql*plus in Windows command script to control flow?

前端 未结 6 952
感动是毒
感动是毒 2020-12-28 22:58

I\'m trying to use sql*plus to control a small Windows command script.

Basically, I want to execute some PL/SQL (perhaps select from a view or table or execute a fun

6条回答
  •  抹茶落季
    2020-12-28 23:40

    This is what I ended up using.

    My .cmd script:

    @ECHO OFF
    ECHO Checking Oracle...
    
    for /f %%i in ('sqlplus -s user/password@database @script.sql') do @set count=%%i
    echo %count%
    
    IF %count% GTR 0 GOTO :skipped
    GOTO :runprocess
    

    Where script.sql:

    SELECT COUNT(*)
    FROM table
    WHERE criteria = 1;
    
    exit
    

提交回复
热议问题