如何在Windows命令脚本中使用sql * plus来控制流? [英] How to use sql*plus in Windows command script to control flow?

查看:55
本文介绍了如何在Windows命令脚本中使用sql * plus来控制流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用sql * plus来控制一个小的Windows命令脚本.

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

基本上,我想执行一些PL/SQL(也许从视图或表中选择或执行一个函数),该操作向我显示了数据库中某些行的状态,然后根据行的状态执行一些Windows命令.

Basically, I want to execute some PL/SQL (perhaps select from a view or table or execute a function) which shows me the status of some rows in the database, and then depending upon the state of the rows, perform some Windows commands.

我的问题是如何将结果返回到命令脚本中.

My problem is how to get the results back into the command script.

sqlplus user/password@server @script.sql

IF <CONDITIONAL HERE BASED on script.sql results> GOTO :runprocess

REM log and email that process had to be skipped
EXIT

:runprocess
REM run various Windows service commands

推荐答案

这是我最终使用的内容.

This is what I ended up using.

我的.cmd脚本:

@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

其中script.sql:

Where script.sql:

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

exit

这篇关于如何在Windows命令脚本中使用sql * plus来控制流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆