4 Database Manipulation

The DBOPEN Statement

DBOPEN syntax:

DBOPEN (base name, password, mode, status)

The parameters are:

base name
A string variable containing the database name preceded by two blank spaces.
password
A string expression containing a left-justified ASCII string.
mode
A numeric expression equal to 1, 3, 8 or 9.
status
An integer array variable that returns status information after DBOPEN is executed. The array must contain at least ten elements in its right-most dimension.
Eloquence A.06.00 uses the client/server model to connect to a database server. Since the data base server can run on a different machine and there could be more than one server on a machine, the DBOPEN syntax accomplish this.

The DBOPEN statement uses a database specification, which consists of three terms:

Otherwise, the server hostname or "IP address" is required.

The syntax is as below:

[[server][:service]/][Database]

server
The name or IP number of the system running the database server. If it is omitted, the local system is assumed.
service
The service name or port number of the data base server. If it is omitted, the default service name "eloqdb" is assumed.
database
The database name.
* For Eloquence A.05.xx databases, this is the absolute path.

* For Eloquence A.06.xx, this is simply the data base name.

NOTE: The data base name is not case sensitive.

For example:

   Db$="  sampledb"
   DBOPEN(Db$,"",1,S(*))
This opens the database sampledb on the local system, using the default service.

Db$=" server/sampledb"

This would connect the default data base server running on the system named "server".

Db$=" server:eloqdb5/path/to/sampledb"

This would connect the data base server, running on the system named "server" using the port associated with the service name "eloqdb5". For Eloquence A.05.xx compatible data bases, it is required to specify an absolute path.

All the connection details could be hidden in a VOLUME definition. If a volume DBVOL is defined as below (for example in your .eloqrc file)

DBVOL="server:eloqdb5/path/to"

then the code below

Db$=" sampledb,DBVOL"

would connect to data base server:eloqdb5/path/to/sampledb.

DBOPEN Modes

A database may be opened in one of four modes. These modes determine the type of operations that can be performed by all users accessing the database.

Mode 1: Modify shared with database locking. Data entries may be read and written within the constraint of the user-class number granted by DBOPEN. Databases opened in mode 1 should be locked (DBLOCK) before data set entries may be added, deleted, or modified. If one user uses DBLOCK, all others also have to lock.

Mode 3: Modify exclusive. DBLOCK and DBUNLOCK statements are not required in this mode. Exclusive access is obtained for reading and/or writing. Although the database may change in content, it does so under your exclusive control. Control is relinquished after executing a DBCLOSE operation. Other requests for access to the database are refused until a DBCLOSE operation is executed.

Mode 8: Read shared. The database is opened for shared read access. Writing to the database is not permitted.

Mode 9: Open for read, allow concurrent update. The database is opened for read access. Other programs may open database in modes 1 and 8.

If successful, DBOPEN replaces the first two characters of the base name string variable, formerly blanks, with an ASCII database number between 00 and 09. This is the internal ID number of the database and should not be altered.

A corrupt database is accessible in mode 8. Status ERROR -94 is returned if the database is corrupt.

DBOPEN Status Array

A DBOPEN error assigns a non-zero conditional word (CW) to the first element of the status array. A list of all CW values and their meanings appear in page 197 . The following table describes the status array contents after a successful DBOPEN.

 
Array Element Value Description
10CW.
20 through 31User-class number.
30 
40 
50 
6Bits 0 through 11The DBOPEN identification number (401).
 Bits 12 through 15The mode value used to open the database.
7Program line number 
80 
9Mode numberDBOPEN-mode parameter value (same as bits 12 through 15 of element 6).
10Any valueReserved.


Eloquence Database Manual - 19 DEC 2002