pass parameter to BTEQ script from a Windows batch file

Tools
Enthusiast

pass parameter to BTEQ script from a Windows batch file

Is there a way to pass a parameter to a BTEQ script that is called by a Windows batch file?

I tried the line

select count(*) from tbl_%1 where %1 is 200612, but I get an error message.

N.
1 REPLY
Enthusiast

Re: pass parameter to BTEQ script from a Windows batch file

You can generate script similar to below mentioned script.

del scr01.txt
echo .logon localhost/test,test >>scr01.txt
echo select * from samples01.%1% ; >>scr01.txt
echo .logoff >> scr01.txt
echo .quit >> scr01.txt
bteq < scr01.txt

and run the batch script as below

C:\>scr02.bat test1

C:\>del scr01.txt

C:\>echo .logon localhost/test,test 1>>scr01.txt

C:\>echo select * from samples01.test1 ; 1>>scr01.txt

C:\>echo .logoff 1>>scr01.txt

C:\>echo .quit 1>>scr01.txt

C:\>bteq 0

BTEQ 08.02.00.00 Thu Jul 18 09:33:12 2007

+---------+---------+---------+---------+---------+---------+---------+----
.logon localhost/test,

*** Logon successfully completed.
*** Transaction Semantics are BTET.
*** Character Set Name is 'ASCII'.

*** Total elapsed time was 3 seconds.

+---------+---------+---------+---------+---------+---------+---------+----
select * from samples01.test1 ;

*** Query completed. One row found. One column returned.
*** Total elapsed time was 1 second.

a
-----------
10

+---------+---------+---------+---------+---------+---------+---------+----
.logoff
*** You are now logged off from the DBC.
+---------+---------+---------+---------+---------+---------+---------+----
.quit
*** Exiting BTEQ...
*** RC (return code) = 0