In T-SQL, SPACE() function is used to add spaces to a string. For e.g.
@s = 'He' + space(5) + 'llo'
Output
He llo
So is there any function in PL/SQL that is equivalent to SPACE()?
Thank you.
You can use RPAD or LPAD functions
select 'He' || rpad(' ',5,' ') || 'llo'
from dual;
/
or in PL/SQL it would be:
declare
x varchar2(20);
begin
x:= 'He' || rpad(' ',5,' ') || 'llo';
end;
/
Jeffrey using rpad(' ',n,' ')
gives n+1
spaces
select RPAD('A',3,'-')||RPAD(' ',4,' ')||RPAD('B',5,'-') from dual
Output
A-- B----
After A--
and before B
, you will find 5 spaces instead of 4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With