Page 1 of 1

Checking unique values in all records.

Posted: Fri May 30, 2008 8:15 am
by tom
Hi Dsxians,

I have a requirement to check the date column value is same for all the records
from source file using transformer stage in the extract job.
For eg:
run_date

01/23/2008
01/23/2008
01/23/2008
01/23/2008
01/23/2008

If it is not same for all the records,I want to stop the process.

I tried writing the changed values to a temp file using the below condition and check the file size at sequence
level and if there is changed value(ie temp file size greater than zero) i am controlling the process by writing a
message to log Utilitymesssgetolog(" SDSD").

Condition is

Stage variables-

svCurr --> run_date
svUni -->If svPrev <> svCurr Then '1' Else '0'
svPrev --> run_date

Constraint-->Svuni =1
But in this condition,even if all the date values are same the first two values are writing to the file.

01/23/2008
01/23/2008

Could you please help me to acheive this.Thanks.

Re: Checking unique values in all records.

Posted: Fri May 30, 2008 8:42 am
by rajngt
Modify the stage variable as below:

Stage variables-

svCurr --> run_date
svUni -->If svPrev <> svCurr Then '1' Else '0'
svPrev --> svCurr

Posted: Fri May 30, 2008 8:50 am
by rajngt
Also assign initial value for svPrev as null (or as you like) and update svUni as below

svUni --> if svPrev is null then '0' else (If svPrev <> svCurr Then '1' Else '0' )

Posted: Fri May 30, 2008 9:07 am
by tom
Hi rajngt,

Thanks for your reply.

Still 2 records are writing to the temp file.

Is there any other alternative way to acheive this?

Thanks
tom

Posted: Mon Jun 02, 2008 6:17 am
by rajngt
Hi Tom,

Since you have mentioned that the source is file and you are using logic to find the file size to kick off the job, my suggestion will be instead of creating one job to capture unique records to file and then checking the file size at the sequence level, try the below one:

in sequencer execute the below sample command:

cut -f<field number> -d'<delimiter>' <file name> | uniq |wc -l

If your file looks like:

name1,field21,01/23/2008
name2,field22,01/23/2008
name3,field23,01/23/2008
name4,field24,01/23/2008
name5,field25,01/23/2008
name5,field25,01/23/2008

Here the date column is 3rd one, delimiter is comma.
Hence you need to execute below command for this:

cut -f3 -d',' <file name> | uniq |wc -l

This has to return 1 as value otherwise you are having different value in date column. By using trigger option, you can decide whether to run the job or not.