Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have a requirement to transform the data from source to target. below is the requirement.
In T_USER_DIM the column will have 3 possible values: value null when st_user.external_employee=1. value ‘y' when st_user.external_employee=0 and the st_user.external_id is found in st_us_persons. value 'n’ when st_user.external_employee=0 and the st_user.external_id is not found in st_us_persons.
i have written expression like this in tmap, but it is not working.
(ST_USER.external_employee=="1")?"Null" : ( ( ST_USER.external_employee == "0")?"Y":"N"
Hi,
To check if st_user.external_id exists in st_us_person you will need to join on that table. You can then check if the external_id is null or not.
If the data type of the column st_user.external_employee is an integer, there is no need to surround 1 or 0 with quotes in the conditional statements. If it is a String, you have to use st_user.external_employee.equals("1") instead.
Try this and see if it works:
st_user.external_employee == 1 ? null: st_user.external_employee == 0 && st_us_persons.external_id != null ? "Y": st_user.external_employee == 0 && st_us_persons.external_id == null ? "N" : "X"
Hi @plID,
Thank you for your response,i have a join between these 2 tables and the data type of the column st_user.external_employee is Varchar. i have one more question, do we need to enclose the statements in braces or simply adding the condition in the expression editor will work.
Both works. Make sure that you are using correct braces in multiple if conditions.
my source column is string datatype and my target is character, how to fix this
Hi,
To check whether one String is equal to another you cannot use the operator "==". Instead you should use st_user.external_employee.equals("1"). To convert a String into a char you can use the mystring.charAt(0) method. Make sure to check if the variable is null or not first as you cannot call this method on a null value.
Taken together, try to create a variable in the tMap to do the multiple conditions and then convert to char in the expression field of the output mapping (see below).
Hi @plID ,
Thank you for your response, i have made changes you mentioned, but still i'm getting this erroranges like you