从批处理文件向Oracle SQL文件传递参数 [英] Passing parameters to Oracle SQL file from Batch file

查看:95
本文介绍了从批处理文件向Oracle SQL文件传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个更新特定表的SQL文件.但是,表名称取决于安装软件的计算机名称. (类似:TableFooBar-MyMachine).我必须编写一个调用Oracle SQL脚本的批处理文件,该脚本将更新此表.

I have a SQL file that updates certain table. However, the table name depend on the machine name on which the software is installed. (Something like: TableFooBar-MyMachine). I have to write a batch file that calls an Oracle SQL script which will update this table.

因此,BatchFile->更新. SQL-> TableFooBar-MyMachine

So, BatchFile --> Update. Sql --> TableFooBar-MyMachine

更新. sql的语句如下:

The Update. Sql will have statement like:

Update TableFooBar-<Machine-Name> where fooid = -99;

此批处理文件需要在许多计算机上运行.实际上,此类表上有许多更新语句.我不希望人们编辑sql文件.相反,如果我在批处理文件中设置机器名称并将其传递给sql,我就完成了! 如何将计算机名称参数传递到.sql文件以实现此目的?

This batch file needs to run on many machines. There are actually many update statements on such tables. I do not want people to edit the sql files. Instead if I set the machine name in the batch file and pass it to the sql, I'm pretty much done! How do I pass the machine name parameter to the .sql file to achieve this?

推荐答案

您可以使用替换变量

update.sql

update.sql

--
Update TableFooBar-&1 set column_foo='bar' where fooid = -99;
--

然后致电

sqlplus foo/bar@db @update.sql <Machine-Name>

这篇关于从批处理文件向Oracle SQL文件传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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