LPAD(x,a,y,n) is a string function that inserts the character string y at the start of the character string x as often as specified by the parameter a. Leading and subsequent blanks in the character string x are truncated. The optional parameter n defines the maximum total length of the character string created.
The result of the parameter a must be a positive integer.
The optional parameter n must be greater than or equal to the total LENGTH(x)+a*LENGTH(y).
|
Result of the LPAD(x,a,y,n) function |
LPAD(x,a,y) |
The maximum length of the character string is the length of the character string x. |
x or a is the NULL value |
|
a is the special NULL value |
Error Message |
Example table: customer
Creating bar charts: LPAD inserts asterisks in front of the first parameter (in this case, a blank). This is done according to the number equal to account divided by 100.
SELECT name, account, LPAD(' ',TRUNC(account/100),'*',50) graph
FROM customer WHERE account > 0 ORDER BY account DESC
NAME |
ACCOUNT |
GRAPH |
DATASOFT |
4813.50 |
************************************************ |
TOOLware |
3770.50 |
************************************* |
Peters |
650.00 |
****** |
Brown |
440.00 |
**** |
Porter |
100.00 |
* |
See also: