Getting a Session object

The Session object is the entry point for accessing Rational ClearQuest databases. If you are writing an external application, you must create a Session object and use it to log on to a database. After you have logged on to a database, you can use the Session object to:

For script hooks (VBScript and Perl), IBM Rational ClearQuest creates a Session object for your hooks automatically when the user logs on to the database. The Session object is available through the Entity object. In the context of a hook, to get a Session object from an entity object, use the following syntax.

Scripting language
Syntax for making a call to an Entity object in a hook
VBScript
set currentSession = GetSession

VBScript hooks implicitly associate the Entity object with the current record.

Perl
When writing Rational® ClearQuest® hooks, a Session object is created and made available through the context variable $session. You do not need to perform any explicit call to create it.
If you need a Session object in some other context (such as when writing an external application) you can get a Session object by using the following syntax:
$session=$entity->GetSession();

For external applications, you must create a Session object manually. If you want to use the AdminSession object, the same rule applies.

Language example
Syntax for manually creating the Session object (or the AdminSession object) in an external application
VBScript
set currentSession = CreateObject("CLEARQUEST.SESSION") 
set adminSession = CreateObject("CLEARQUEST.ADMINSESSION")
Perl
$currentSession = CQSession::Build();  
$currentAdminSession= CQAdminSession::Build();

When you are done with the object, destroy it:

CQSession::Unbuild($currentSession);
CQAdminSession::Unbuild($currentAdminSession);


Feedback