create or replace directory D_OUTPUT as ‘D:/temp’ ; --创建目录
grant read,write on directory D_OUTPUT to testuser; --将目录的读写权限授予用户
CREATE OR REPLACE PROCEDURE OUTPUTTXT
(
INCHAR IN CLOB
) AS
export_handle UTL_FILE.file_type;
BEGIN
export_handle := UTL_FILE.FOPEN('D_OUTPUT', 'test.txt', 'w');
UTL_FILE.PUT_LINE(export_handle,INCHAR);
UTL_FILE.FCLOSE(export_handle);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM, 1, 2000));
END OUTPUTTXT;
自己遇到的问题,创建新用户
create user Rx identified by Rx;
切换用户时报错
解决方法,将连接数据库的权限授予该用户
grant connect, resource to Rx;
grant create session to Rx;
这里使用的sql developer
使用conn Rx/Rx 会自动断开连接。
查看已经建立的目录
select * from dba_directories