I am trying to right-align the output of some PL/SQL code, but dbms_output.put_line is trimming the leading whitespace from my strings. How do I make it stop? Or is there a better way to output strings with leading whitespace?
dbms_output.put_line(lpad('string', 30, ' '));
outputs:
string
instead of:
string
Rules and Limits The maximum line size is 32767 bytes. The default buffer size is 20000 bytes. The minimum size is 2000 bytes and the maximum is unlimited.
Every extra line of code decreases the performance of code. After all, it is an extra instruction to be executed, which at least consumes some CPU. So yes, dbms_output. put_line decreases the performance.
When using the dbms output. put line command, either the server output is not enabled or there is a bug in the code. Until executing the PL/SQL command, make sure that the server output is turned on. If there is a code error, it should be fixed.
The problem is not with dbms_output
but with SQL*Plus.
Use
SET SERVEROUTPUT ON FORMAT WRAPPED
or
SET SERVEROUTPUT ON FORMAT TRUNCATED
to preserve the spaces.
From the documentation (PDF) of SET SERVEROUT WORD_WRAPPED
(which is the standard):
SQL*Plus left justifies each line, skipping all leading whitespace.
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