当我在 Oracle SQL 开发人员中执行查询时,我想在本地计算机上读取包含查询参数的文件。到目前为止,我在网上找到的示例并不充分。执行以下代码时,我不断收到“ORA-29283:无效文件操作”错误:
CREATE DIRECTORY SAMPLEDATA2 AS 'C:';
GRANT READ, WRITE ON DIRECTORY SAMPLEDATA2 TO PUBLIC;
declare
f utl_file.file_type;
s varchar2(200);
c number := 0;
BEGIN
f := utl_file.fopen('SAMPLEDATA2','sample2.txt','R');
loop
utl_file.get_line(f,s);
dbms_output.put_line(s);
c := c + 1;
end loop;
exception
when NO_DATA_FOUND then
utl_file.fclose(f);
dbms_output.put_line('Number of lines: ' || c);
end;