Creating and Using Run Files - Basic Teradata Query

Basic Teradata Query Reference

Product
Basic Teradata Query
Release Number
15.00
Language
English (United States)
Last Update
2018-09-25
dita:id
B035-2414
lifecycle
previous
Product Category
Teradata Tools and Utilities

Creating and Using Run Files

BTEQ run files are the same as scripts or input stream files except that they are not defined as the SYSIN file for automatic execution when BTEQ is invoked. To execute the file, define the file with a z/OS DD statement. Then, invoke BTEQ and use the RUN command to execute the file.

Creating a Run File

To create a BTEQ run file that displays the contents of the Department table in the default database, create a file called SAMPFILE, and enter the following BTEQ script:

   .LOGON tdpid/userid,password 
   SELECT * FROM department;
   .LOGOFF

Identifying a Run File as a Valid ddname

After creating and saving a run file, identify it as a valid ddname:

 

If Using

Enter

TSO

ALLOC FI(SAMPFILE) DA(sampfile.script) SHR

Executing a Run File

To execute the run file, enter either form of the BTEQ RUN command:

   .RUN FILE=sampfile

or

   .RUN DDNAME=sampfile

Before running the file, BTEQ echoes the RUN command, followed by the BTEQ command prompt. BTEQ then executes each statement in the run file as though it was entered interactively.

Terminating a Run File

If a run file does not end with either an EXIT or a QUIT command, BTEQ completes executing the last statement, returns a warning message, and then switches back to reading from the standard input stream. When using BTEQ interactively, BTEQ’s command prompt is given. For example:

   *** Warning:  EOF on INPUT stream. 
   BTEQ -- Enter your Teradata SQL request or BTEQ command: 

Note: For information on I/O errors and abends, refer to “I/O Errors and Abends” on page 95.

Displaying Run File Results

Depending on the configuration of the SYSPRINT specification, BTEQ either displays the results on the user terminal or writes them to the specified file:

   .LOGON fml,  
   *** Logon successfully completed. 
   *** Total elapsed time was 3 seconds. 
   
   SELECT * FROM department;
   *** Query completed. 5 rows found. 4 columns returned.
   *** Total elapsed time was 3 seconds. 
   
   DeptNo   DeptName      Loc  MgrNo 
   ------   ------------  ---  ----- 
      500   Engineering   ATL  10012 
      700   Marketing     NYC  10021 
      300   Exec Office   NYC  10018 
      600   Manufacturing CHI  10007 
      100   Admin         NYC  10011 
   
   .LOGOFF 
   *** You are now logged off from the DBC. 
   
   *** Warning: EOF on INPUT stream.

Note: For short jobs, it might be advantageous to execute a run file interactively and display the results on a terminal screen. For longer jobs, it might be better for BTEQ to write the results to a SYSPRINT file. In the latter cases, it is necessary to define a SYSPRINT file as a valid ddname using a z/OS DD statement before executing the RUN command.