Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

UTL_FILE Errors

879856Sep 24 2011 — edited Sep 24 2011
CREATE OR REPLACE PROCEDURE Write_CLOB_To_XML_File
IS

clob_loc CLOB;
buffer VARCHAR2(32767);
buffer_size CONSTANT BINARY_INTEGER := 32767;
amount BINARY_INTEGER;
offset NUMBER(38);
file_handle UTL_FILE.FILE_TYPE;
directory_name CONSTANT VARCHAR2(80) := 'oracleclrdir';
new_txt_filename CONSTANT VARCHAR2(80) := 'textfile1.txt';

BEGIN

DBMS_OUTPUT.ENABLE(100000);

-- ----------------
-- GET CLOB LOCATOR
-- ----------------
SELECT txt_file INTO clob_loc
FROM test_clob
WHERE id = 1;

-- --------------------------------
-- OPEN NEW XML FILE IN WRITE MODE
-- --------------------------------
file_handle := UTL_FILE.FOPEN(
location => directory_name,
filename => new_txt_filename,
open_mode => 'w',
max_linesize => buffer_size);

amount := buffer_size;
offset := 1;

-- ----------------------------------------------
-- READ FROM CLOB XML / WRITE OUT NEW XML TO DISK
-- ----------------------------------------------
WHILE amount >= buffer_size
LOOP

DBMS_LOB.READ(
lob_loc => clob_loc,
amount => amount,
offset => offset,
buffer => buffer);

offset := offset + amount;

UTL_FILE.PUT(
file => file_handle,
buffer => buffer);

UTL_FILE.FFLUSH(file => file_handle);

END LOOP;

UTL_FILE.FCLOSE(file => file_handle);

END;




I wrote above procedure to storing a CLOB column into a file ................But it shows the following errors....


Error(9,21): PLS-00201: identifier 'UTL_FILE' must be declared
Error(9,21): PL/SQL: Item ignored
Error(27,5): PLS-00320: the declaration of the type of this expression is incomplete or malformed
Error(27,5): PL/SQL: Statement ignored
Error(50,9): PL/SQL: Statement ignored
Error(51,26): PLS-00320: the declaration of the type of this expression is incomplete or malformed
Error(54,9): PL/SQL: Statement ignored
Error(54,33): PLS-00320: the declaration of the type of this expression is incomplete or malformed
Error(58,5): PL/SQL: Statement ignored
Error(58,29): PLS-00320: the declaration of the type of this expression is incomplete or malformed





Can anyone tell me that's, there is some special permission must be grant to UTL_FILE before using...... or there is some other problem.....
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 22 2011
Added on Sep 24 2011
3 comments
411 views