Using Locate Statement

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Using Locate Statement

Post by DS_SUPPORT »

Hi All,

I am building a dynamic array, by reading a flatfile. My Flatfile will have the values like

Code: Select all

JOB1,Y,N
JOB2,N,N
JOB3,Y,Y
So i am building the dynamic array (JOBLIST) also in the same manner.
So my dynamic array will look like

Code: Select all

JOB1,Y,N:@AM:
JOB2,N,N:@AM:
JOB3,Y,Y:@AM:
And inside the jobcontrol, i am reading the job names from DS_JOBS, so based on the jobname, i need to fetch the corresponding settings. So when i read the name JOB1 from DS_JOBS , i need the retrive the values Y,N from the dynamic array.

So I am using Locate statement, as it will be Very fater than For ... Next loop, and i can avoid running loop for every job.

I am using the Locate Statement like

Code: Select all

Locate JobName IN JOBLIST Setting POS Then
                  JobSettings = Field(JOBLIST<POS>,",",2,2)
               End Else
                  JobSettings = ""
               End

Here JobName will contain the value from DS_JOBS. The above Locate is not working because the actual string in the dynamic array looks like "JOB1,Y,N", where as i am searching the dynamic array only with a part of String. (with JOB1 alone). It is guranteed that each job will have a single row in the dynamic array.

How to achieve this with the Locate Statement itself?
Or is there I can change while building the dynamic array itself, because i am creating the dynamic array.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

LOCATE will not do a partial string search. You need the FINDSTR statement. By the way, if you OPEN the directory and READ the entire file in a single read statement, you will automatically have your dynamic array.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

Thanks for the information Ray, I will try that tomorrow. BTW how to read the entire file in a READ statement, in the help i am seeing only READSEQ statement.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Look in the DataStage BASIC manual.

DataStage BASIC can treat a directory as if it were a "table", with the file names in the directory being the "record keys" and the actual files being the "records". In this sense, after you use OPEN or OPENPATH to open the parent directory, a READ of a file yields a field-mark delimited dynamic array.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

Thanks, I resolved it by using FINDSTR.
Post Reply