13.3. Creating and Checking Existence of Files
PLVfile provides a program (four overloaded versions, actually) to create a file. The headers for fcreate are the following:
FUNCTION fcreate (loc_in IN VARCHAR2, file_in IN VARCHAR2, line_in IN VARCHAR2) RETURN UTL_FILE.FILE_TYPE; FUNCTION fcreate (file_in IN VARCHAR2, line_in IN VARCHAR2 := NULL) RETURN UTL_FILE.FILE_TYPE; PROCEDURE fcreate (loc_in IN VARCHAR2, file_in IN VARCHAR2, line_in IN VARCHAR2); PROCEDURE fcreate (file_in IN VARCHAR2, line_in IN VARCHAR2 := NULL);
In versions of fcreate with three arguments, you provide the location, name, and single line to be deposited in the file. Notice that all three values are required. In versions of fcreate with two arguments, you provide the file specification (location and name combined, or just the name, in which case the default directory will be applied).
Notice that the overloading is not only among different parameter lists, but even different program types. I will explain this approach to overloading in PLVfile in this section; you will see it repeatedly throughout the package.
The overloading of fcreate achieves two objectives:
It allows the developer to either obtain the handle to the newly created file (the function versions) or ignore that file handle entirely (the procedure versions). You'll want to retrieve the handle if you plan to perform other actions on that file. If you only want to create the file and then move on to other business, it will be easier and more ...