String

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
albasir
Participant
Posts: 18
Joined: Fri Nov 09, 2007 11:08 am

String

Post by albasir »

Hi all,

My input:

AAAAA = 10000 OR AAAAA = 10000 AND BBBBB = 20000 AND CCCCC = 20000 OR CCCCC=20000 AND DDDDD=30000

Output should be:

(AAAAA = 10000 OR AAAAA = 10000) AND (BBBBB = 20000) AND (CCCCC = 20000 OR CCCCC=20000) AND (DDDDD=30000)

basically all the ORs should be grouped and put into braces from the input.
PLease suggest me to arrive at the desired result.

Thanks,
-M
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Can you perhaps explain exactly which stage and what columns you have? Are AAAAA, BBBBB, CCCCC column names?
albasir
Participant
Posts: 18
Joined: Fri Nov 09, 2007 11:08 am

Post by albasir »

ArndW wrote:Can you perhaps explain exactly which stage and what columns you have? Are AAAAA, BBBBB, CCCCC column names? ...

These are not column names... AAAAA, BBBBB are the values as part my test input data stream...i am trying to build a dynamic WHERE clause in transformer stage...this WHERE clause will be used later to query a Oracle stage...

Let me now if you need furthe info

Thanks
-M
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

This is more along the lines of a buildop in PX. If you can use server jobs then you could do some string manipulation in a loop, I'd use INDEX(In.Col,' OR ') to find the "or" statement, then go back 3 words and prepend a '(' and then go forward 3 words and put in a ')'. That approach is straightforward, but won't work if you have 2 or more ORs in a row.
trammohan
Participant
Posts: 47
Joined: Thu Nov 13, 2003 12:47 pm

Post by trammohan »

Can be implemented in a C routine and call it from the transformer..
trammohan
Participant
Posts: 47
Joined: Thu Nov 13, 2003 12:47 pm

Post by trammohan »

Can be implemented in a C routine and call it from the transformer..
albasir
Participant
Posts: 18
Joined: Fri Nov 09, 2007 11:08 am

Post by albasir »

ArndW wrote:This is more along the lines of a buildop in PX. If you can use server jobs then you could do some string manipulation in a loop, I'd use INDEX(In.Col,' OR ') to find the "or" statement, then go back ...
Yes...Index function is returning the position of my "AND" Keywords...
Please give me some hint how to put these into a loop to find position of all the AND keywords in a particulare record...

My idea is to replace all the' AND ' with ') AND (' with some more additional adjustments. In this way i can brackets for all my OR keywords.
But i could not figure out CHANGE function or EREPLACE function in the transformer.

Is there a more elegant way to acheive this!!!
V'TH LUV
trammohan
Participant
Posts: 47
Joined: Thu Nov 13, 2003 12:47 pm

Post by trammohan »

Albasir,

There is one External Filter stage in PX... use that stage to replace string with the following sed command

sed 's/AND/\) AND \(/g'

hope this helps...
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The "EREPLACE" function doesn't exist in the PX transform stage, so the external sed function, perhaps in a wrapper, will work but might be just as slow as using a BASIC transform stage. In that case, it would be better to evaluate writing this job in Server.
albasir
Participant
Posts: 18
Joined: Fri Nov 09, 2007 11:08 am

Post by albasir »

ArndW wrote:The "EREPLACE" function doesn't exist in the PX transform stage, so the external sed function, perhaps in a wrapper, will work but might be just as slow as using a BASIC transform stage. In that case, ...
Hi Arndw,

your suggesstions are not appearing till the end...Some premium content icon comes in between so i could not get your suggesstions entirely. IS that a way to get rid of this??
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

albasir wrote:...Some premium content icon comes in between so i could not get your suggesstions entirely. IS that a way to get rid of this??
Yeah! Get a premium membership.
gateleys
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

That particular post only had a couple more words to it, but it is certainly worthwhile getting a premium membership.
albasir
Participant
Posts: 18
Joined: Fri Nov 09, 2007 11:08 am

Post by albasir »

ArndW wrote:That particular post only had a couple more words to it, but it is certainly worthwhile getting a premium membership.
Sure...Thanks for your help :D
Post Reply