Database Object

A Database object stores information about a user database.

Use the Database object to change the properties associated with a database. Using the properties of this object, you can get and set the database name, descriptive information, timeout intervals, and login information. You can also use the methods of this object to adjust the schema revision associated with the database.

Setting a property does not automatically update the corresponding value in the database. To update the values in the database, you must call the ApplyPropertyChanges method. When you call this method, HCL Compass updates the values of any database properties that have changed.

To set the schema revision of a new database, create the database, then call the database object's SetInitialSchemaRev method.

To change the schema revision of an existing database, call the database object's Upgrade method.

To create a new user database by using the Database object, follow these steps:

  1. Create the database by calling the CreateDatabase method of the current AdminSession object.
  2. Set the initial schema revision by using the SetInitialSchemaRev method.
    Note: As new schema revisions become available, update the database by using the Upgrade method.

The following examples show you how to create a database and set its initial schema revision.

Examples

VBScript


set adminSession = CreateObject("ClearQuest.AdminSession")
set db = adminSession.CreateDatabase("newDB") 

' Set initial schema to first revision of "mySchema" 
set schemas = adminSession.Schemas 
set mySchema = schemas.Item("mySchema") 
set schemaRevs = mySchema.SchemaRevs 
set firstRev = schemaRevs.Item(1) 
db.SetInitialSchemaRev(firstRev) 

Perl


use CQPerlExt;
$adminSession = CQAdminSession::Build();

#Create a database
$db = $adminSession->CreateDatabase("newDB");

#From the list of schemas from the schema repository, get the
#"mySchema" schema
$schemas = $adminSession->GetSchemas();
$mySchema = $schemas->ItemByName("mySchema");

#From the list of all the revisions associated with "mySchema", 
#get the first revision in the list
$schemaRevs = $mySchema->GetSchemaRevs();
$firstRev = $schemaRevs->Item(0);

#Set initial schema to first revision of "mySchema"
$db->SetInitialSchemaRev($firstRev);

#...
CQAdminSession::Unbuild($adminSession);