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
dev:sql:functions:lpad [2009/12/07 14:25]
tdo
dev:sql:functions:lpad [2016/06/28 22:38] (current)
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. ​  
 + 
 +This function returns a STRING datatype.
  
-The return data type is C STRING of length specified in the n parameter + 1. 
 ===== Syntax ===== ===== Syntax =====
-  $LPAD( <​column_spec | '​string'>​ , return_length [ ,​pad_character ] ) 
  
-== < column_specstring > == +  $LPAD( character_expressionnum_characters [pad_character] )
-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 ​== +== character_expression ​== 
-Required. n is the total length of the return value ( 0 < n <= 255)+
  
-== pad_character == +Required Any expression that returns ​a character-class datatype ​Examples of expressions are columns, concatenations of columns, literal strings and functions that return a character ​datatype 
-Optionalpad evaluates to 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 +== num_characters ==  
-Dynamic Information Systems Corporation #####+ 
 +Required. ​ The number of characters to be returned from the function, with the left-most characters padded with spaces or the named character. 
 + 
 +== pad_character ==  
 + 
 +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>​
 +====== Additional Resources ======
 +
 +See also:
 +{{page>​dev:​sql:​functions:​see_also_string&​nofooter&​noeditbtn&​noheader}}
 +
 +
 {{page>:​bottom_add&​nofooter&​noeditbtn}} {{page>:​bottom_add&​nofooter&​noeditbtn}}
 
Back to top
dev/sql/functions/lpad.1260195945.txt.gz · Last modified: 2016/06/28 22:38 (external edit)