LPAD(x,a,y,n)
LPAD(x,a,y,n)
is a string function that inserts the character string y
(string
literal) at the start of the character
string x
(string specification)
as often as specified by the expression a
.
Only expressions that produce an alphanumeric value are permitted as string
specifications. The result of the expression a
must
be a positive integer.
Leading and subsequent blanks in the character string x
are
truncated.
The optional parameter n
(unsigned
integer) defines the maximal total length of the character string created. n
must
be greater than or equal to the total LENGTH(x)+a*LENGTH(y)
.
x, a, y, n |
Result of the LPAD(x,a,y,n) function |
|---|---|
|
The maximum length of the character string is the length of the
character string |
|
|
|
Error Messages |
Example
SELECT hno, LPAD('',TRUNC(price/10),'*',70) graph FROM room
WHERE price > 150 ORDER BY price DESC
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 price divided by 10.
HNO |
GRAPH |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|