<< Click to Display Table of Contents >> Navigation: Concordance Programming Fundamentals > Working with the Database > Understanding Database Handles |
Before you open a database, you must first understand the concept of a database handle. You can think of a database handle as the handle of a briefcase: it is the part of the database you use to contact and use the database. CPL can have up to 16 handles at any given time; you can attach each of those handles to one and only one (ie, different) databases.
There are two ways to attach a handle to a database:
1.If you start a CPL with a database already open, Concordance will automatically attach the first handle (handle 0) to that database.
2.Alternately, you can explicitly open a database using the built-in opendb function.
Once you have an active handle, you can access database structure information such as field names and how many documents are in the database. You can also access the data within each field of each document.
A database handle is stored in an int variable, and is defined as an integer: 0 through 15. You will notice that many code samples in the following section contain the following arbitrary variable declaration:
int db; |
Since all numeric variables in CPL are initialized with a value of 0, the variable db will by default contain a handle to the current database. You may of course use your own variable names, if you so choose:
int myDatabase; int litSupportDatabase; int database1, database2; int youGetThePoint; |