Check whether string consists of alphanumeric characters
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 503
- Joined: Wed Jun 29, 2005 8:14 am
Check whether string consists of alphanumeric characters
I was searching the Help Guide and found out that we have the follwing function in Parallel Edition --
AlNum
Return whether the given string consists of alphanumeric characters
DO we have a equivalent in Server Edition??
AlNum
Return whether the given string consists of alphanumeric characters
DO we have a equivalent in Server Edition??
-
- Premium Member
- Posts: 503
- Joined: Wed Jun 29, 2005 8:14 am
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
There isn't a direct one. You could create a direct one.
Code: Select all
FUNCTION AlNum(TheString)
* Returns 1 (true) if all characters are alphanumeric, 0 (false) otherwise.
Ans = @TRUE
CharCount = Len(TheString)
For ch = 1 To CharCount
Character = TheString[ch,1]
If Character Matches "1A" : @VM : "1N"
Else
Ans = @FALSE
Exit ; * as soon as a non-alphanumeric character found exit loop
End
Next ch
RETURN(Ans)
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.
This is another way in which you can do it...........
Code: Select all
Input = TRIM(aNUMBERFIELD)
*********************************************************
*The function gets the non-numeric fields from the Input*
*********************************************************
Convert= Iconv(Input,"MD")
ConvStatus= Status()
*************************************************************************
* Output: 1 if there is error or warning in conversion *
* 0 if the conversion is successful *
*************************************************************************
Begin Case
Case (ConvStatus=1 or ConvStatus=2 or ConvStatus=3)
Output=1
Case ConvStatus=0
Output=0
End Case
Ans= Output
Ans= Output
Avishek Mukherjee
Data Integration Architect
Chicago, IL, USA.
Data Integration Architect
Chicago, IL, USA.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
ray.wurlod wrote:ALPHAnumeric was specified in the subject.
Sorry I pasted the wrong one............
Code: Select all
Input = VarCharField
**********************************************************
*The function gets the non-numeric fields from the Input*
**********************************************************
Charac= Iconv(Input,"MC/N")
***************************************************************
*The function counts the non-numeric fields in the result set*
***************************************************************
NumofCharac= Len(Charac)
Begin Case
Case (NumofCharac >0)
Output=1
Case (NumofCharac=0)
Output=0
End Case
Ans= Output
Arg1 = Input field(Varchar: Datatype)
Called by:
Transformer
Parameters:
Arg1 = Input field
Checks for non-numeric character in numeric field.
Return Values: 0 = If the Input Field does NOT have non-numeric character
1 = If the Input Field has non-numeric character
Avishek Mukherjee
Data Integration Architect
Chicago, IL, USA.
Data Integration Architect
Chicago, IL, USA.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: