DB2 Version 9.7 for Linux, UNIX, and Windows

FREMOVE procedure - Remove a file

The FREMOVE procedure removes a specified file from the system. If the file does not exist, this procedure throws an exception.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-UTL_FILE.FREMOVE--(--location--,--filename--)---------------><

Procedure parameters

location
An input argument of type VARCHAR(128) that specifies the alias of the directory that contains the file.
filename
An input argument of type VARCHAR(255) that specifies the name of the file.

Authorization

EXECUTE privilege on the UTL_FILE module.

Example

Remove the file myfile.csv from the system.

SET SERVEROUTPUT ON@

CREATE PROCEDURE proc1()
BEGIN
  DECLARE v_dirAlias      VARCHAR(50) DEFAULT 'mydir';
  DECLARE v_filename      VARCHAR(20) DEFAULT 'myfile.csv';
  CALL UTL_FILE.FREMOVE(v_dirAlias,v_filename);
  CALL DBMS_OUTPUT.PUT_LINE('Removed file: ' || v_filename);
END@

CALL proc1@

This example results in the following output:

Removed file: myfile.csv