Server Directory Configuration
1. Create server directory (1) Execute the following command under System User:CREATE OR REPLACE DIRECTORY Mail_file_dir as '/mail_file/data/prod ';(2) Assign permissions to the created directory and execute:GRANT Read ,Write on DIRECTORY Mail_file_dir to Public;If it is a two-node server, execute the above SQL statement on two servers
2. Create on database server/mail_file/data/prodDirectory switch to home directory '/' Under Execute Create directory command after directory creation is complete, assign permissions under Home directory '/' command: chmod 777/mail_file/data/prod
3. write files to DirectoryDECLAREFhandle Utl_file.file_type;BEGINFhandle: = Utl_file.fopen ( ' Mail_file_dir ', ' Example.txt ' , ' W ');utl_file.put_line (Fhandle, ' GH test write one ');utl_file.put_line (Fhandle, ' gh test write ');Utl_file.fclose (fhandle);END;
4, read out the contents of the fileDECLAREFhandle Utl_file.file_type;Fp_buffer VARCHAR2( 4000);BEGINFhandle: = Utl_file.fopen ( ' Mail_file_dir ', ' Example.txt ' , ' R ');
utl_file.get_line (Fhandle, fp_buffer);Dbms_output.put_line (fp_buffer);utl_file.get_line (Fhandle, fp_buffer);Dbms_output.put_line (fp_buffer);Utl_file.fclose (fhandle);END;
Error:ORA-29283 : Invalid file operationORA-06512 : In "SYS. Utl_file ", Line 449ORA-29283 : Invalid file operationCause: There is no directory under the database or the directory does not have read and write permissions
Oracle EBS Server Directory Configuration