FOPEN procedure
Translation reference for UTL_FILE.FOPEN.
Description
This procedure opens a file. (Oracle PL/SQL UTL_FILE.FOPEN)
This procedure is implemented using Snowflake STAGE to store the text files.
The user is in charge of uploading the local files to the STAGE to be used by the procedure.
This procedure requires to be used in conjunction with:
UTL_FILE.FCLOSE
procedure
Syntax
Setup data
The
UTL_FILE
schema must be created.
Create the stage
utlfile_local_directory
.
If the value in the
OPEN_MODE
parameter is w or r it is necessary to upload the file in theutlfile_local_directory
.
The PUT command runs in Snowflake CLI.
Custom procedure overloads
UTL_FILE.FOPEN( VARCHAR, VARCHAR)
Parameters
FILENAME: The name of the file, including extension**.**
OPEN_MODE: Specifies how the file is opened.
Open modes
The Oracle Built-in package UTL_FILE.FOPEN
procedure supports six modes of how to open the file, but only three of them are supported in the Snowscripting procedure.
Functionality
This procedure uses two tables with which the operation of opening a file will be emulated. The FOPEN_TABLES
table will store the files that are open and the FOPEN_TABLES_LINES
table stores the lines that each file owns.
If the file is opened in write mode, a new file is created, if it is opened in read or append mode, it loads the lines of the file in FOPEN_TABLES_LINES
and inserts the file in FOPEN_TABLES
.
Note:
Note that this procedure uses the stage that was created previously. For now, if you want to use another name for the stage, you must modify the procedure.
These procedures are implemented for the internal stages in the
COPY INTO