Daylight v4.9
Release Date: 1 February 2008

Name

dt_open - open a database

Generic Prototype

dt_open(dt_Handle, dt_String, dt_String, dt_String, dt_Integer *)
=> dt_Handle

C Prototype

#include "dt_thor.h"

dt_Handle dt_open(dt_Handle server, dt_Integer dblen, dt_String dbname, dt_Integer mlen, dt_String mode, dt_Integer plen, dt_String passwd, dt_Integer *isnew)

FORTRAN Prototype

include 'dt_f_thor.inc'

integer*4 dt_f_open(server, dbname, mode, passwd, isnew)

integer*4 server
character*() dbname
character*() mode
character*() passwd
integer*4 isnew

Description

Opens a database. The object 'server' represents the THOR or Merlin server program running on the machine on which the database resides. The server becomes the parent of the opened database.

If the server is a THOR server, the following operations occur: the thorserver opens all of the databases datafiles, including the primary and cross-reference data files and the primary and cross-reference hash files. Associated databases (see dt_setauxillarydb(3)) are automatically opened with "r" (read) permission.

If the server is a merlin server, the following operations occur: the merlinserver opens the primary data file, reads its contents into memory, and closes the file. The memory remains in use as long as any user has the database opened.

The string 'dbname' is the path of the database on the server. If 'path' is a simple filename, the server will search its search path for a database of the given name. The first database whose name matches 'dbname' will be opened. If 'dbname' contains any directory information, it must be a complete path. Partial and relative pathnames are not allowed. In this case, the server's search path is ignored.

The string 'mode' must be one of "r", "w", or "e" for read, write, or executive permission. The string 'passwd' must be the database's password for the given mode or a "higher" mode. The executive password may be used for read, write, and executive access. The write password may be used for read and write access.

The parameter 'isnew' indicates whether the returned handle represents a newly-opened database connection, or represents an existing connection. If 'isnew' if FALSE, the client was already connected to the specified database and the handle returned represents an object which was allocated by a previous call to this function.

Return Value

Returns a handle for a database object, or the NULL_OB if an error is encountered. For a thorserver, the returned object will be type TYP_DATABASE. For a merlinserver, the returned object will be type TYP_POOL.

Reasons that the connection may fail include:

- the database doesn't exist or is locked by another server,
- there is a problem with the server,
- the password is not valid for the requested permission mode,
- one of the associated databases can not be opened.

Related Topics

dt_database(3) dt_exists(3) dt_getdatabases(3) dt_getpasswords(3) dt_getsearchpath(3) dt_getusers(3) dt_isopen(3) dt_ispublic(3) dt_ping(3) dt_server(3) dt_setpassword(3) dt_setsearchpath(3)