如何使用批处理文件将绑定变量值传递给SQLplus

问题描述 投票:0回答:1

我想使用批处理文件将值传递给Sqlplus并将输出存储在excel中。

SQL code:

Select :v_customerName||'|'||id||'|'||SUBMISSION_DATE||'|'||VALUE
from job_summary 

在job_summary表中,我只有3列(id,date,value)。我必须使用批处理文件传递客户名称。

MY OUTPUT in Excel:
  |1|1-may-20|234
  |2|4-may-20|235
Output I want:
  abc|1|1-may-20|234
  abc|2|4-may-20|235

我现在不如何在批处理脚本中为客户提供价值。

My batch:
sqlplus hr/hr@ @Header.sql !customername!
oracle batch-file plsql sqlplus
1个回答
0
投票
set colsep ';' set ver off set heading off spool a.txt select '&1', ename, job from emp where deptno = 10; spool off exit

如下所述; Littlefoot是您要在输出文件中看到的参数:

c:\Temp>sqlplus scott/tiger @p Littlefoot

SQL*Plus: Release 11.2.0.2.0 Production on Uto Svi 12 07:14:38 2020

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


Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production


Littlefoot;CLARK     ;MANAGER
Littlefoot;KING      ;PRESIDENT
Littlefoot;MILLER    ;CLERK

Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

c:\Temp>

结果:

c:\Temp>type a.txt

Littlefoot;CLARK     ;MANAGER
Littlefoot;KING      ;PRESIDENT
Littlefoot;MILLER    ;CLERK


c:\Temp>

所以:

只是

    pass参数
  • 使用.sql符号引用它(在&脚本中] >>
© www.soinside.com 2019 - 2024. All rights reserved.