| superclass(es) | object |
| subclass(es) | - |
| description | The class dbSession takes care of initializing and loading all the components necessary for the relational database access. |
| remarks | When the first instance of this class is created the ODBC DLL is loaded
and initialized. The ODBC DLL is removed when no more instances of this class exist. This class is located in the file db.txt. |
| see also | database - query |
| There is no need to create an instance of this class, the file 'db.txt'
contains a static instance of this class. The name of the static instance is 'dbsession'.
With the an instance if this class it is possible to check if the initialization of
the database access software was successful or not, see the method initialized/1. dbsession<-initialized(O). The method iterateDatabases/3 can be used to create a list of (all) available ODBC datasources configured on a computer system. With the methods firstDatabase/4 and nextDatabase/3 it is also possible to create a list containing (all) available ODBC datasources. All installed ODBC drivers can be returned by the method iterateDrivers/2. More information about each ODBC driver can be retrieved by the methods firstDriver/3 and nextDriver/3. A list of 'attribute = value' pairs is created when firstDriver/3 and nextDriver/3 is called, the list of attributes can vary per driver. During development of a database application it is often useful to be able to view the ODBC and database error messages, the default setting is that these are not shown. By using the method putDebugMode/1 with parameter value 'true' the error messages will be displayed. The error code of the last error detected can always be retrieved by the method lastError/1. To translate an error code to an error message the dberror/2 predicate can be used or the method lastErrorMsg/1 can be called. |
| func | Determine if the Trinc-Prolog relation database access system was correctly initialized or not. |
| pre | TRUE |
| post | If Trinc-Prolog has correctly initialized the relation database access software then true was assigned to the variable Output else was false assigned. |
iterateDatabases(Filter, List, Output)/3
| func | Create a list of available data sources. The first parameter Filter determines the type of data sources must be searched, the three possible values are: 'all', 'user', 'system'. For instance: if Filter is 'user' then only data sources defined as user data sources are placed in the output list variable. |
| pre | The variable Filter must contain one of the three value: 'all', 'user' or 'system'. |
| post | If there was no problem creating the list of data sources then true was assigned to Output, if there was an error then was false assigned. The variable List is assigned a list of data source names. |
firstDatabase(Filter, OutName, OutDescr, Output)/4
| func | Get name and description of the first data sources that is of the type specified by the value of the Filter variable. The first parameter Filter determines the type of data sources, the three possible values are: 'all', 'user', 'system'. |
| pre | The variable Filter must contain one of the three value: 'all', 'user' or 'system'. |
| post | If a database of the correct type was found then true was assigned to Output, if there was an error then was false assigned. The name and description of the database were assigned to the variables OutName and OutDescr. |
nextDatabase(OutName, OutDescr, Output)/3
| func | Get name and description of the next data source. The type of datasource searched is determined by the last call to the method firstDatabase/4. |
| pre | There must have been a call to the method firstDatabase/4. |
| post | If a database of the correct type was found then true was assigned to Output, if there was an error then was false assigned. The name and description of the database were assigned to the variables OutName and OutDescr. |
iterateDrivers(List, Output)/2
| func | Create a list of available ODBC database drivers. |
| pre | TRUE |
| post | If there was no problem creating the list of database drivers then true was assigned to Output, if there was an error then was false assigned. The variable List is assigned a list of database driver names. |
firstDriver(OutName, OutAttribs, Output)/3
| func | Get name and list of attributes of the first ODBC database driver. |
| pre | TRUE |
| post | If a first database driver was found then true was assigned to the variable Output, if no driver was found then was false assigned. For the first driver the name was assigned to the variable OutName, The variable OutAttribs is assigned a list of 'attribute = value' pairs. The list of attributes can vary per driver. |
nextDriver(OutName, OutAttribs, Output)/3
| func | Get name and list of attributes of the next ODBC database driver. |
| pre | TRUE |
| post | If a first database driver was found then true was assigned to the variable Output, if no driver was found then was false assigned. For the first driver the name was assigned to the variable OutName, The variable OutAttribs is assigned a list of 'attribute = value' pairs. The list of attributes can vary per driver. |
| func | Switch the ODBC debug mode on or off. If the ODBC debug mode is on the ODBC error messages are displayed, else not. |
| pre | The variable YesNo must contain true or false. |
| post | If YesNo was true the ODBC error messages are displayed, else no error messages are displayed. |
| func | Determine if the ODBC debug mode is on or off. |
| pre | TRUE |
| post | If the ODBC debug mode is on then true was assigned to the variable Output, else was false assigned to the variable Output. |
| func | Store a new error code as the last error detected. |
| pre | The variable Val must contain an integer |
| post | The value of Val was stored as the last error code. |
| func | Return the error code of the last error detected. For all the error codes see dberror/2. |
| pre | TRUE |
| post | The error code of the last error detected was assigned to the variable OutputVal. |
| func | Return a string description of the last error detected. For all the error codes see dberror/2. |
| pre | TRUE |
| post | A message describing the last error was assigned to the variable OutputString.. |