how can i read write files from pl/sql
Answers were Sorted based on User's Feedback
Answer / avi007
DECLARE
fileHandler UTL_FILE.FILE_TYPE;
BEGIN
fileHandler := UTL_FILE.FOPEN('/tmp', 'myfile', 'W');
UTL_FILE.PUTF(fileHandler, 'Look ma, I''m writing to a
file!!!\n');
UTL_FILE.FCLOSE(fileHandler);
EXCEPTION
WHEN utl_file.invalid_path THEN
raise_application_error(-20000, 'ERROR:
Invalid path
for file or path not in INIT.ORA.');
END;
/
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / avi007
--Read file
DECLARE
fileHandler UTL_FILE.FILE_TYPE;
BEGIN
fileHandler := UTL_FILE.FOPEN('/tmp', 'myfile', 'R');
UTL_FILE.GETF(fileHandler, 'Look ma, I''m writing to a
file!!!\n');
UTL_FILE.FCLOSE(fileHandler);
EXCEPTION
WHEN utl_file.invalid_path THEN
raise_application_error(-20000, 'ERROR:
Invalid path
for file or path not in INIT.ORA.');
END;
/
Is This Answer Correct ? | 0 Yes | 0 No |
How do I quit sql?
What is the difference between mdf and ndf files?
Is sqlexception checked or unchecked?
Which tcp/ip port does sql server run?
Are pl sql variables case sensitive?
How many sql core licenses do I need?
How to fetch records from a partitioned table?
How do you display "13th of November, 17 days left for month end" without hardcoding the date.
How to write a single statement that concatenates the words ?hello? And ?world? And assign it in a variable named greeting?
How do I save the results of sql query in a file?
How to get second highest salary from a table
How can a function retun more than one value in oracle with proper example?