UTL_FILE.FCLOSE_UDF

Definition

This user-defined function (UDF) is used to replicate the functionality of the Oracle UTL_FILE_FCLOSE procedure.

UTL_FILE.FCLOSE_UDF(FILE VARCHAR)

Parameters

FILE VARCHAR

The file to process and close.

Returns

Returns a varchar with the result.

Usage example

The UTL_FILE.FCLOSE_UDF closes the file that is being processed. To review the result or handle files, it is required to use the Snowflake CLI console. The Snowflake CLI console allows the upload or download of a file.

Input:

CREATE OR REPLACE PROCEDURE PROC()
RETURNS VARCHAR
LANGUAGE SQL
EXECUTE AS CALLER
AS
$$
   DECLARE
    file_data  VARIANT;
   BEGIN
   
    CALL UTL_FILE.FOPEN_UDF('test2.csv','a');
    
    SELECT
      *
    INTO
      file_data
    FROM
      TABLE(RESULT_SCAN(LAST_QUERY_ID()));

    CALL UTL_FILE.PUT_LINE_UDF(:file_data,'New line');


    CALL UTL_FILE.FCLOSE_UDF(:file_data);
 
      
   END
$$;

CALL PROC();

Output:

null

Last updated