Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
90 views
in Technique[技术] by (71.8m points)

Extra output lines when calling SQL scripts from bacth file

I have a batch file where I am passing a value to SQL and then executing the SQL query. I am getting desired output but additionally few more lines also appearing in the output.

Batch File

set /p hostname="Enter hostname:"
echo %hostname%
set arg1=
set arg1=%arg1: =%
set COMMAND=sqlplus.exe -s %arg1% 
%COMMAND% @C:UsersinfodbaDesktopest.sql %hostname%

SQL file

select ID from Tablename where pid = '&1';

Here I am passing hostname to query as "&1" and I get this output:

old   1: select ID  from Tablename where pid='&1'     //extra lines
new   1: select ID from Tablename  where pid='SQY5760dznicWC'   //extra lines

SQY5760dznicWC/08_01_0_pdf_23o0akf8jwgy6.pdf    //desired output. 

but if I remove the &1 and pass the hostname directly, I am not getting those extra lines.

Please help me figure out how to remove those extra lines.

question from:https://stackoverflow.com/questions/65645041/extra-output-lines-when-calling-sql-scripts-from-bacth-file

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can suppress the variable substitution line by setting VERIFY to OFF using following command:

SET VERIFY OFF

You need to write this command in your sql script.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...