Many thanks for visiting my Blog..!!Please share this blog using below share buttons and leave your Comments/Feedback/Appreciations on Tab: Feedback
Share This Blog..!!

Transformer STRING FUNCTIONS in Datastage



Transformer STRING FUNCTIONS in Datastage: DK®


Please go through this post to understand the mostly used transformer sting functions in details. Here you can see the transformer string functions with examples.DK®

**1. Trim: DK®
Trim is used to reduce additional space, tab or any unwanted occurrence of a character to one but it strictly removes the leading and trialing characters. This has the provision of additional argument to get desire result. We will see those with examples.

There are multiple options to trim the data:
Input Data => “  Devendra    Kumar  
Functions used:
Trim(“  Devendra    Kumar   “)          O/P  : “Devendra Kumar“
FTrim (“  Devendra    Kumar   “)       O/P  : “Devendra    Kumar  
Btrim (“  Devendra    Kumar   “)        O/P  : “  Devendra    Kumar“
Trim (“  Devendra    Kumar   “,’ ‘,’A’)   O/P  : “DevendraKumar“


**2. AlNum: DK®
This functions check whether given string contains only and only alphanumeric
characters. I.e. if string contains any special characters it returns -1(False).
Example:If given string is ‘John$007’ then
AlNum (link_name.string_name) = -1 (false) as it contains special character ‘$’.
If given string is ‘John007’ then
AlNum (link_name.string_name) = 1 (True) as it contains only alphanumeric characters.

Allnum(“12345”)       output-1
Allnum(“abcd”)          output-1
Allnum(“ab125”)       output-1
Allnum(“@a12345”)             output-0
Allnum(“@a1 2345”) output-0

**3. Alpha: DK®
This function checks whether thegiven string contains only alphabetic characters. I.e. from ‘Aa’ to ‘Zz’.
Example:If given string is ‘John007’ then
Alpha (link_name.string_name) = 0 (False)
If given string is ‘John Margaret’ then
Alpha (link_name.string_name) = 1 (True)

Alpha (“abcd”)           output-1
Alpha (“12345”)        output-0
Alpha (“ab125”)        output-0
Alpha (“@a12345”) output-0
Alpha (“@a1 2345”)             output-0


**4. CompactWhiteSpace: DK® 
It just reduce the unnecessary white spaces between two words to single white space i.e. if given string contains ‘I    am   Devendra’ then this function will give output  I am Devendra’.


*5. Compare:DK®
   Compares String1 & String2,if String1 is greater than String2 it will result 1

   If String1 is less than String2,then it will result 1.
            If both the strings are equal then it will result 0.
            To compare String1 with String2, we give Justification:L
           To compare String2 with String1,we give Justification:R

     Ex:       Compare(“abcd”,”abc”,”L”)---output-1
                  Compare(“abcd”,”abc”,”R”)---output-0
                  Compare(“abc”,”Abc”)---output-1     Default Justification-L
                  Compare(“abc”,”abcd”)---output  -1

**6. Convert: DK®
 This function provides facility to change the content of string or whole string as a replacement. Example: If given string is ‘devendra’ and requirement is to change characters ‘dev’ to ‘DEV’ then use we can use this function as follows
Convert(‘dev’,’DEV’, link_name)

Output => “DEVendra


**7. Count: DK®
 It counts the number of times the given substring occurs in the string.
Example: If the given string is ‘We are going really, really fast’. This function will give count 2 for substring ‘really’.
Count(link_name,’really’) =2.



**8. Dcount: DK®
 This functions returnscount of delimited fields in the string.
Example: If the given string is ‘john, ron, harry, rowling’ then this function will give count 3 for delimiter ‘,’ as shown below.
Dcount(link_name,’,’) =3

     Ex:  DCount(“DE-VE-ND-RA”,”_”)-------o/p:4
             DCount(“DE,V,EN,D,RA”,”,”)-------o/p:5


**9. Downcase:DK®
 This function is used change all the upper case letters in the string to lower case.
Example: If the given string contains “DEvenDra” then this function will give
Downcase(link_name)=”devendra”




**10. Dquote: DK® 
It puts the given string in double quotes.
Example: If given string is I am Devendra, then this function returns
Dquote(link_name) =”I am Devendra”




**11. Field: DK® 
This is important function which deals with the delimiter fields as it returns one or more substring depending upon the specified delimiters in a given string.
Example: Suppose given string is “adc89@nxcbs@nahs@ncn@xcz” where ‘@’ will be treated as a delimiter then
Field (link_name,’@’,1) = adc89
Field (link_name,’@’,1,3) = adc89@nxcbs@nahs
Field (link_name,’@’,2,2) = nxcbs@nahs



**12. Left: DK® 
This function returns the leftmost ‘n’ characters from input string.
 Example: Suppose given string is “DEV90@nxcbs@nahs@ncn@xcz” then
 Left (link_name, 3) = DEV



**13. Len: DK® 
It returns the length of the given string.
 Example: if given string is “Devendra” then
 Len (link_name) = 8




**14. Right:DK® 
This function returns the rightmost ‘n’ characters of string.
 Example: Suppose given string is “Devendra@nxcbs@nahs@ncn@DEV” then
 Right (link_name,3) = “DEV”

No comments:

Post a Comment

disqus