Page 1 of 1

Stop the job after 1 read row

Posted: Wed Aug 23, 2006 11:25 am
by wahil
Hi to all,

I have the job below:

HASH ---> TRANSFORM ---> SEQFILE

This hash have millions of rows, but i need stop the job after read the first only. In transform stage i put @INROWNUM in constraint, but the dstage read all rows in hash...It's take 6hours to finish...
I try with @OUTRONNUM too, but the result as the same.

Any idea?

Thanks a lot!

Posted: Wed Aug 23, 2006 11:51 am
by thumsup9
Use a Before Job Routine with Head or Tail to get the number of rows you want.

Posted: Wed Aug 23, 2006 12:07 pm
by DSguru2B
Or you can specifiy the limit as 1 row in the director. You can also specify it in command line.

Posted: Wed Aug 23, 2006 12:20 pm
by wahil
DSGuru,

Excuse-me but i have other stages before the hash table. I don't write about this to be more easy...

Posted: Wed Aug 23, 2006 12:59 pm
by DSguru2B
Split the job. Simple as that. Aborting the job or even stopping the job before its true end doesnt always comeout with good results, IMHO. Thats why i advised to finish the job by limiting the execution to one row.

Re: Stop the job after 1 read row

Posted: Wed Aug 23, 2006 1:05 pm
by gateleys
Can you post the exact constraint that you put in your Xfmr stage?

gateleys

Posted: Wed Aug 23, 2006 2:15 pm
by kcbland
HASH-->XFM--->SEQ means ALL rows output from the HASHed file to get to the XFM to be thrown away. Split the jobs if your logic is messy.


As for the first row out of the hashed file, how do you qualify the first row? By order written into the file? Sorry, hashed data is randomized throughout the file. There is no "first" row concept.

If you use the UV/ODBC (Universe) stage, you could use SQL to limit the rows via a WHERE clause, or if your hashed file is created in the project (if not use SETFILE, search the forum) then you can use the WITH @ID=xxxx where xxxx is the single key value for the row you want output.

Posted: Thu Aug 24, 2006 12:51 am
by ray.wurlod
The Hashed File stage has a Selection tab does it not? An appropriate selection phrase phrase to put in here is

Code: Select all

FIRST 1
If that builds a WITH phrase that causes a syntax error, trick DataStage into generating a legal phrase, for example

Code: Select all

1 = 1 FIRST 1

Posted: Thu Aug 24, 2006 1:10 am
by pigpen
At the moment of creating the hash file, create another sequential file with the first record and use it afterwards.