stopping output after retlimit reached

Teradata Applications
Fan

stopping output after retlimit reached

Right now my code does:

 

.set retlimit 1000;
+---------+---------+---------+---------+---------+---------+---------+---------
+---------+---------+---------+---------+---------+-
select a,b,c,d,e from schema.table;

 *** Ok, Session 7989088, Request 3, Statement# 1
 *** Query completed. 106735398 rows found. 5 columns returned.
 *** Total elapsed time was 2 seconds.

 

So I get the 1000 lines of output but then the bteq command continues to run until all 106735398 rows are processed.

 

I'ld like the bteq command to terminate after the 1000 lines are displayed.


Accepted Solutions
Teradata Employee

Re: stopping output after retlimit reached

Technically... It does all the running of the query first. RETLIMIT in BTEQ operates after the fact, after the entire query has run to completion. It applies the limit only when BTEQ is retrieving results from the database. In this case the 106M rows are retrieved and placed in a spool file, then BTEQ retrieves 1000 of those rows.

 

 

If it is desired to only retrieve 1000 rows, put the qualification in the query itself using TOP 1000 syntax in the select list.

1 ACCEPTED SOLUTION
2 REPLIES
Teradata Employee

Re: stopping output after retlimit reached

Technically... It does all the running of the query first. RETLIMIT in BTEQ operates after the fact, after the entire query has run to completion. It applies the limit only when BTEQ is retrieving results from the database. In this case the 106M rows are retrieved and placed in a spool file, then BTEQ retrieves 1000 of those rows.

 

 

If it is desired to only retrieve 1000 rows, put the qualification in the query itself using TOP 1000 syntax in the select list.

Fan

Re: stopping output after retlimit reached

perfect!