日期:2014-05-17  浏览次数:20967 次

急!如何从一个shell文件中传递一个参数到sql文件中,不能用存储过程
就是在一个shell文件中调用一个sql文件,并传递一个参数到这个sql文件中,不能用存储过程


------解决方案--------------------
aa.sql的内容

select * from &tablename;

E:\> sqlplus system/genome @e:\aa.sql

SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 8月 6 12:18:56 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.


连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

输入 tablename 的值: dual
原值 1: select * from &tablename
新值 1: select * from dual

D
-
X

SQL>

------解决方案--------------------
C:\tmp> type test.sql
set verify off
select '&1 ' from dual;
exit

C:\tmp> sqlplus username/password@server @test.sql "any string "

SQL*Plus: Release 9.2.0.1.0 - Production on 星期一 8月 6 13:37:12 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.


连接到:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production


'ANYSTRING '
--------------------
any string

从Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production中断开

C:\tmp>