For those who are familiar with TransactSQL (SQL Server/Sybase), there is this function named SPACE(n). It generates n number of spaces when called. Unfortunately, it has no direct counterpart command in Oracle PL/SQL. However, there’s an alternative and it work just fine. Here’s the sample.

SELECT '->|' || RPAD(' ',5,' ') || '|<-' spacer FROM DUAL

I used this in one my of my recursive functions that generates XML. For easier reading of the output in a normal text editor, I needed to indent the lines. Here's the specific code where I used this technique.

l_curr_lvl := (p_lvl + 1)*3;
l_indent := RPAD(' ',l_curr_lvl,' ');

Comments are closed.

Post Navigation