I have written a script to read data from a file, execute a SQL query, then write the data to an output file. I was getting this error: "ORA-20000: utl_file.invalid_path" when I had my read/write files in C:\scripts on my local drive. In SQL*Plus, I executed "show parameters" and the utl_file_dir is set to "/oracle/app/oracle/admin/{dbname}/udump". I tried created this path on my C: drive and copied the files in that I wanted to read and write to/from to this new directory. I still get the same error. I tried executing ALTER SYSTEM SET UTL_FILE_DIR='C:\scripts' and got the error "ORA-02095: specified initialization parameter cannot be modified"
I am not the DBA, and if I ask the DBA to change this parameter for me, I know he won't do it. He is totally uncooperative, and won't make any changes we need to the database. Is there some way I can change this parameter for myself only, locally, without any help from the DBA?
Here is my script also, in case there is something else wrong with it that may be causing this error (I have thoroughly tested this SELECT statement and it is working fine, I just don't want to have to execute it 100 times and cut and paste the results into Excel!):
DECLARE
NEXT_CASE_ID_NUMBER varchar2(20);
input_file utl_file.file_type;
output_file utl_file.file_type;
BEGIN
input_file := utl_file.fopen('\scripts', 'case_ids.txt', 'r');
output_file := utl_file.fopen('\scripts', 'output_1.txt', 'w');
LOOP
utl_file.get_line(input_file, NEXT_CASE_ID_NUMBER);
utl_file.put(output_file, NEXT_CASE_ID_NUMBER);
utl_file.put(output_file,
'SELECT p.person_id, p.first_name, p.last_name || " INCOME",
i.INCOME_TYPE_CD AS ITEM_TYPE_CD, i.PERIOD_TYPE_CD, i.START_DT,
i.END_DT, i.GROSS_AMOUNT AS AMOUNT
FROM person p, income i
WHERE p.person_id (+) = i.person_id
AND p.person_id in
(select PERSON.PERSON_ID
FROM PERSON, CASE_MEMBER
WHERE PERSON.PERSON_ID = CASE_MEMBER.PERSON_ID
AND case_id = NEXT_CASE_ID_NUMBER)
UNION
select p.person_id, p.first_name, p.last_name || " ASSET",
a.ASSET_TYPE_CD AS ITEM_TYPE_CD, "X", a.START_DT, a.END_DT, a.CASH_VALUE AS AMOUNT
FROM person p, asset a
WHERE p.person_id (+) = a.person_id
AND p.person_id in
(select PERSON.PERSON_ID
FROM PERSON, CASE_MEMBER
WHERE PERSON.PERSON_ID = CASE_MEMBER.PERSON_ID
AND case_id= NEXT_CASE_ID_NUMBER)
UNION
select p.person_id, p.first_name, p.last_name || " EXPENSE",
e.EXPENSE_TYPE_CD AS ITEM_TYPE_CD, e.PERIOD_TYPE_CD,e.START_DT,
e.END_DT, e.AMOUNT
FROM person p, expense e
WHERE p.person_id (+) = e.person_id
AND p.person_id in
(select PERSON.PERSON_ID
FROM PERSON, CASE_MEMBER
WHERE PERSON.PERSON_ID = CASE_MEMBER.PERSON_ID
AND case_id = NEXT_CASE_ID_NUMBER)');
utl_file.new_line(output_file);
END LOOP;
IF utl_file.is_open(input_file) THEN
utl_file.fclose(input_file);
END IF;
IF utl_file.is_open(output_file) THEN
utl_file.fclose(output_file);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('NO_DATA_FOUND');
WHEN utl_file.invalid_path THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.invalid_path');
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE('TOO_MANY_ROWS');
WHEN utl_file.invalid_mode THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.invalid_mode');
WHEN utl_file.READ_ERROR THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.READ_ERROR');
WHEN utl_file.WRITE_ERROR THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.WRITE_ERROR');
WHEN utl_file.INTERNAL_ERROR THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.INTERNAL_ERROR');
WHEN utl_file.INVALID_FILEHANDLE THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.INVALID_FILEHANDLE');
WHEN utl_file.INVALID_MAXLINESIZE THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.INVALID_MAXLINESIZE');
WHEN utl_file.INVALID_OPERATION THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.INVALID_OPERATION');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('UNKNOWN ERROR');
END;
I am not the DBA, and if I ask the DBA to change this parameter for me, I know he won't do it. He is totally uncooperative, and won't make any changes we need to the database. Is there some way I can change this parameter for myself only, locally, without any help from the DBA?
Here is my script also, in case there is something else wrong with it that may be causing this error (I have thoroughly tested this SELECT statement and it is working fine, I just don't want to have to execute it 100 times and cut and paste the results into Excel!):
DECLARE
NEXT_CASE_ID_NUMBER varchar2(20);
input_file utl_file.file_type;
output_file utl_file.file_type;
BEGIN
input_file := utl_file.fopen('\scripts', 'case_ids.txt', 'r');
output_file := utl_file.fopen('\scripts', 'output_1.txt', 'w');
LOOP
utl_file.get_line(input_file, NEXT_CASE_ID_NUMBER);
utl_file.put(output_file, NEXT_CASE_ID_NUMBER);
utl_file.put(output_file,
'SELECT p.person_id, p.first_name, p.last_name || " INCOME",
i.INCOME_TYPE_CD AS ITEM_TYPE_CD, i.PERIOD_TYPE_CD, i.START_DT,
i.END_DT, i.GROSS_AMOUNT AS AMOUNT
FROM person p, income i
WHERE p.person_id (+) = i.person_id
AND p.person_id in
(select PERSON.PERSON_ID
FROM PERSON, CASE_MEMBER
WHERE PERSON.PERSON_ID = CASE_MEMBER.PERSON_ID
AND case_id = NEXT_CASE_ID_NUMBER)
UNION
select p.person_id, p.first_name, p.last_name || " ASSET",
a.ASSET_TYPE_CD AS ITEM_TYPE_CD, "X", a.START_DT, a.END_DT, a.CASH_VALUE AS AMOUNT
FROM person p, asset a
WHERE p.person_id (+) = a.person_id
AND p.person_id in
(select PERSON.PERSON_ID
FROM PERSON, CASE_MEMBER
WHERE PERSON.PERSON_ID = CASE_MEMBER.PERSON_ID
AND case_id= NEXT_CASE_ID_NUMBER)
UNION
select p.person_id, p.first_name, p.last_name || " EXPENSE",
e.EXPENSE_TYPE_CD AS ITEM_TYPE_CD, e.PERIOD_TYPE_CD,e.START_DT,
e.END_DT, e.AMOUNT
FROM person p, expense e
WHERE p.person_id (+) = e.person_id
AND p.person_id in
(select PERSON.PERSON_ID
FROM PERSON, CASE_MEMBER
WHERE PERSON.PERSON_ID = CASE_MEMBER.PERSON_ID
AND case_id = NEXT_CASE_ID_NUMBER)');
utl_file.new_line(output_file);
END LOOP;
IF utl_file.is_open(input_file) THEN
utl_file.fclose(input_file);
END IF;
IF utl_file.is_open(output_file) THEN
utl_file.fclose(output_file);
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('NO_DATA_FOUND');
WHEN utl_file.invalid_path THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.invalid_path');
WHEN TOO_MANY_ROWS THEN
DBMS_OUTPUT.PUT_LINE('TOO_MANY_ROWS');
WHEN utl_file.invalid_mode THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.invalid_mode');
WHEN utl_file.READ_ERROR THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.READ_ERROR');
WHEN utl_file.WRITE_ERROR THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.WRITE_ERROR');
WHEN utl_file.INTERNAL_ERROR THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.INTERNAL_ERROR');
WHEN utl_file.INVALID_FILEHANDLE THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.INVALID_FILEHANDLE');
WHEN utl_file.INVALID_MAXLINESIZE THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.INVALID_MAXLINESIZE');
WHEN utl_file.INVALID_OPERATION THEN
RAISE_APPLICATION_ERROR(-20000, 'utl_file.INVALID_OPERATION');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('UNKNOWN ERROR');
END;