Data Issue

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
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Data Issue

Post by samsuf2002 »

I have a column with apha, alphanumeric and numeric values, I want to pass only numeric values and want to make apha & aplhanumeric values empty.

I tried using

Code: Select all

if len(convert("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefhijklmnopqrstuvwxyz","",col)) = 0 then "" else col
but its not working for alphanumeric values.

Then I tried

Code: Select all

If index("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefhijklmnopqrstuvwxyz",col,1) > 0 then "" else col
this one is making numeric values empty.


Can any help me here and let me know if I am doin anything wrong in the above code.

Thanks in advance.
hi sam here
bart12872
Participant
Posts: 82
Joined: Fri Jan 19, 2007 5:38 pm

Post by bart12872 »

you have the Num function. It returns 1 if it's a number.
jdmiceli
Premium Member
Premium Member
Posts: 309
Joined: Wed Feb 22, 2006 10:03 am
Location: Urbandale, IA

Post by jdmiceli »

Well, this is kind of hokey, but should work (I'm pulling this off the top of my head and have not tested it - so make sure you do that):

Create a routine something like this:

Code: Select all

Function RemoveLetters(Arg1)

Text = Arg1
Ans = ""

LC = LEN(Text)

For i=1 to LC
   Letter = Text[i,1]
   Tst = Num(Letter)
   if Tst = 0
   then
      Ans := Letter
   end
Next i

RETURN (Ans)
This isn't very elegant and I'm sure someone with more experience than me with coding could do it better, but I think it will work.

Good luck!
Bestest!

John Miceli
System Specialist, MCP, MCDBA
Berkley Technology Services


"Good Morning. This is God. I will be handling all your problems today. I will not need your help. So have a great day!"
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

I used Num() and it gave me the result I want.

thanks bart12872 and jdmiceli.
hi sam here
Post Reply