WHEN N > length(C1) THEN 
substr(repeat(C2,(N length(C1)+length(C2))/(length(C2)+1 sign(length(C2)))),1,N
 length(C1)) || C1
   ELSE substr(C1,1,N)
 END
;
Results of LPAD look like Example A 12.
Example: A 12   Results of LPAD: CREATE FUNCTION and sample usage
SELECT char(lpad( ABCDE ,15, *. ),50) FROM SYSIBM.SYSDUMMY1;
                                                   
1                                                  
                                                   
*.*.*.*.*.ABCDE                                    
    1 record(s) selected.
                                                                          
SELECT char(lpad( ABCDE ,3, *. ),50) FROM SYSIBM.SYSDUMMY1;
                                                   
1                                                  
                                                   
ABC                                                
    1 record(s) selected.
                                                                          
SELECT char(lpad( ABCDE ,15,  ) ||  X ,50) FROM SYSIBM.SYSDUMMY1;
                                                   
1                                                  
                                                   
          ABCDEX                                   
    1 record(s) selected.
As RPAD allows LPAD a different number and data type for input arguments, 
Example A 13 shows LPAD without the third parameter.
 Appendix A. Sample code for user defined functions 
343






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

san diego web hosting

 

Our partners: PHP: Hypertext Preprocessor Cheap Web Hosting JSP Web Hosting Ontario Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Java Hosting Cheapest Hosting

Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved