Beruflich Dokumente
Kultur Dokumente
Demonstration 1
The second parameter (n) to lpad or rpad determines the
resulting length. If string is longer than n, string w ill be cut:
select
lpad('string with 25 characters', 20) lpad,
rpad('string with 25 characters', 20) rpad
from dual;
LPAD RPAD
-------------------- --------------------
string with 25 chara string with 25 chara
Demonstration 2
The literal string is lpadded to all lengths betw een 1 and 15.
The < show s w here the string is cut. As soon as the second
parameter becomes larger than the length of the first
parameter, lpadding occurs. The default is space, so spaces are
prepended to string:
begin
for i in 1 .. 15 loop
dbms_output.put_line(
lpad('string', i) || '<'
);
end loop;
www.QlikView.com
end;
Ads by Google /
s<
st<
str<
stri<
strin<
string<
string<
string<
string<
string<
string<
string<
string<
string<
string<
Demonstration 3
Same thing as in demonstration 2, but w ith rpad instead of
lpad:
begin
for i in 1 .. 15 loop
dbms_output.put_line(
rpad('string', i) || '<'
);
end loop;
end;
/
s<
st<
str<
stri<
strin<
string<
converted by Web2PDFConvert.com
string <
string <
string <
string <
string <
string <
string <
string <
string <
Demonstration 4
This demonstration is again similar to demonstration 2, but it
uses a non-default padding string (.,_).
begin
for i in 1 .. 15 loop
dbms_output.put_line(
lpad('string', i, '.,_')
);
end loop;
end;
/
s
st
str
stri
strin
string
.string
.,string
.,_string
.,_.string
.,_.,string
.,_.,_string
.,_.,_.string
.,_.,_.,string
.,_.,_.,_string
Demonstration 5
This demonstration show s how to pretty print some output.
apple - pear
grapefruit - mango
orange - banana
lemon - watermelon
select
rpad(col_1, 10) || ' - ' ||
lpad(col_2, 10)
from
rlpad_tbl;
apple - pear
grapefruit - mango
orange - banana
lemon - watermelon
converted by Web2PDFConvert.com
n) returns null.
converted by Web2PDFConvert.com