SaveQueryDef

Description

Saves the query to the specified location in the workspace.

The user logged into the current session must have access to the pathname specified in the qdefPath parameter. (Thus, only users with administrative privileges can save queries to the Public Queries folder.) If the pathname you specify in the qdefPath parameter contains subfolders that do not exist, HCL Compass creates those folders implicitly.

The last parameter to the SaveQueryDef method is a Boolean value that specifies whether or not to overwrite an existing QueryDef object with the same name and path (0 = no overwrite, 1 = overwrite). The method returns an error if the query already exists, with either a 0 or 1 value specified for the overwrite parameter.

Syntax

VBScript


workspace.SaveQueryDef qdefName, qdefPath, queryDef, overwrite 

Perl


$workspace->SaveQueryDef(qdefName, qdefPath, queryDef, overwrite); 
Identifier
Description
workspace
The Workspace object obtained from the current session.
qdefName
A String containing the name of the query.
qdefPath
A String containing the pathname of the folder in which you want to save the query.
queryDef
The QueryDef object representing the query you want to save.
overwrite
A Bool indicating whether this query should overwrite a query with the same name and path information.
Return value
None.

Example

Perl

use CQPerlExt;
my $CQSession = CQSession::Build();
my $RootFolder = "Public Queries";
$CQSession->UserLogon($ologon, $opw, $odb, "");
$workspace = $CQSession->GetWorkSpace();
$QueryDef = $CQSession->BuildQuery("Defect");
@owner = ("jswift");
@state = ("Closed");
@dbfields = ("ID","State","Headline");
foreach $field (@dbfields) {
      $QueryDef->BuildField($field);   
      }
$FilterNode1 = $QueryDef->BuildFilterOperator($CQPerlExt::CQ_BOOL_OP_AND);
$FilterNode1->BuildFilter("Owner", $CQPerlExt::CQ_COMP_OP_EQ, \@owner);
$FilterNode1->BuildFilter('State', $CQPerlExt::CQ_COMP_OP_NOT_IN, \@state);
$ResultSet = $CQSession->BuildResultSet($QueryDef);
$ResultSet->Execute();
$workspace->SaveQueryDef("delete me", $RootFolder, $QueryDef, 1);
print "'$RootFolder/delete me' copied\n";
  }
CQSession::Unbuild($CQSession);