473,394 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to disable history from perl code

I am using a script. It autometically updates some cases. And it updates history of the cases also. But i don't want to be like that. I don't wnat to update history.
Is there any way to do.
Feb 21 '08 #1
11 2233
KevinADC
4,059 Expert 2GB
No idea what you are even talking about.
Feb 21 '08 #2
Kelicula
176 Expert 100+
Provide some code. Maybe we can help.
Include the "histories" you speak of.
Feb 22 '08 #3
I am updating 2 fields with my script. I have sheduled the code to run it for every 1 hour. It is updating successfully. But it is also updating history for each record. So per a day 24 entry will be registering in history of cases. So that is my problem. I don't want history to update.
Expand|Select|Wrap|Line Numbers
  1. =pod
  2.  
  3. =head1 Due Counter update
  4.  
  5. This program is supposed to be called by the scheduled tasks scheduled repeadtedly with an apropriate
  6. time interval. The purpose is to find all trouble report with a certain state, and inctrement a counter 
  7. in each record. It needs the cqperl Perl interpreter that comes with the IBM Rational ClearQuest 
  8. distribution
  9.  
  10. =head2 Syntax
  11.  
  12. =begin html
  13.  
  14. <pre>
  15. cqperl duecounterupdate.pl
  16. </pre>
  17.  
  18. =end html
  19.  
  20. =cut 
  21.  
  22. my $USERNAME   = "sqluser";    # This user account is a hard-coded
  23. my $PASSWORD   = "xyz";    # user accouunt in the database with SQL run privileges
  24. my $REPOSITORY = "xyz";
  25. my $DATABASE   = "TEST";
  26. my @QUERIES    = (
  27.     [ "Answering_Time_Count", "Public Queries/Due Counter/all_errand_answering_time_cases" ],
  28.     [ "Delivery_Time_Count",  "Public Queries/Due Counter/all_solution_delivering_time_cases" ],
  29. );
  30. my $one_day = 24 * 3600;       # Number of seconds for one day
  31. require CQPerlExt;             # Must be run with the cqperl binary.
  32.  
  33. #   Log on to the schema repository
  34. my $sqlSession = CQPerlExt::CQSession_Build();
  35. eval { $sqlSession->UserLogon( $USERNAME, $PASSWORD, $DATABASE, $REPOSITORY ); };
  36. if ($@) {
  37.     print "$@\n";
  38.     exit;
  39. }
  40. print "SQL Login as $USERNAME on $REPOSITORY succeeded\n";
  41.  
  42. # Get all national holidays
  43. my %HOLIDAYS  = ();
  44. my $resultSet = $sqlSession->BuildSQLQuery("select fldcolumn from Holidays order by 1");
  45.  
  46. $resultSet->Execute();
  47. while ( $resultSet->MoveNext() == $CQPerlExt::CQ_SUCCESS ) {    
  48.     my $holiday = $resultSet->GetColumnValue(1);
  49.     $HOLIDAYS{ substr( $holiday, 0, 10 ) } = 1;
  50. }
  51.  
  52. #print "Found holidays: " . join( ",", keys %HOLIDAYS ) . "\n";
  53.  
  54. my $workspace = $sqlSession->GetWorkSpace();
  55.  
  56. my $justnow = time();
  57.  
  58. for ( my $query = 0 ; $query <= $#QUERIES ; $query++ ) {
  59.     my @CASES     = ();
  60.     my $queryDef  = $workspace->GetQueryDef( $QUERIES[$query][1] );
  61.     my $resultSet = $sqlSession->BuildResultSet($queryDef);
  62.  
  63.     $resultSet->Execute();
  64.     while ( $resultSet->MoveNext() == $CQPerlExt::CQ_SUCCESS ) {
  65.         push @CASES, [ $resultSet->GetColumnValue(2), $resultSet->GetColumnValue(7), $resultSet->GetColumnValue(8) ];
  66.     }
  67.  
  68.     foreach my $case (@CASES) {
  69.         my ( $caseId, $counter, $changeTime ) = @$case;
  70.  
  71.         # The counter is displayed in decimal days. Convert it to seconds by multiply by seconds per day
  72.         $counter *= $one_day;
  73.  
  74.         print "Case $caseId: Last changed $changeTime, $QUERIES[$query][0]=$counter\n";
  75.  
  76.         # Update the due counters and the due-date field
  77.         my $diff = $justnow - $changeTime;
  78.         print "Diff=$diff\n";
  79.         while ( $diff > 0 ) {
  80.             my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime($changeTime);
  81.             my $datestr = sprintf( "%4.4d-%2.2d-%2.2d", 1900 + $year, 1 + $mon, $mday );
  82.             if ( !$HOLIDAYS{$datestr} && $wday != 0 && $wday != 6 ) {
  83.  
  84.                 if   ( $diff > 3600 ) { $counter += 3600; }
  85.                 else                  { $counter += $diff; }
  86.             }
  87.  
  88.             if   ( $diff > 3600 ) { $changeTime += 3600; }
  89.             else                  { $changeTime += $diff; }
  90.             $diff -= 3600;
  91.         }
  92.  
  93.         my $objtoedit = $sqlSession->GetEntity( "Case", $caseId );
  94.  
  95.         $sqlSession->EditEntity( $objtoedit, "modify" );
  96.  
  97.         # Convert counter back to decimal days by divide by seconds per day
  98.         $counter /= $one_day;
  99.  
  100.         # For some very stupuid reason that I cannot understand, the variable values to be used to update
  101.         # the field value must be referenced here, otherwise we will get an error message TODO: WHY?
  102.         #        $a = "$counter\n";
  103.  
  104.         print "objtoedit->SetFieldValue( $QUERIES[$query][0], $counter )\n";
  105.         $objtoedit->SetFieldValue( $QUERIES[$query][0], $counter );
  106.  
  107.         # Wait until the last query to update the last_due_calc field, since it is retreived by all queries
  108.         if ( $query == $#QUERIES ) {
  109.             my $a = "$justnow\n";
  110.             $objtoedit->SetFieldValue( 'Last_Due_Calc_time', $justnow );
  111.         }
  112.  
  113.         # Validate the changes. (Must be done in order to be able to commit the changes)
  114.         if ( $objtoedit->Validate() eq "" ) {
  115.             $objtoedit->Commit();
  116.         }
  117.         else {
  118.             $objtoedit->Revert();
  119.             print "Failed $caseId $QUERIES[$query][0]=$counter, calctime=$justnow\n";
  120.         }
  121.     }
  122.  
  123. }
  124.  
Histrory part
------------------

Expand|Select|Wrap|Line Numbers
  1. Date/Time    User Name    Action:    Old State    New State  
  2.  2008-02-19 14:19:33     edtalte     submit     no_value     Submitted   
  3.  2008-02-19 16:36:13     sqluser     modify     Submitted     Submitted   
  4.  2008-02-19 16:36:14     sqluser     modify     Submitted     Submitted   
  5.  2008-02-19 16:36:35     sqluser     modify     Submitted     Submitted   
  6.  2008-02-19 16:36:36     sqluser     modify     Submitted     Submitted   
  7.  2008-02-19 16:39:56     sqluser     modify     Submitted     Submitted   
  8.  2008-02-19 16:39:57     sqluser     modify     Submitted     Submitted   
  9.  2008-02-19 16:43:59     sqluser     modify     Submitted     Submitted   
  10.  2008-02-19 16:44:00     sqluser     modify     Submitted     Submitted   
  11.  2008-02-19 16:53:03     sqluser     modify     Submitted     Submitted   
  12.  2008-02-19 16:53:03     sqluser     modify     Submitted     Submitted   
  13.  2008-02-19 16:53:11     sqluser     modify     Submitted     Submitted   
  14.  2008-02-19 16:53:11     sqluser     modify     Submitted     Submitted   
  15.  2008-02-19 16:55:21     sqluser     modify     Submitted     Submitted   
  16.  2008-02-19 16:55:22     sqluser     modify     Submitted     Submitted   
  17.  2008-02-19 17:00:01     sqluser     modify     Submitted     Submitted   
  18.  2008-02-19 17:00:02     sqluser     modify     Submitted     Submitted   
  19.  2008-02-20 08:00:03     sqluser     modify     Submitted     Submitted   
  20.  2008-02-20 08:00:04     sqluser     modify     Submitted     Submitted   
  21.  2008-02-20 09:00:05     sqluser     modify     Submitted     Submitted   
  22.  2008-02-20 09:00:06     sqluser     modify     Submitted     Submitted   
  23.  2008-02-20 10:00:02     sqluser     modify     Submitted     Submitted   
  24.  2008-02-20 10:00:03     sqluser     modify     Submitted     Submitted   
  25.  2008-02-20 12:00:02     sqluser     modify     Submitted     Submitted   
  26.  2008-02-20 12:00:04     sqluser     modify     Submitted     Submitted   
  27.  2008-02-20 13:00:26     sqluser     modify     Submitted     Submitted   
  28.  2008-02-20 13:00:28     sqluser     modify     Submitted     Submitted   
  29.  2008-02-21 08:00:11     sqluser     modify     Submitted     Submitted   
  30.  2008-02-21 08:00:13     sqluser     modify     Submitted     Submitted   
  31.  2008-02-21 09:00:02     sqluser     modify     Submitted     Submitted   
  32.  2008-02-21 09:00:03     sqluser     modify     Submitted     Submitted   
  33.  2008-02-21 10:00:02     sqluser     modify     Submitted     Submitted   
  34.  2008-02-21 10:00:03     sqluser     modify     Submitted     Submitted   
  35.  2008-02-21 12:00:02     sqluser     modify     Submitted     Submitted   
  36.  2008-02-21 12:00:03     sqluser     modify     Submitted     Submitted   
  37.  2008-02-21 13:00:02     sqluser     modify     Submitted     Submitted   
  38.  2008-02-21 13:00:02     sqluser     modify     Submitted     Submitted   
  39.  2008-02-21 14:00:03     sqluser     modify     Submitted     Submitted   
  40.  2008-02-21 14:00:04     sqluser     modify     Submitted     Submitted   
  41.  2008-02-21 14:17:01     sqluser     modify     Submitted     Submitted   
  42.  2008-02-21 14:17:02     sqluser     modify     Submitted     Submitted   
  43.  2008-02-21 15:00:05     sqluser     modify     Submitted     Submitted   
  44.  2008-02-21 15:00:11     sqluser     modify     Submitted     Submitted
Feb 22 '08 #4
Kelicula
176 Expert 100+
I am sorry but, I still don't understand what you mean by "updating history part".

Do you have "default" values set up in the Database for those fields?

If a field is set to "not null", and you update some other field within the same record, the "default" value will be used to update the fields that were left blank.

I am not experienced with "CQPerlExt". For database transactions I use the DBI module.

You may want to move @CASES out of the loop, since declaring it with "my" within a loop will create warnings, when "strict" pragma is used.
(line 59)

I recommend using "strict" in all your scripts.
Feb 22 '08 #5
KevinADC
4,059 Expert 2GB
This is going to be a tooth pulling session so I am out of the thread.
Feb 22 '08 #6
eWish
971 Expert 512MB
The easiest approach would be to delete the code that does the updating of the history that you don't want to keep anymore.

We do not know which section of code is doing the updating. Comment out each of the areas one at a time until it does what you want.

Make sure your scripts use the strict and warnings pragmas to assist in your debugging efforts.

That is all we can tell you since your description and lack of information is not helping us help you.

--Kevin
Feb 23 '08 #7
What the system is:
I have a defect tracking system. In that I have defects that are said to be CASES. And I have all information about that defects i.e., CaseId, title, description, Attachment and History also. It contains when the case is opened, closed and timestamp etc.

What the requirement is:
What the requirement is I have to implement a field which says that the cases has to be closed in these many days. By that users can know the elapsed time to solve the case.

What I have done:
Basically it is a counter which calculates elapsed time in seconds and after that it is converted to days. Here we are considered holidays and national holidays as well.
And I updated the counter field by using modify action. Then this action modifies all the fields of history also.
When ever I call that script that action updates history also, and then there will be so many entries in that history. And I need to call the script an hour basis. So per day there are 24 entries that will be big problem

What I need:
I don’t want to update case history. Is there any possibility to update the only one filed?







I am sorry but, I still don't understand what you mean by "updating history part".

Do you have "default" values set up in the Database for those fields?

If a field is set to "not null", and you update some other field within the same record, the "default" value will be used to update the fields that were left blank.

I am not experienced with "CQPerlExt". For database transactions I use the DBI module.

You may want to move @CASES out of the loop, since declaring it with "my" within a loop will create warnings, when "strict" pragma is used.
(line 59)

I recommend using "strict" in all your scripts.
Feb 25 '08 #8
eWish
971 Expert 512MB
Is this homewor/classwork?
Feb 25 '08 #9
Already this system is using by a major client in Europe. I need to implement new requirements.

Is this homewor/classwork?
Feb 25 '08 #10
eWish
971 Expert 512MB
Okay, I have a better understanding now. What is the exact name of the field in the database for "Cases", the field you don't want to update?

In the code you posted I do not see where you are writing any data to the database. Where are the queries located that do the writing?

Would you please post some of the queries?

--Kevin
Feb 26 '08 #11
KevinADC
4,059 Expert 2GB
Okay, I have a better understanding now. What is the exact name of the field in the database for "Cases", the field you don't want to update?

In the code you posted I do not see where you are writing any data to the database. Where are the queries located that do the writing?

Would you please post some of the queries?

--Kevin

He should really be asking on a forum that discusses ClearQuest

http://www.ibm.com/developerworks/fo...pa?forumID=329

Here is almost the exact same question posted on the CLearQuest forum:

http://www.ibm.com/developerworks/fo...94537&tstart=0
Feb 26 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Tony Marston | last post by:
If the use of the browser's BACK button is interfering with the operation of your web application then take a look at this article entitle "Back Button Blues" ...
3
by: Paul | last post by:
Hi, just wondering if there is a way to disable the back button of the browser as I have a logoff page and would like to not allow the back operation? Guessing there may be a way to do it through...
8
by: Ed Jay | last post by:
I want to use history.go() to navigate between my previously loaded pages. I'm looking for a way to trigger a function call when a page is accessed using history.go(). Is there an event generated?...
2
by: Vani Donthula | last post by:
Hi In my web application,in one of the page where I need to disable the back button of the toolbar. Suggestions on this are welcome. Thanks, Vani.
3
by: vanya | last post by:
i have been tryin to program(javascript) to disable the following keystroke combinations CTRL+O or CTRL+L Go to a new location (O = 79 L = 76) CTRL+S Save the current page ( S = 83) CTRL+E...
0
by: sandeep ch | last post by:
hi , I am opening a excel sheet from perl but every time i run the program i get a pop up message saying that "This Workbook contains links to other sources" " - To update all linked information...
3
by: jdserran | last post by:
hello ^__^ does anyone here know a perl code or function that can be used to go back to a previous page after clicking a link? that is, it does the exact thing when you use javascript's...
3
parshupooja
by: parshupooja | last post by:
Hey all, I have button on page. OnClick event I am saving records to database, which takes couple of seconds, meanwhile if user becomes impatient and clicks again, it triggers save again. I want...
8
by: alamodgal | last post by:
hiiiiiiiiiii everybody, pls solve my problem if u can? Actualy what happens in my site when i press enter key it will show some secured...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.