I'm new to BTEQ, trying to execute in batch mode via .bat file

Tools & Utilities

I'm new to BTEQ, trying to execute in batch mode via .bat file

I created a file test_it.bat and test_it.txt, when I call test_it.bat from a command prompt the BTEQ script keeps stopping and asking to enter logon info and I have the logon command specified in the test_it.txt file:

test_it.bat

echo off

cd G:\COMMON\dw\Teradata_Output

bteq test_it.txt custlog.log 2>&1

@echo off goto end

:end

@echo exit

test_it.txt

.RUN FILE = G:\COMMON\dw\Teradata_Output\logon.txt

.EXPORT DATA FILE = G:\COMMON\dw\test.csv

.SET SEPARATOR ','

SELECT * FROM HRCP_SEMANTIC_COGNOS_V.BRNCH_LOC_DIM WHERE CO_CD = 'HG';

.LOGOFF

.EXIT

Here is the output from the command prompt screen:

G:\COMMON\dw\Teradata_Output>test_it.bat

G:\COMMON\dw\Teradata_Output>echo off

 Teradata BTEQ 15.00.00.00 for WIN32. PID: 7900

 Copyright 1984-2014, Teradata Corporation. ALL RIGHTS RESERVED.

 Enter your logon or BTEQ command:

test_it.txt custlog.log

 *** Warning: You must log on before sending SQL requests.

 Teradata BTEQ 15.00.00.00 for WIN32. Enter your logon or BTEQ command:

.run file = g:\common\dw\teradata_output\logon.txt

.run file = g:\common\dw\teradata_output\logon.txt

 Teradata BTEQ 15.00.00.00 for WIN32. Enter your logon or BTEQ command:

.LOGON GDWP/showcase,

 *** Logon successfully completed.

 *** Teradata Database Release is 14.10.06.01

 *** Teradata Database Version is 14.10.06.01

 *** Transaction Semantics are BTET.

 *** Session Character Set Name is 'ASCII'.

 *** Total elapsed time was 2 seconds.

 BTEQ -- Enter your SQL request or BTEQ command:

 *** Warning: EOF on INPUT stream.

 BTEQ -- Enter your SQL request or BTEQ command:

.logoff

.logoff

 *** You are now logged off from the DBC.

 Teradata BTEQ 15.00.00.00 for WIN32. Enter your logon or BTEQ command:

.exit

.exit

 *** Exiting BTEQ...

 *** RC (return code) = 2

off goto end

exit

G:\COMMON\dw\Teradata_Output>

The command screen stops after the "*** Warning: You must log on before sending SQL requests." and prompts for me enter the logon info.  I manually execute the .RUN command ".run file = g:\common\dw\teradata_output\logon.txt" which is specified in the test_it.txt file.

Basically I'm trying to find a way to execute the test_it.txt in batch so I can schedule the job to run daily.

Tags (2)
2 REPLIES
Junior Supporter

Re: I'm new to BTEQ, trying to execute in batch mode via .bat file

Hi.

There are 'lower than' ("<") and 'greater than' (">") signs missing in your call to bteq:

bteq < test_it.txt > custlog.log 2>&1

HTH.

Cheers.

Carlos.

Re: I'm new to BTEQ, trying to execute in batch mode via .bat file

Thanks CarlosAl, you are the man, worked like a charm...