Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi.
I have a T-sql subscript statement as:
substring('StrA',1,charindex(' ','StrA')-1)
How do I make that work in Talend tMap component?
Thank you for your suggestions.
Hi,
you have to connect an input flow to tMap, then you drag your field onto output flow field.
In output field you can use the follow code:
StringHandling.LEFT(row1.field1, StringHandling.INDEX(row1.field1," "));
where row1.field1 is the field to process as your string 'StrA'.
In attachments you can see a simulation and the output in log (see tFixedInput as a SQL Server input component, field1 as a field of SQL Server record).
I hope I understood well and this is useful for you.
Hi,
you have to connect an input flow to tMap, then you drag your field onto output flow field.
In output field you can use the follow code:
StringHandling.LEFT(row1.field1, StringHandling.INDEX(row1.field1," "));
where row1.field1 is the field to process as your string 'StrA'.
In attachments you can see a simulation and the output in log (see tFixedInput as a SQL Server input component, field1 as a field of SQL Server record).
I hope I understood well and this is useful for you.
This code will work with also string without spaces:
StringHandling.INDEX(row1.field1," ") > 0 ?
StringHandling.LEFT(row1.field1, StringHandling.INDEX(row1.field1," "))
:
""