SQL

Description

Sets or returns the SQL string associated with the query.

If you assign a value to this property, the QueryDef object uses your string instead of the terms you have built using other methods of this object.

If you get the value of this property, the QueryDef object returns the SQL string that will be executed when the query is run. If you had assigned a SQL string to this property earlier, that string is returned; otherwise, this method generates a SQL string from the terms that have been added to the QueryDef object so far.

Syntax

VBScript

querydef.SQL 



set workspace = session.GetWorkSpace

set querydef = workspace.GetQueryDef queryName 
querydef.SQL string_of_SQL_statements 

Perl

$querydef->GetSQL();



$workspace = $session->GetWorkSpace();

$querydef = $workspace->GetQueryDef(queryName);
$querydef->SetSQL(string_of_SQL_statements); 
Identifier
Description
querydef
A QueryDef object.
string_of_SQL_statements
A String containing the individual SQL statements.
Return value
For the Get, returns a String containing the SQL that will be executed when the query is run.

For the Set, no return value. Returns an exception if user doesn't have SQL writer privilege.

Examples

VBScript

set session = GetSession

set workspace = session.GetWorkSpace

'Get the QueryDef by supplying a query name

set querydef = workspace.GetQueryDef "Public Queries\Defects"

'Provide a string of SQL statements

querydef.SQL "select distinct T1.dbid,T1.id,T1.headline from Defect 
T1,statedef T2 where T1.state = T2.id and (T1.dbid <> 0 and (T2.name = 
'Submitted'))" 

Perl

$workspace = $session->GetWorkSpace();

$querydef = $workspace->GetQueryDef(queryName);

$querydef->SetSQL("select distinct T1.dbid,T1.id,T1.headline from Defect 
T1,statedef T2 where T1.state = T2.id and (T1.dbid <> 0 and (T2.name = 
'Submitted'))"); 


Feedback