premal has asked for the wisdom of the Perl Monks concerning the following question:
I have written a CGI perl script to communicate to Rational ClearQuest to fetch some data and display it on the screen. I am able to do this but I want to capture the data fetched from ClearQuest to be stored in some variable and later I will use some looping to print the values on the screen. The reason I want to do this because I am also printing a check boxes at the begining of every row. I have a button to do certain action based on the values selected through check boxes. There can be only one or multiple check box selection and depending upon selected check boxes I want to pass the selected values to a perl script and execute that script in backgroud when user clicks on button.
I don't know how to store the data returned by ClearQuest into a variable. If I declare Variable inside the while loop which is retriving ClearQuest data the variable will only store most recent data (i.e. last value fatched). Can anyone please help me out to get this resolved? I have given my code below.
#!C:\Program Files\IBM\RationalSDLC\ClearQuest\CQperl.exe use CGI::Carp qw(fatalsToBrowser); use CQPerlExt; # for ClearQuest API access my ($sessionObj) = CQSession::Build(); my ($workSpace) = ""; $sessionObj->UserLogon("user", "passwd\$", "CQDB", ""); ########################################################### # Create the query to find ReleaseForm records ########################################################### my $queryDef = $sessionObj->BuildQuery("Environment"); # select the fields that you want in the report $queryDef->BuildField("Environment"); $queryDef->BuildField("Release"); $queryDef->BuildField("Project"); $queryDef->BuildField("VLS_Name"); $queryDef->BuildField("AppServerName"); $queryDef->BuildField("State"); $queryDef->BuildField("URL"); my ($FilterNode1) = $queryDef->BuildFilterOperator($CQPerlExt::CQ_BOOL +_OP_AND); $FilterNode1->BuildFilter("Release", $CQPerlExt::CQ_COMP_OP_EQ, ["$R +elease"]); $FilterNode1->BuildFilter("Environment", $CQPerlExt::CQ_COMP_OP_EQ, +["$Environment"]); $FilterNode1->BuildFilter("State", $CQPerlExt::CQ_COMP_OP_EQ, ["Acti +ve"]); $FilterNode1->BuildFilter("Project", $CQPerlExt::CQ_COMP_OP_NEQ, ["I +nfoAdvantage Baseline"]); $FilterNode1->BuildFilter("Project", $CQPerlExt::CQ_COMP_OP_NEQ, ["I +nfoAdvantage Platinum"]); $FilterNode1->BuildFilter("Project", $CQPerlExt::CQ_COMP_OP_NEQ, ["I +nfoAdvantage Custom"]); $FilterNode1->BuildFilter("Project", $CQPerlExt::CQ_COMP_OP_NEQ, ["P +B Baseline"]); # Create sort types and sort orders my $queryFieldDefs = $queryDef->GetQueryFieldDefs(); $hostname = $queryFieldDefs->ItemByName("Release"); $hostname->SetSortType($CQPerlExt::CQ_SORT_ASC); $hostname->SetSortOrder(1); my $resultSet = $sessionObj->BuildResultSet($queryDef); # create our + result set $resultSet->EnableRecordCount(); # execute the query and populate the result set $resultSet->Execute(); # go to the first row of the result set $status = $resultSet->MoveNext(); # while we have another row in the result set while ($status == $CQPerlExt::CQ_SUCCESS) { my $Environment = $resultSet->GetColumnValue(1); my $Release = $resultSet->GetColumnValue(2); my $Project = $resultSet->GetColumnValue(3); my $VLS_Name = $resultSet->GetColumnValue(4); my $AppServerName = $resultSet->GetColumnValue(5); my $State = $resultSet->GetColumnValue(6); my $URL = $resultSet->GetColumnValue(7); print <<END_HTML; <table border="1" cellpadding="8" bgcolor="#CCD6F5"> <tr> <td><input type="checkbox" value="$VLSName"/></td> <td>$Release</td> <td>$Environment</td> <td width="160">$Project</td> <td width="430"><a href="$URL">$URL</a></td> </tr> </table> END_HTML # next row in result set $status = $resultSet->MoveNext; } print <<END_HTML; <br><input type="submit" value="Bounce"/> </form> END_HTML CQSession::Unbuild($sessionObj);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Capture output of a while loop into a variable
by onelesd (Pilgrim) on Sep 26, 2011 at 05:24 UTC | |
by premal (Acolyte) on Sep 27, 2011 at 08:34 UTC | |
by onelesd (Pilgrim) on Sep 27, 2011 at 18:30 UTC | |
Re: Capture output of a while loop into a variable
by CountZero (Bishop) on Sep 26, 2011 at 06:21 UTC |