CREATE_DIRECTORY procedure - Create a directory alias
The CREATE_DIRECTORY procedure creates a directory alias for the specified path.
Directory information is stored in SYSTOOLS.DIRECTORIES,
which is created in the SYSTOOLSPACE when you first reference this
module for each database.
Syntax
Procedure parameters
- alias
- An input argument of type VARCHAR(128) that specifies the directory alias.
- path
- An input argument of type VARCHAR(1024) that specifies the path.
Authorization
EXECUTE privilege on the UTL_DIR module.
Examples
Create a directory alias, and use it in a call to the UTL_FILE.FOPEN function.
SET SERVEROUTPUT ON@
CREATE OR REPLACE PROCEDURE proc1()
BEGIN
DECLARE v_filehandle UTL_FILE.FILE_TYPE;
DECLARE isOpen BOOLEAN;
DECLARE v_filename VARCHAR(20) DEFAULT 'myfile.csv';
CALL UTL_DIR.CREATE_DIRECTORY('mydir', '/home/user/temp/mydir');
SET v_filehandle = UTL_FILE.FOPEN('mydir',v_filename,'w');
SET isOpen = UTL_FILE.IS_OPEN( v_filehandle );
IF isOpen != TRUE THEN
RETURN -1;
END IF;
CALL DBMS_OUTPUT.PUT_LINE('Opened file: ' || v_filename);
CALL UTL_FILE.FCLOSE(v_filehandle);
END@
CALL proc1@
This example results in the following output:
Opened file: myfile.csv