While loop in Datastage
Moderators: chulett, rschirm, roy
While loop in Datastage
I m facing one prob while running while loop in job control .
In our job we put while i<8 but it goes into infinite loop .Do we need any patch for running while loop in datastage ,coz we r facing this prob after migrating it to new server.
Thanks
In our job we put while i<8 but it goes into infinite loop .Do we need any patch for running while loop in datastage ,coz we r facing this prob after migrating it to new server.
Thanks
Re: While loop in Datastage
please paste your code for while loop for us to check, below syntax works fine with 7.5.1a version.
loop while i < 8 do
print i
i=i+1
repeat
loop while i < 8 do
print i
i=i+1
repeat
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
In our job we put while i<8 but it goes into infinite loop .
we are facing this prob after migrating it to new server ,before that it was fine.
we are facing this prob after migrating it to new server ,before that it was fine.
Code: Select all
LOOP
**This will be the no how many time u want to run the loop
WHILE i<=8 DO
**Calling the first job that will check in DW and write in a file
handle1=DSAttachJob("SrcLoadF5609001Date",DSJ.ERRFATAL)
handle1=DSPrepareJob(handle1)
err1=DSRunJob(handle1,DSJ.RUNNORMAL)
sleep 5
**Reading the file to see the data
DirPath = $Staging
BaseName = "\E1DateFile.txt"
FileName = DirPath : BaseName
OpenSeq FileName to FileVar
Then
ReadSeq FileLine from FileVar
Then
extractdate=FIELD(FileLine,",",1)
year1=FIELD(trim(extractdate),"-",1)
month1=FIELD(trim(extractdate),"-",2)
date1=FIELD(trim(extractdate),"-",3)
newdate= date1:"/":month1:"/":year1
datein=@DATE
dateext = Oconv(datein, "D/E")
[b]**goes into infine loop after this [/b]
IF newdate EQ dateext
THEN
handle2=DSAttachJob("GLMasterControlJob_FINAL_DV",DSJ.ERRFATAL)
handle2=DSPrepareJob(handle2)
err2=DSRunJob(handle2,DSJ.RUNNORMAL)
Exit
END
END
Else
var=""
**Wait for 20mins (1200 secs), here u specify data how long u want to wait in sec
SLEEP 1200
i=i+1
If i = 6
Then
handle2=DSAttachJob("E1Email1",DSJ.ERRFATAL)
handle2=DSPrepareJob(handle2)
err2=DSRunJob(handle2,DSJ.RUNNORMAL)
handle3=DSAttachJob("E1Email2",DSJ.ERRFATAL)
handle3=DSPrepareJob(handle3)
err3=DSRunJob(handle3,DSJ.RUNNORMAL)
handle4=DSAttachJob("E1Email3",DSJ.ERRFATAL)
handle4=DSPrepareJob(handle4)
err4=DSRunJob(handle4,DSJ.RUNNORMAL)
handle5=DSAttachJob("E1Email4",DSJ.ERRFATAL)
handle5=DSPrepareJob(handle5)
err5=DSRunJob(handle5,DSJ.RUNNORMAL)
End
CONTINUE
**it will go to loop start which will run the first job to check data from DB
END
END
REPEAT
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Wrap your code in Code tags so we can see the indenting. The typical reason for infinite loop is that there is a code path that does not update the loop index variable.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
To help him out I just popped his code into the BASIC engine and used "Format" on it to get it indented, then went back and updated it with "code" markers.
Unfortunately I'm out of time to actually diagnose the issue right now...
Content Editor...
P.S. - Replying to topic to let you know the update happened...
Unfortunately I'm out of time to actually diagnose the issue right now...
Content Editor...
P.S. - Replying to topic to let you know the update happened...
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
And according to me thats the exact problem in this code.ray.wurlod wrote:Wrap your code in Code tags so we can see the indenting. The typical reason for infinite loop is that there is a code path that does not update the loop index variable. ...
**goes into infine loop after this.
Yes because if its able to read the file i think its not going to the statement where the index is updated.
1. I can't see where you are initializing the counter. I generally prefer to do that.
2. Watch End tags to find the blocks end and see how the flow goes.
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.
Genius may have its limitations, but stupidity is not thus handicapped.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Does U work at your site? If not, why mention him in your documentation (comments)?
If OpenSeq takes its THEN clause, the loop variable is never incremented.
As already noted, it's never given an initial value either. You are relying on "nice" behaviour from the engine: "variable unassigned, zero used" will probably appear in your job log as the engine makes this substitution for you.
If OpenSeq takes its THEN clause, the loop variable is never incremented.
As already noted, it's never given an initial value either. You are relying on "nice" behaviour from the engine: "variable unassigned, zero used" will probably appear in your job log as the engine makes this substitution for you.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Shoar. Try this site for examples.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.