Page 1 of 1

DataStage not identifying Varchar

Posted: Wed Dec 31, 2008 11:05 am
by sagar deshmukh
Hi i have a rounine as given below




DEFFUN ConvDateCYYDDDtoYYYYMMDD(A) Calling "DSU.ConvDateCYYDDDtoYYYYMMDD"
DEFFUN ConvDateToYYYYMMDD(A) Calling "DSU.ConvDateToYYYYMMDD"
DEFFUN ConvtSignOverPunch(A) Calling "DSU.ConvtSignOverPunch"

******
*Init*
******

RECORD_LENGTH = 100
REJECT = "REJECT-"
CODE = 0
Ans = ""
IC4X = Arg1

*********
*Process*
*********
If Len(IC4X) < RECORD_LENGTH Or Len(IC4X) > RECORD_LENGTH Then
GoTo Reject
End Else
GoTo ProcessIC4X
End

ProcessIC4X:
*** Get Country_Code - 1 ***
Country_Code = Trim(IC4X[1,3])
If (IsNull(Country_Code) Or (Country_Code <> "US" And Country_Code <> "GU" And Country_Code <> "CA")) Then
CODE = 1
GoTo Reject
End
Ans = Ans:Country_Code:"|"

*** Get Item_Nbr - 2 ***
Item_Nbr = Trim(IC4X[26,6])
If Num(Item_Nbr) = @FALSE Then
CODE = 2
GoTo Reject
End
Ans = Ans:Item_Nbr:"|"

*** Get Loc_Nbr - 3 ***
Loc_Nbr = Trim(IC4X[5,5])
If Num(Loc_Nbr) = @FALSE Then
CODE = 3
GoTo Reject
End
Ans = Ans:Loc_Nbr:"|"



Reject:
Return ("<":REJECT:CODE:">")


here for Loc_Nbr - 3 if we give value as 'e4545' it identifies as varchar and aborts....but if we give 45e45 then it doesnt identify it as varchar....
can you tell me whats the problem......



bt same piece of code for Get Item_Nbr - 2 is working fine,....

Posted: Wed Dec 31, 2008 3:21 pm
by ArndW
Write a short Basic routine and return the value of "NUM('45e45')". Is that returning a 1 or a 0?

Posted: Wed Dec 31, 2008 7:16 pm
by ray.wurlod
It returns 1, since 45e45 is numeric (provided EXACTNUMERIC is sufficiently large).

You don't even need a routine. Use EVAL in a query.

Code: Select all

SELECT EVAL "NUM('45e45')" FROM VOC FIRST 1;

Posted: Wed Dec 31, 2008 11:19 pm
by ArndW
Ray - you ruined the suspense I was trying to build up ;)

Posted: Thu Jan 01, 2009 8:57 am
by chulett
Only in this forum. :wink:

viewtopic.php?t=124402