Home » RDBMS Server » Enterprise Manager » PLS HELP: WRITING TO A FILE IN PL/SQL
PLS HELP: WRITING TO A FILE IN PL/SQL [message #68782] Thu, 16 September 2004 03:59 Go to next message
RAJ SINGH
Messages: 10
Registered: October 2002
Junior Member
HI ALL.

THIS IS THE CODE I HAVE WRITTEN TO CREATE A FILE.

ITS NOT WORKING.

PLS HELP.

CREATE OR REPLACE PROCEDURE WRITEFILE(LOCATIONS IN VARCHAR2,FILEN IN VARCHAR2, LINE2BINST IN VARCHAR2)

IS

FILER UTL_FILE.FILE_TYPE;

BEGIN

FILER := UTL_FILE.FOPEN(LOCATIONS,FILEN,'W');

IF LINE2BINST IS NOT NULL

THEN

UTL_FILE.PUT_LINE(FILER,LINE2BINST);

ELSE

UTL_FILE.PUT_LINE(FILER,'HI HOW ARE U');

END IF;

UTL_FILE.FCLOSE(FILER);

EXCEPTION

WHEN UTL_FILE.INVALID_PATH THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20000, 'File location is invalid.');

WHEN UTL_FILE.INVALID_MODE THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20001, 'The open_mode parameter in FOPEN is invalid.');

WHEN UTL_FILE.INVALID_FILEHANDLE THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20002, 'File handle is invalid.');

WHEN UTL_FILE.INVALID_OPERATION THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20003, 'File could not be opened or operated on as requested.');

WHEN UTL_FILE.READ_ERROR THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20004, 'Operating system error occurred during the read operation.');

WHEN UTL_FILE.WRITE_ERROR THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20005, 'Operating system error occurred during the write operation.');

WHEN UTL_FILE.INTERNAL_ERROR THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20006, 'Unspecified PL/SQL error.');

WHEN UTL_FILE.CHARSETMISMATCH THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20007, 'A file is opened using FOPEN_NCHAR, but later I/O ' ||

'operations use nonchar functions such as PUTF or GET_LINE.');

WHEN UTL_FILE.FILE_OPEN THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20008, 'The requested operation failed because the file is open.');

WHEN UTL_FILE.INVALID_MAXLINESIZE THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20009, 'The MAX_LINESIZE value for FOPEN() is invalid; it should ' ||

'be within the range 1 to 32767.');

WHEN UTL_FILE.INVALID_FILENAME THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20010, 'The filename parameter is invalid.');

WHEN UTL_FILE.ACCESS_DENIED THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20011, 'Permission to access to the file location is denied.');

WHEN UTL_FILE.INVALID_OFFSET THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20012, 'The ABSOLUTE_OFFSET parameter for FSEEK() is invalid; ' ||

'it should be greater than 0 and less than the total ' ||

'number of bytes in the file.');

WHEN UTL_FILE.DELETE_FAILED THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20013, 'The requested file delete operation failed.');

WHEN UTL_FILE.RENAME_FAILED THEN

UTL_FILE.FCLOSE(FILER);

RAISE_APPLICATION_ERROR(-20014, 'The requested file rename operation failed.');

WHEN OTHERS THEN

UTL_FILE.FCLOSE(FILER);

RAISE;

END;

/

I EXECUTED IT THIS WAY:

SQL>execute writefile('c:aa','aaa.dat','hi how are u doing');

THE ERRORS I HAVE GOT ARE:

ERROR at line 1:
ORA-20000: File location is invalid.
ORA-06512: at "SYSTEM.WRITEFILE", line 18
ORA-06512: at line 1

PLS HELP ME OUT.

-RAJ
Re: PLS HELP: WRITING TO A FILE IN PL/SQL [message #68794 is a reply to message #68782] Wed, 22 September 2004 23:13 Go to previous messageGo to next message
san
Messages: 11
Registered: October 2001
Junior Member
everything is fine.
just see that u have system previliges.
thats it.
-san.
Re: PLS HELP: WRITING TO A FILE IN PL/SQL [message #68884 is a reply to message #68782] Wed, 05 January 2005 20:07 Go to previous message
parijat
Messages: 1
Registered: January 2005
Junior Member
same error though i have system priviledge
Previous Topic: shared memory realm does not exist
Next Topic: Oracle Management Server
Goto Forum:
  


Current Time: Sun May 22 11:38:39 CDT 2022