Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 04 Sep 2003 @ 16:11:39 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Stored Procedure that Loops
 
From:   Figge, Jason

The only way to loop in BTEQ is by using the REPEAT command. However, this requires a source file which will always be finite in length. You could add millions of rows, but this would be very bad practice. A better way would be to use the following files:

process.sql
-----------
/* Logon */
.logon /,;
Database ;

/* Execute your three loop statements - Check for errors as necessary */
s1. a SQL bulk delete
s2. a bulk ins/sel;
s3. a bulk Update;

If ACTIVITYCOUNT != 0 THEN .QUIT 0;
.QUIT 99;

loop.bat
--------
@Echo off
REM Launch database statements
Bteq < process.sql > error.log

Rem Check for a non zero return code
If ERRORLEVEL 1 EXIT
Loop.bat

I understand there may be issues with getting the return code from BTEQ in a Batch file, but we effectively do this all the time, only our scripting lanuage is Perl, and it works just fine. The above files are theoretical, so you may have to play with them a little first. If you used the .RUN approach from within BTEQ and the script you execute contains subsequent .RUN statements, then you'll eventuall run out of stack space and/or memory.

Jason



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023