Page 1 of 1

check column sorted

Posted: Wed Feb 07, 2007 1:43 am
by PeterPol
Hello,

I have an ODBC file for which I want to check and report if it is sorted on a certain column. How to do this?

Peter

Posted: Wed Feb 07, 2007 2:32 am
by ray.wurlod
Use stage variables in a Transformer stage to compare each row with the previous one in that column. If the direction of difference changes, then the answer is NO.

Posted: Wed Feb 07, 2007 5:20 am
by kumar_s
Just curious, why do you need to use ODBC for file? Is it not flat file?

Posted: Wed Feb 07, 2007 5:35 am
by PeterPol
hello,

No, the files I have to process are all FoxPro DBf files for which I need ODBC (stage).

Peter

Posted: Wed Feb 07, 2007 5:37 am
by kumar_s
Fine. Option suggested by Ray would be more simple, when compare to others.

Posted: Fri Feb 09, 2007 7:14 am
by PeterPol
Hello,

The suggestion of ray works fine.

However, I wondered if it is possible to quit the transformer immediately if the direction of difference has changed? How?

Thanks,
Peter

Posted: Fri Feb 09, 2007 7:40 am
by DSguru2B
Well I highly doubt you can quit the execution of just the transformer, what you could do is as soon as there is a direction change, send it down a second link with its property set to 'Abort after 1 row'.

Posted: Fri Feb 09, 2007 3:11 pm
by ray.wurlod
The Compare stage reports direction of difference between two inputs. To use this you'd need to generate a sequential key on two copies of the sorted Data Set (Column Generator stages) with an offset of 1 between the two copies, then compare based on matching that key.