Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: DBMS_OUTPUT.PUT_LINE question
Turdcutter wrote:
>
> How do you get this function to insert leading spaces?
>
> DBMS_OUTPUT.PUT_LINE(' '|| var1)
>
> gives no leading spaces
>
> ?????
>
> also,,,
>
> how could you do a carriage return with this function
> DBMS_OUTPUT.PUT_LINE('') < ---- doesn't seen to work
>
> thank you
If you are working in UNIX then the solution is a no-brainer.
Simple prepend a character like '.' to the front of each line. when sqlplus exits and the results are dumped out send the output to sed via a pipe and use sed to strip off all of the initial '.' characters.
#!/bin/ksh
sqlplus -s scott/tiger <<-sqlEOF | sed 's/^.//' >/dev/stdout
set serveroutput on;
set feedback off;
set pages 0;
whenever sqlerror exit failure;
declare
begin
dbms_output.enable(1000000);
dbms_output.put_line('.'||' hello world');
end;
.
/
exit success;
sqlEOF
if [[ $? -ne 0 ]];then
print -us "Fatal error from sqlplus";
exit 1;
fi
exit 0;
Received on Tue Jun 06 2000 - 00:00:00 CDT