how ot use a loop in btep?

Tools & Utilities

how ot use a loop in btep?

Hi all!

      I want to make a loop like this:

      while (i <= j){

       do something;

       i ++;

      }

     ;

     but when i run the script it make mistake,anyone can help me ?tanks

Tags (1)
2 REPLIES
Enthusiast

Re: how ot use a loop in btep?

In BTEQ there is a command available to repeat a stement multiple times.

.REPEAT INTEGER(how many times you want to repeat)

Example:

.Repeat 5

SELECT Data;

This will repeat this select 5 times.

Khurram

Re: how ot use a loop in btep?

It may be worth it to call bteq inside of a BASH or Korn Shell.  It should give you much more flexibility than simply using the repeat function.

while [[ i -le j ]]
do

bteq << EOF
.LOGON

SELECT CURRENT_TIMESTAMP(0);

.EXIT
EOF

i++
done