I have a procedure where a
FOR rec IN c1
DBMS_OUTPUT.PUT_LINE (rec.branchno || CHR(9) || rec.street || CHR(9)
|| rec.city || CHR(9) || rec.postcode);
B003 163 Main St. Glasgow G11 9QX
B007 16 Argyll St. Aberdeen AB2 3SU
B005 22 Deer Rd. London SW1 4EH
IF STRLEN(rec.city) < 8
PUT ( CHR(9) || CHR(9) )
PUT ( CHR(9) )
DBMS_OUTPUT to produce formatted reports is probably the wrong approach.
SQL*Plus is pretty good at producing fixed-width text reports. It's not obvious whether the stored procedure is adding some value (in which case you could have it return a
sys_refcursor to SQL*Plus) or whether it would just make more sense to put the SQL statement in a SQL*Plus script along with appropriate
column format commands to control the output of the data. Any number of other tools (SQL Developer, for example) support enough SQL*Plus commands to be able to generate a simple fixed width report as well.