Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
dev:sql:functions:lpad [2009/12/07 14:26]
tdo
dev:sql:functions:lpad [2010/07/08 20:58]
els
Line 1: Line 1:
 {{page>:​top_add&​nofooter&​noeditbtn}} {{page>:​top_add&​nofooter&​noeditbtn}}
-<​html><​div align="​center"><​span style="​color:​red">​DRAFT</​span></​div></​html>​ 
-====== Omnidex SQL Function: $LPAD ====== 
 {{page>:​sql_bar&​nofooter&​noeditbtn}} {{page>:​sql_bar&​nofooter&​noeditbtn}}
 +====== Omnidex SQL Function: $LPAD ======
 ===== Description ===== ===== Description =====
-The $LPAD function adds pad characters to the left of a character string ​up to the specified total length.+Pad the string on the left with spaces or the named character.  If the string ​is already padded, as happens with a CHARACTER datatype, ​the string must first be trimmed using the TRIM function  
 +===== Syntax =====
  
-The return data type is C STRING of length specified in the return_length parameter + 1.+  $LPAD( character_expression,​ num_characters [, pad_character] )
  
-===== Syntax ===== +== character_expression ​== 
-  $LPAD( <​column_spec | '​string'>​ , return_length [ ,​pad_character ] )+
  
-== < column_spec,​ string > == +Required. ​ Any expression that returns a character-class datatype ​Examples ​of expressions are columnsconcatenations ​of columns, literal strings and functions ​that return a character datatype 
-Required. ​The string to be "​padded"​If the length ​of the string is longer than nthe portion ​of the string ​that fits into n is returned.+
  
-== return_length ​== +== num_characters ​== 
-Required. n is the total length of the return value ( 0 < n <= 255)+
  
-== pad_character == +Required The number of characters ​to be returned from the function, with the left-most characters padded with spaces or the named character.
-Optionalpad evaluates ​to a single character. The default is the space character. +
-===== Example ===== +
-==== Example 1 ==== +
-<code SQL> +
-SELECT  +
-$LPAD(COMPANY,​ 45, '​*'​),​  +
-$RPAD(COMPANY,​ 45, '#'​)  +
-FROM CUSTOMERS  +
-WHERE COMPANY='​SYSTEMS'​+
  
-*****Dynamic Information Systems Corporation +== pad_character ==  
-Dynamic Information Systems Corporation #####+ 
 +Optional. ​ The character to be used to pad the string. ​ If this parameter is omitted, then a space is used as the pad character. 
 + 
 +===== Examples ===== 
 +==== Example: Column ==== 
 + 
 +//In this example, the name must first be trimmed and since it is already padded with spaces.// 
 + 
 +<​code>​ 
 +> SELECT $lpad(trim(name),​ 40, '​.'​) nme FROM individuals;​ 
 + 
 +NME 
 +---------------------------------------- 
 +..........................MS. MARY LEWIS 
 +...................MRS. ALICE R TOLLIVER 
 +...................MR. SIDNEY K TOLLIVER 
 +.................MRS. JENNIFER J HOPKINS 
 +.....................MR. CHARLIE HOPKINS 
 +.......................MS. KIMBERLY BLUE 
 +.........................KATHLEEN TUCKER
 </​code>​ </​code>​
 +
 {{page>:​bottom_add&​nofooter&​noeditbtn}} {{page>:​bottom_add&​nofooter&​noeditbtn}}
 
Back to top
dev/sql/functions/lpad.txt · Last modified: 2016/06/28 22:38 (external edit)