EGL Reference Guide for iSeries

close

The EGL close statement disconnects a printer; or closes the file or message queue associated with a given record; or, in the case of an SQL record, closes the cursor that was open by an EGL open or get statement.



Syntax diagram for the close statement

name
Name of the I/O object that is associated with the resource being closed; that object is a print form or an indexed, MQ, relative, serial, or SQL record
resultSetIdentifier
For SQL processing only, an ID that ties the close statement to a get or open statement run earlier in the same program. For details, see resultSetID.

Example:

	 if (userRequest = "C")
     try
       close fileA;
     onException
        myErrorHandler(12);
     end
	 end 

The behavior of a close statement depends on the type of I/O object.

Indexed, serial, or relative record

When you use the name of an indexed, serial, or relative record in a close statement, EGL closes the file associated with that record.

If a file is open and you use the fileAssociation item to change the resource name associated with that file, EGL closes the file automatically before executing the next statement that affects the file. For details, see resourceAssociation.

EGL also closes any file that is open when the program ends.

MQ record

When you use the name of a MQ record in a close statement, EGL ensures that the MQSeries command MQCLOSE is executed for the message queue associated with that record.

Print form

If the I/O object is a print form, the close statement issues a form feed and either disconnects from the printer or (if the print form is spooled to a file) closes the file.

Before you use sysVar.printerAssociation to change the print destination, close the printer or file specified by the current value of sysVar.printerAssociation. Issue a close statement option for each print destination, as multiple printer or print files can be open at the same time.

EGL run time ensures that all printers are closed when the program ends.

SQL record

When you use the name of an SQL record in a close statement, EGL closes the SQL cursor that is open for that record.

EGL automatically closes a cursor in these cases:

EGL closes all open cursors in this case:


Related concepts
Record types and properties
resultSetID
Segmentation in text applications
SQL support


Related tasks
Syntax diagram


Related reference
add
delete
EGL statements
Exception handling
execute
get
get next
get previous
I/O error values
open
prepare
replace
recordName.resourceAssociation
SQL item properties
sysLib.commit
sysLib.rollback
sysVar.printerAssociation
sysVar.terminalID


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]