Page 1 of 1

Start Loop

Posted: Fri Oct 27, 2006 9:07 pm
by thumsup9
Hello All,

I am currently running a job from a sequencer.The Sequencer has a Start Job Activity and End Loop. I have to run the same job for number of days say 20 or more.

I am currently passing the a parameter in the start loop and the value is in format YYYYMMDD

From -- #BeginDate#
Step--- 1
To----- #EndDate#

Its runs good, but i know this isnt a right approach and this wont solve my problem.I want to pass the date not as numeric but in its original format say YYYY-MM-DD or MM-DD-YYYY.

Please advice,

Thanks,

Posted: Sat Oct 28, 2006 2:07 am
by kumar_s
You still can convert the integer into date in you job.

Re: Start Loop

Posted: Sat Oct 28, 2006 8:19 am
by chulett
thumsup9 wrote:Its runs good, but i know this isnt a right approach and this wont solve my problem.I want to pass the date not as numeric but in its original format say YYYY-MM-DD or MM-DD-YYYY.
You can't - not if you want the Loop stages to control the iterations. You'd have to roll your own, I would think, if you really want to stick with ISO dates for some reason.

There's nothing wrong with your approach per se, and you'll need to stick with 'numeric' dates - the only thing you are missing is converting them to internal format first. If you do that then you can iterate from BeginDate to EndDate with a step of 1, with each step being a day.

Posted: Sat Oct 28, 2006 11:45 am
by thumsup9
Thx Craig and Kumar,

I think i was confused and also confused you,

I have main sequencer job sqDimensionLoad.It has 3 job activities,

loadjob1,loadjob2,sqloadjob3.( All these jobs take #BeginDate# retunred by a routine as input to run each day 10/28 )

sqloadjob3 is a sequencer by itself which has 1 job activity

startloop--loadjob3--endloop.

I want to run sqloadjob3 job for say 2days (10/26,10/27,10/28 back from #BeginDate# ,how do I run this particular job for 3 different days while calling this job from sqDimensionLoad where we are passing #BeginDate#

Please ask me if you need further clarification,

Thanks,

Posted: Sat Oct 28, 2006 1:58 pm
by ray.wurlod
Create a delimited list of dates in an upstream Routine, and use that as the driver for a List loop. Error handling has been omitted here for clarity.

Code: Select all

FUNCTION ListOfDates(StartDate,EndDate)
intStartDate = Iconv(StartDate, "DYMD")
intEndDate = Iconv(EndDate, "DYMD")
Ans = ""
For intDate = intStartDate To intEndDate
   Ans<-1> = intDate
Next IntDate
Convert @FM To "," In Ans
RETURN(Ans)

Posted: Sat Oct 28, 2006 5:12 pm
by chulett
Ray's got another way having the Loop step through a delimited list of dates. Don't see why the way I outlined wouldn't work as well, the decider would be how you needed to use the parameter, if you had a chance to switch it back to 'external' format within the job or if you needed to use it before there would be any chance to do that - like in SQL.

Probably easiest to take Ray's route as it can use the dates in the format you'd prefer. Then something like this in the Job Activity stage that runs sqloadjob3 to pass in the iteration date from the delimited list:

Code: Select all

Trim(EReplace(YourLoopList.$Counter,@FM,""))

Posted: Sat Oct 28, 2006 10:01 pm
by ray.wurlod
The routine could always switch them back, returning instead a list of external format dates. I just happen to prefer using internal format in server jobs.

Posted: Sun Oct 29, 2006 1:09 am
by thumsup9
Thanks Ray and Craig. I wanted to get back to you once I test it against our scenario and you know my answer, that fits perfectly.Thanks for all your inputs...

Thums !!