Hello,
I need to check if a column data is numeric or character.
the data I get can only come in 2 ways for that column number or varchar2 ( the datatype of the column is ofcourse varchar2 )
I thought I'll just check for the ascii range of the first character ( If it is not between Ascii(48) and Ascii(57)) then it is a character
Anyway that is what I'm trying to do but, I just can't find a way to simply get the ascii code for the first character.
Any suggestions or clarifications will be appreciated.
How to get the ascii code for the first character in a strin
Moderators: chulett, rschirm, roy
How to get the ascii code for the first character in a strin
Best Regards,
Lando
Lando
-
- Charter Member
- Posts: 166
- Joined: Wed Mar 16, 2005 6:52 am
- Location: Mumbai, India
Hi Lando,
Check out the NUM() Function in the BASIC guide(Pg 509), It does exactly what you need done.
If you want to check only the first character of the incoming string, the expression:
will give you the ASCII code of the first character (Watch out for leading spaces if any with this approach).
IHTH
Check out the NUM() Function in the BASIC guide(Pg 509), It does exactly what you need done.
If you want to check only the first character of the incoming string, the expression:
Code: Select all
SEQ(<in.col>[1,1])
IHTH
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Alpha(Left(InLink.TheString,1)) will return 1 if the first character is alphabetic, or 0 otherwise. Num(Left(InLink.TheString,1)) will return 1 if the first character is numeric or 0 otherwise. You can combine the logic with the Boolean operator Or to get the test expression you seek.
Code: Select all
Alpha(Left(InLink.TheString,1)) Or Num(Left(InLink.TheString,1))
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.