closeserverfile
closeserverfile

The closeserverfile statement closes the current database (used on the server).

Parameters

No parameters.

Description

This statement tells Panorama X server that the current database can be closed. It can be used by web publishing code that has used the openserverfile statement to open a database.

The closeserverfile statement does not close the database immediately. First, it checks to see if any user has the database open for sharing. If they do, the file will not be closed.

If no one is using the file for sharing, it still will not be closed immediately. Instead, the server will delay before actually closing the database. The delay time is controlled by the Auto Close Delay option in the Server panel of the PanoramaX>Preferences dialog.

The purpose of this delay is server performance. If the database is opened again soon, Panorama won’t have to read the file from disk into memory again.

For example, here’s a web procedure for a very simple order entry database (so simple that each invoice can have only 1 item). This code adds a new order and looks up the price of the item.

    let sku = webformitemvalue("SKU")
    let wasDatabase = info("databasename")
    openserverfile "Prices"
    setactivedatabase wasDatabase
    addrecord
    SKU = sku
    Price = lookup("Prices","SKU","SKU","Price",0)
    setactivedatabase "Prices"
    closeserverfile

If this web procedure is called multiple times within a short period (the Auto Close Delay period), the Prices database will only be read from disk into memory once. As long as the auto close delay period doesn’t expire, the database won’t actually close.

Note that the delay is extended each time this code runs. Suppose the Auto Close Delay period is 5 seconds. If the code is called once every 3 seconds, the database will never close. Each time the closeserverfile statement runs, the delay will extend another five seconds.

See Also

- Auxiliary Databases -- automatically opening multiple databases associated with each other.
- closefile -- closes the current database.
- Custom Database Initialization -- using an .Initialize procedure to automatically run custom code when a database opens.
- Database Integrity Checks -- checking database integrity when opening and saving.
- Database is Damaged Alert -- how to fix the "database is damaged" alert when opening a database.
- getcookie( -- returns the value of a cookie submitted to the server.
- getcookielist( -- returns a list of cookies submitted to the server.
- opendatabase -- opens a database file.
- openfile -- opens a database file. It can also import data from a text file, another database, or a variable into the current database.
- opensavedwindows -- opens windows that were open the last time file was saved.
- opensecret -- opens a database invisibly, without opening its windows.
- openserverfile -- opens a database (used on the server).
- opentextfile -- imports data from a text file or a variable into the current database.
- panoramastartupdatabases -- opens any databases specified for startup.
- setcookie -- set the value of a cookie to send back to the client..
- Web Cookies -- web cookies.
- webformitemvalue( -- gets the value of a POST web form item (used when processing a web query with Panorama Server).
- webimagedisplay( -- used within an Image Display Object to specify both a web image (used when the form is displayed in a web browser from Panorama Server) and a local image file (used when the form is displayed within Panorama).
- webshare -- perform record locking operations from a web publishing procedure.

History

Version | Status | Notes
10.2 | Updated | Carried over from Panorama 6.0.