OPENTEMP

OPENTEMP

Top  Previous  Next

 

The OPENTEMP statement creates and opens a temporary dynamic file by pathname, associating it with a file variable.

 

 

Format

 

OPENTEMP {pathname} {options} TO file.var

{ON ERROR statement(s)}

{THEN statement(s)}

{ELSE statement(s)}

 

where

 

pathnameevaluates to the pathname of the file to be opened. If omitted of given as a null string, the temporary file is created in the QM temporary directory (see the TEMPDIR configuration parameter).

 

optionscontrol the manner in which the file is opened. The available options are:
ECSCreate ECS mode file (ignored on non-ECS systems)
NON.TRANSACTIONALIgnore transaction boundaries

 

file.varis the name of the variable to hold the file reference for use in later operations on this file.

 

statement(s)are statements to be executed depending on the outcome of the OPENTEMP operation.

 

At least one of the THEN and ELSE clauses must be present.

 

A file opened by the OPENTEMP statement may be referenced using the file variable in subsequent statements that operate on the file. The file is opened for exclusive use by the QM session in which the OPENPATH statement is executed and remains open so long as the file variable remains intact. Overwriting this variable or discard of the variable on return from a subroutine will implicitly close the file. The file will be deleted automatically when it is closed.

 

The optional NON.TRANSACTIONAL clause indicates that updates to the file are not to be treated as part of any transaction within which they occur.

 

If the file is opened successfully, the THEN clause is executed. If the open fails the ELSE clause is executed and the STATUS() function may be used to determine the cause of the failure.

 

The ON ERROR clause is taken only in the case of serious errors such as damage to the file's internal control structures. The STATUS() function will contain an error number. If no ON ERROR clause is present, a fatal error results in an abort.

 

 

Examples

 

OPENTEMP "\TEMP\MYFILE" TO TEMP.F ELSE ABORT "Cannot open temporary file"

 

This statement opens a temporary file as pathname \TEMP\MYFILE. If the open fails, the program aborts with an error message.

 

 

OPENTEMP TO TEMP.F ELSE ABORT "Cannot open temporary file"

 

This statement opens a temporary file in the QM temporary directory. If the open fails, the program aborts with an error message.

 

 

See also:

OPEN, OPENPATH