utPLSQL logo

[ Home | Getting Started | Build Test Packages | Examples | User Guide | Release Notes | Document Map ]

< Previous Section: Custom Reporter Packages | Next Section: Release Notes >

Configuring the File Reporter

Outline

By default, the results of a test run are written to the screen (via the default Output Reporter). The subprograms described in this section were created by Rainer Medert to allow these results to be written to file instead. They form part of the utConfig package. Don't forget that you will first need to enable file output from the database via the UTL_FILE_DIR parameter in order to do this.

Turning file output on

To turn on file output, you will need to switch to using the File Reporter, or a custom reporter that uses it. See the page on Custom Reporter Packages for details.

Setting the directory to be used

Once file output has been turned on, you can specify which directory the files will be written to using the following procedure:

PROCEDURE setfiledir (
   dir_in      IN VARCHAR2 := NULL, 
   username_in IN VARCHAR2 := NULL
);

the directory given will have to have been specified for output in a UTL_FILE_DIR database parameter, as mentioned above.

To see which directory is being used for output, use the following:

FUNCTION filedir (username_in IN VARCHAR2 := NULL) RETURN VARCHAR2;

Formatting the output filenames

The structure of the filenames used for output is as follows:

<user-prefix>_[program-name_]<date><extension>

Each of these elements can be configured using the following procedures.

The user-prefix is an arbitrary string. It defaults to the username of the currently connected user, but can be set (and returned) using the following:

-- Set the file prefix for a user
PROCEDURE setuserprefix (
   userprefix_in IN VARCHAR2 := NULL, 
   username_in   IN VARCHAR2 := NULL
);

-- Get the file prefix for a user
FUNCTION userprefix (username_in IN VARCHAR2 := NULL) RETURN VARCHAR2;

The program-name is the name of the tested program, or the test suite being run. By default, this is element is not used in the generated filename. To turn this on or off (and to determine the current setting), use the following:

-- Set the include program name flag for a user
PROCEDURE setincludeprogname (
   incname_in  IN BOOLEAN := FALSE, 
   username_in IN VARCHAR2 := NULL
);

-- Get the include program name flag for a user
FUNCTION includeprogname (username_in IN VARCHAR2 := NULL) RETURN BOOLEAN;

The date element of the filename is simply SYSDATE converted to a string. The default format is 'YYYYDDMMHH24MISS', but this can be set (and returned) using the following:

-- Set the date format for a user
PROCEDURE setdateformat (
   dateformat_in IN VARCHAR2 := 'yyyyddmmhh24miss', 
   username_in   IN VARCHAR2 := NULL
);
          
-- Get the date format for a user
FUNCTION dateformat (username_in IN VARCHAR2 := NULL) RETURN VARCHAR2;

The final element of the filename that can be configured is the extension. This defaults to ".UTF" but can be set (and returned) using the following:

-- Set the file extension for a user
PROCEDURE setfileextension (
   fileextension_in IN VARCHAR2 := '.UTF', 
   username_in IN VARCHAR2 := NULL
);

-- Get the file extension for a user
FUNCTION fileextension (username_in IN VARCHAR2 := NULL) RETURN VARCHAR2;

Note The initial dot must be included, otherwise there will be none in the resulting filename!

Setting all the parameters at once

It is possible to set all the file output parameters at once using the following procedure:

PROCEDURE setfileinfo ( 
   dir_in           IN VARCHAR2 := NULL,
   userprefix_in    IN VARCHAR2 := NULL, 
   incname_in       IN BOOLEAN  := FALSE,     
   dateformat_in    IN VARCHAR2 := 'yyyyddmmhh24miss', 
   fileextension_in IN VARCHAR2 := '.UTF',
   username_in      IN VARCHAR2 := NULL
);

To get back all of the file output parameters simultaneously, use the following function:

FUNCTION fileinfo (username_in IN VARCHAR2 := NULL) RETURN rec_fileinfo;

The record type rec_fileinfo is defined in the utConfig package and has one field for each of the parameters.

< Previous Section: Custom Reporter Packages | Next Section: Release Notes >

utPLSQL logo

Valid XHTML 1.0 Strict