This shows you the differences between two versions of the page.
dev:sql:functions:lpad [2010/07/09 03:35] els |
dev:sql:functions:lpad [2016/06/28 22:38] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{page>:top_add&nofooter&noeditbtn}} | ||
- | {{page>:sql_bar&nofooter&noeditbtn}} | ||
- | ====== Omnidex SQL Function: $LPAD ====== | ||
- | ===== Description ===== | ||
- | 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 C STRING datatype. | ||
- | |||
- | ===== Syntax ===== | ||
- | |||
- | $LPAD( character_expression, num_characters [, pad_character] ) | ||
- | |||
- | == character_expression == | ||
- | |||
- | 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. | ||
- | |||
- | == num_characters == | ||
- | |||
- | 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> | ||
- | |||
- | {{page>:bottom_add&nofooter&noeditbtn}} |