13 replies
by fofa
by jim
This is a way to send the output to directly to the printer depending on the operating system and version of Oracle you are using. Our DBA at work uses the example below to send a list of tables to the printer. Hope it helps.
SPOOL TABLIST.LST
REM *****************************************************************
REM Prints Report Showing tables available
REM *****************************************************************
SET PAGESIZE 71 LINESIZE 98 VERIFY OFF
SET PAGESIZE 71
CLEAR COL
CLEAR BREAK
COL TODAY NEW_VALUE CURRENT_DATE NOPRINT
COL TIME NEW_VALUE CURRENT_TIME NOPRINT
TTITLE LEFT "DATE: " CURRENT_DATE CENTER 'ARIZONA DEPARTMENT OF HEALTH SERVICES' COL 87 "PAGE: " FORMAT 999 -
SQL.PNO SKIP 1 LEFT "TIME: " CURRENT_TIME CENTER 'BEHAVIORAL HEALTH SERVICES' RIGHT -
COL 84 "USERID: " FORMAT A15 SQL.USER SKIP 2 CENTER -
'CLIENT ENROLLMENT DISENROLLMENT AND REPORTING SYSTEM (CEDAR)' SKIP 4
COL USER FORMAT A10 TRUNCATE
COL TABLE_NAME FORMAT A30
SELECT OWNE
by snowcycle
You could try using the UTL_FILE set of commands. These output data to a file with a maximum of 1023 characters, so you could open a file:
vfhdl_op_file := UTL_FILE.FOPEN(vs_dir, vs_filename, 'w');
vn_reccount := 0;
FOR lrec_row IN lcur_query LOOP
-- output record
vn_reccount := vn_reccount + 1;
UTL_FILE.PUTF(vfhdl_file, lrec_decl.op_row);
UTL_FILE.NEW_LINE(vfhdl_file, 1);
END LOOP;
-- write trailer record (if you want to!)
UTL_FILE.PUTF(vfhdl_file, '**END OF FILE**, ' || TO_CHAR(vn_reccount, '9999999999'));
UTL_FILE.NEW_LINE(vfhdl_file, 1);
-- close file
UTL_FILE.FCLOSE(vfhdl_file);
Your cursor should be like this:
CURSOR lcur_query IS
SELECT Column1 || ',' || Column2 || ',' || Column3
|| ',' || Column4 || ',' || Column5 || ',' || Column6 AS table_line
FROM USER.TABLE
ORDER BY Column1, Column2, Column3
Order by not required, add parameters and data formatting to taste.
by ranjeevk
spool command can't be used inside PL/SQL .
But you can increase the buffer length inside PL/SQL so that you will not get the error of overflow.
by alesu
You can keep using dbms_output package, but try using a bigger buffer:
SET SERVEROUTPUT ON SIZE n, where n is the new buffer size.
by vs
You may set a buffer size for dbms_output by command: dbms_output.enable(buffer_size=512000);
Buffer size cannot be greater than 1000000.
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending