CodePudding user response:
Should can't, don't know how it functionsCodePudding user response:
Is it possible to achieve this effect by other means?CodePudding user response:
Also met the problem, not solved, finally a an export, I at that time is fixed, three well,If a lot or not fixed would have a little trouble, mark
CodePudding user response:
As the query statement is fixed, can consider to stored as an XML file, you can also use excel to open;CodePudding user response:
Right click copy to execl select copy all the as... Can take multiple query result export comes,CodePudding user response:
You can use the UTL_FILE package,Demo:
DECLARE
VSFILE UTL_FILE. FILE_TYPE; Definition - to accept a file handle type
The BEGIN
-- DBMS_OUTPUT. The ENABLE (1000000); - & gt; Avoid error ORA - 20000: ORU - 10027: BUFFER OVERFLOW, the LIMIT OF 10000 BYTES
- file naming rules.. The time table data as a file named...
- began to open the file
VSFILE:=UTL_FILE FOPEN (' DUMP_DIR01 ', 'EXCEL_DATA. CSV', 'W');
/* parameter is introduced:
UTL_FILE. FOPEN (LOCATION IN VARCHAR2, FILENAME IN VARCHAR2, OPEN_MODE VARCHAR2) IN RETURN FILE_TYPE;
The LOCATION is the DB directory name file storage, -- -- -- -- -- -- -- perform user should have to DIR directory permissions to read and write
FILENAME is the file name,
OPEN_MODE is open mode (' R 'is read text,' W 'is written text,' A 'is additional text, parameters are case insensitive, but if' A 'specified file does not exist, it will use the' W 'first created,' W 'have the function of covering) */
- file field headers printed
UTL_FILE. PUT_LINE (VSFILE, 'A, B, C);
- each file loaded rows [every time into the loop assignment of 0]. Eliminate the header part
- the contents of a FOR loop query,
FOR CUR (IN the SELECT LEVEL AS A, B LEVEL + 1 AS, LEVEL + 2 AS C
The FROM DUAL
CONNECT BY LEVEL & lt;=10) LOOP
/* UTL_FILE PUT_LINE if need EXCEL format, need to use commas, every field, open WINDOWS EXCEL tool default */
is EXCEL format?UTL_FILE. PUT_LINE (VSFILE, CUR. A | | ', '| | CUR. B | |', '| | CUR. C);
END LOOP;
- in the LOOP, otherwise an error ORA - 29282: file invalid ID/ORA - 06512: in the "SYS. UTL_FILE", LINE 878
- if you don't write the following mandatory/close the handle to the output buffer may be exported data is less than the query item
UTL_FILE. FFLUSH (VSFILE);
UTL_FILE. FCLOSE (VSFILE);
END;