This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
dev:sql:functions:rpad [2009/12/07 14:27] tdo created |
dev:sql:functions:rpad [2012/10/26 14:57] (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: $RPAD ====== | ||
| {{page>:sql_bar&nofooter&noeditbtn}} | {{page>:sql_bar&nofooter&noeditbtn}} | ||
| + | ====== Omnidex SQL Function: $RPAD ====== | ||
| ===== Description ===== | ===== Description ===== | ||
| - | The $RPAD function adds pad characters to the left of a character string up to the specified total length. | + | Pad the string on the right 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. |
| - | The return data type is C STRING of length specified in the return_length parameter + 1. | + | This function returns a STRING datatype. |
| ===== Syntax ===== | ===== Syntax ===== | ||
| - | $RPAD( <column_spec | 'string'> , return_length [ ,pad_character ] ) | ||
| - | == < column_spec, string > == | + | $RPAD( character_expression, num_characters [, pad_character] ) |
| - | Required. The string to be "padded". If the length of the string is longer than n, the 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. |
| - | Optional. pad 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 | + | == num_characters == |
| - | Dynamic Information Systems Corporation ##### | + | |
| + | Required. The number of characters to be returned from the function, with the right-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 since it is already padded with spaces. | ||
| + | |||
| + | <code> | ||
| + | > select $rpad(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}} | ||