Phone Number Format

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Phone Number Format

Post by DS_MJ »

Hello:

Can somebody help with the below query. It works fine.
BUT shows ( ) - EXT if Null

I need it to NOT SHOW ( ) - EXT if these fields are blank or null



Code: Select all

IF               Isnull(Lnk_Cpy_Ds.Ph1) OR (Lnk_Cpy_Ds.Ph1) = '000'
          AND Isnull(Lnk_Cpy_Ds.Ph2) OR (Lnk_Cpy_Ds.Ph2) = '000'
          AND Isnull(Lnk_Cpy_Ds.Ph3) OR (Lnk_Cpy_Ds.Ph3) = '000'
          AND Isnull(Lnk_Cpy_Ds.WRKEXT) OR (Lnk_Cpy_Ds.WRKEXT) = '000'  
THEN ''  

    ELSE IF   IsNotnull(Lnk_Cpy_Ds.Ph1) OR (Lnk_Cpy_Ds.Ph1) <> '000'
          AND IsNotnull(Lnk_Cpy_Ds.Ph2) OR (Lnk_Cpy_Ds.Ph2) <> '000'
          AND IsNotnull(Lnk_Cpy_Ds.Ph3) OR (Lnk_Cpy_Ds.Ph3) <> '000'
          AND IsNotnull(Lnk_Cpy_Ds.WRKEXT) OR (Lnk_Cpy_Ds.WRKEXT) <> '000'  
     THEN '(' : Trim(Lnk_Cpy_Ds.Ph1): ')' : Trim(Lnk_Cpy_Ds.Ph2) : '-' : Trim(Lnk_Cpy_Ds.Ph3) :' EXT. ' : Trim(Lnk_Cpy_Ds.WRKEXT)

		 ELSE IF  IsNotnull(Lnk_Cpy_Ds.Ph1) OR (Lnk_Cpy_Ds.Ph1) <> '000'
			  AND IsNotnull(Lnk_Cpy_Ds.Ph2) OR (Lnk_Cpy_Ds.Ph2) <> '000'
			  AND IsNotnull(Lnk_Cpy_Ds.Ph3) OR (Lnk_Cpy_Ds.Ph3) <> '000'
			  AND Isnull(Lnk_Cpy_Ds.WRKEXT) OR (Lnk_Cpy_Ds.WRKEXT) = '000'  

		 THEN '(' : Trim(Lnk_Cpy_Ds.Ph1): ') ' : Trim(Lnk_Cpy_Ds.Ph2) : '-' : Trim(Lnk_Cpy_Ds.Ph3)

			 ELSE IF     IsNull(Lnk_Cpy_Ds.Ph1) OR (Lnk_Cpy_Ds.Ph1) = '000'
				  AND IsNotnull(Lnk_Cpy_Ds.Ph2) OR (Lnk_Cpy_Ds.Ph2) <> '000'
				  AND IsNotnull(Lnk_Cpy_Ds.Ph3) OR (Lnk_Cpy_Ds.Ph3) <> '000'
			 THEN Trim(Lnk_Cpy_Ds.Ph2) : '-' : Trim(Lnk_Cpy_Ds.Ph3)

				ELSE IF       IsNull(Lnk_Cpy_Ds.Ph1)    OR (Lnk_Cpy_Ds.Ph1) = '000'
						  AND IsNull(Lnk_Cpy_Ds.Ph2)    OR (Lnk_Cpy_Ds.Ph2) = '000'
						  AND IsNotnull(Lnk_Cpy_Ds.Ph3) OR (Lnk_Cpy_Ds.Ph3) <> '000'
					 THEN Trim(Lnk_Cpy_Ds.Ph3)
						  ELSE
                              'INVALID PHONE NUMBER'
Thanks
Thanks in advance,
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Build the pieces with separate expressions concatenated together:

Code: Select all

Isnull(Lnk_Cpy_Ds.Ph1) OR (Lnk_Cpy_Ds.Ph1) = '000' Then '' Else '(' : Trim(Lnk_Cpy_Ds.Ph1): ') ' : ( handle phone 2) : ( handle phone 3 )
-craig

"You can never have too many knives" -- Logan Nine Fingers
DS_MJ
Participant
Posts: 157
Joined: Wed Feb 02, 2005 10:00 am

Post by DS_MJ »

chulett wrote:Build the pieces with separate expressions concatenated together:

Code: Select all

Isnull(Lnk_Cpy_Ds.Ph1) OR (Lnk_Cpy_Ds.Ph1) = '000' Then '' Else '(' : Trim(Lnk_Cpy_Ds.Ph1) ...[/quote]

Thank you.
I will try it.
Thanks in advance,
Post Reply