Oggetto Database

Un oggetto Database memorizza informazioni relative ad un database utente.

Utilizzare l'oggetto Database per modificare le proprietà associate ad un database. Utilizzando delle proprietà di tale oggetto, è possibile ottenere e impostare il nome di database, le informazioni descrittive, gli intervalli di timeout e le informazioni relative all'accesso. È inoltre possibile utilizzare i metodi di tale oggetto per adattare la revisione dello schema associata al database.

L'impostazione di una proprietà non aggiorna automaticamente il valore corrispondente nel database. Per aggiornare i valori nel database, è necessario richiamare il metodo ApplyPropertyChanges. Quando viene richiamato questo metodo, IBM® Rational ClearQuest aggiorna i valori di tutte le proprietà dei database che sono state modificate.

Per impostare la revisione dello schema di un nuovo database, creare il database, quindi richiamare il metodo SetInitialSchemaRev dell'oggetto Database.

Per modificare la revisione dello schema di un database esistente, richiamare il metodo Upgrade dell'oggetto Database.

Per creare un nuovo database utente utilizzando un oggetto Database, effettuare le seguenti operazioni:

  1. Creare il database richiamando il metodo CreateDatabase dell'oggetto corrente AdminSession.
  2. Impostare la revisione dello schema iniziale utilizzando il metodo SetInitialSchemaRev.
    Nota: quando le revisioni di schema diventano disponibili, aggiornare il database utilizzando il metodo Upgrade.

I seguenti esempi mostrano come creare un database e come impostare la relativa revisione dello schema.

Esempi

VBScript

set adminSession = CreateObject("Rational 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); 

Feedback