GOTO Command | Basic Teradata Query - GOTO - Basic Teradata Query

Basic Teradata® Query Reference - 20.00

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
Lake
VMware
Product
Basic Teradata Query
Release Number
20.00
Published
October 2023
ft:locale
en-US
ft:lastEdition
2025-04-02
dita:mapPath
gxl1691484661681.ditamap
dita:ditavalPath
obe1474387269547.ditaval
dita:id
psp1479308573013
Product Category
Teradata Tools and Utilities

Purpose

This command skips over all intervening BTEQ commands and SQL requests until a specified label is encountered, then resumes processing as usual.

Syntax



where the following is true:

labelname
The user-defined name of the statement to which control transfers, as specified by a subsequent LABEL command.

For more information, LABEL (LB).

Usage Notes

The GOTO command only transfers control forward; it cannot transfer control to a statement that occurs before the GOTO command. If a LABEL command statement is not provided which matches the labelname, BTEQ terminates the script.

The GOTO command is frequently used with the IF...THEN... command.

The GOTO command cannot be used in an SQL macro.

Example – GOTO

This example uses GOTO commands to transfer control forward to the LABEL statements SECTIONA or SECTIONB:

database workforce;
select empno
,hours from charges
where  proj_id = 'oe1-0001'
order by empno;
.IF activitycount = 0 then .GOTO SECTIONA
.IF activitycount >= 1 then .GOTO SECTIONB
.label SECTIONA
.REMARK 'Zero Hours on Account'
.GOTO SECTIONC
.label SECTIONB
.REMARK 'Total Hours on Account'
.label SECTIONC
.logoff      
.exit