if statement problem
Moderators: chulett, rschirm, roy
if statement problem
hi
i am having a weird problem in transformer stage:
i created a stage variable: svCoverTypeCode the value can be : 'HA', 'H', 'A' and in the output link's derivation, i create the following if statement
if (svCoverTypeCode = 'HA' or svCoverTypeCode = 'A') then 'Y'
else 'N'
however when the value of svCoverTypeCode value is 'HA' or 'A' the if statement SOMETIMES return 'N'
I am really confused, does anyone know why?
Thanks
Abyss
i am having a weird problem in transformer stage:
i created a stage variable: svCoverTypeCode the value can be : 'HA', 'H', 'A' and in the output link's derivation, i create the following if statement
if (svCoverTypeCode = 'HA' or svCoverTypeCode = 'A') then 'Y'
else 'N'
however when the value of svCoverTypeCode value is 'HA' or 'A' the if statement SOMETIMES return 'N'
I am really confused, does anyone know why?
Thanks
Abyss
Code: Select all
if (LkTfProdDetial.Hospital_ProductTypeID = 3 and LkTfProdDetial.Ancillary_ProductTypeID = 2) or
LkTfProdDetial.Hospital_ProductTypeID = 1 then
'HA'
else if (LkTfProdDetial.Hospital_ProductTypeID = 3) then
'H'
else if (LkTfProdDetial.Ancillary_ProductTypeID = 2) then
'A'
else
'Unknown'
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
What is the data type of the stage variable? If it's Char(3), for example, DataStage will pad to length with the characters defined by APT_STRING_PADCHAR environment variable. You might be better off using VarChar(3) as the stage variable data type.
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.
Tried running simple DS Job with below 2 Columns
Hospital_ProductTypeID,Ancillary_ProductTypeID
3,2
1,8
3,6
7,2
7,7
And it worked as expected.
"Hospital_ProductTypeID","Ancillary_ProductTypeID","svCoverTypeCode","indicator"
"1","8","HA","Y"
"7","2","A","Y"
"3","2","HA","Y"
"3","6","H","N"
"7","7","Unknown","N"
I am not sure if $APT_STRING_PAD_CHAR is applicable for Stage Variables?.
As mentioned, Can you check what's the default value for $APT_STRING_PAD_CHAR (I ran with 0x0 which is default in my case).
Also you mentioned sometimes, could you please clarify if it was working sometimes (Which case)?.
Hospital_ProductTypeID,Ancillary_ProductTypeID
3,2
1,8
3,6
7,2
7,7
And it worked as expected.
"Hospital_ProductTypeID","Ancillary_ProductTypeID","svCoverTypeCode","indicator"
"1","8","HA","Y"
"7","2","A","Y"
"3","2","HA","Y"
"3","6","H","N"
"7","7","Unknown","N"
I am not sure if $APT_STRING_PAD_CHAR is applicable for Stage Variables?.
As mentioned, Can you check what's the default value for $APT_STRING_PAD_CHAR (I ran with 0x0 which is default in my case).
Also you mentioned sometimes, could you please clarify if it was working sometimes (Which case)?.
Venkata Srini
-
- Premium Member
- Posts: 145
- Joined: Thu Oct 26, 2017 10:43 am
Hi all:
I think I find the problem:
i didn't put the full code out. the full code is like:
the else if statement made the difference:
LkTfProdDetial.Whics_Cover_Type has type varchar(10) and I went back to the very first job that load the data in, then figured out the database table that i load data from has type char(3), despite the table definition on database connector stage also set to varchar(10), the actual value hold inside Whics_Cover_Type field still have empty space at the end when load into DS jobs. stage variable recognise there is a char field in the derivation and return everything in char(3) type......
question: do you think $APT_STRING_PAD_CHAR will fix the problem?
I think I find the problem:
i didn't put the full code out. the full code is like:
Code: Select all
if IsNotNull(LkTfProdDetial.Hospital_ProductTypeID) and IsNotNull(LkTfProdDetial.Ancillary_ProductTypeID) then
if (LkTfProdDetial.Hospital_ProductTypeID = 3 and LkTfProdDetial.Ancillary_ProductTypeID = 2) or
LkTfProdDetial.Hospital_ProductTypeID = 1 then
'HA'
else if (LkTfProdDetial.Hospital_ProductTypeID = 3) then
'H'
else if (LkTfProdDetial.Ancillary_ProductTypeID = 2) then
'A'
else
'Unknown'
else if IsNotNull(LkTfProdDetial.Whics_Cover_Type) then
LkTfProdDetial.Whics_Cover_Type
else
'Unknown'
Code: Select all
else if IsNotNull(LkTfProdDetial.Whics_Cover_Type) then
LkTfProdDetial.Whics_Cover_Type
question: do you think $APT_STRING_PAD_CHAR will fix the problem?