Erase history Table every 6 months - see my excerpt from PL/SQL

The following code clears table history employed every 6 months. The code below is run properly, I'm just trying to do
you don't know if there is an error in logic or not, I'm not, but I want to confirm with you.
-- This table holds delete date that deletes records from employee and customer history tables
CREATE TABLE historyDeletionDate (deleteHistoryDate DATE);
CREATE OR REPLACE PROCEDURE clear_emphistory
IS
   dateOfDeletion DATE;
BEGIN
   BEGIN
      SELECT deleteHistoryDate
        INTO dateOfDeletion
        FROM historyDeletionDate;
   EXCEPTION
      WHEN NO_DATA_FOUND THEN
         dateOfDeletion := SYSDATE;
   END;

   IF TRUNC(dateOfDeletion) <= TRUNC(SYSDATE) THEN
      EXECUTE IMMEDIATE 'truncate table CUSTOMERHISTORY';
      EXECUTE IMMEDIATE 'PURGE RECYCLEBIN';
      UPDATE historyDeletionDate SET deleteHistoryDate = ADD_MONTHS(SYSDATE, 6);
   END IF;
END;
/

Hello

It seems wrong to me: clear and effective.

Production code must have a few comments. Pretend that someone (someone you love) must support your work without training on your code. That this person would find useful?

Instead of a single line, an array of columns just to hold the next regular deleteHistoryDate, consider having a multi-line and 2-column table that is also a newspaper when the destruction was actually done. You might have a scheduledDate column that came when labor is schduled and a completedDate column that is initially EMPTY, but filled in when the work is completed. The Babu query would be:

SELECT  scheduledDate
  INTO  dateOfDeletion
  FROM  historyDeletionDate
 WHERE  completedDate     IS NULL;

Tags: Database

Similar Questions

  • Can't see an excerpt from the article on iPhone with web viewer enabled. How to solve?

    I try to activate the preview of the article for the web viewer for iPhone. On iPhone, I see just a banner with the cover of my problem...

    image.png

    How can I configure so that viewers can just to see complete with overlays "Get App" section as it is configured for iPad?

    Here is a link to test...

    Citygram Austin July 2014: makes - Kumbh Mela

    It is a Folio v30, all items are marked as 'free', folios have the same name and product ID and web viewer is enabled.

    I thought I had this feature before.

    We do not support the viewer of the web article on iPhone, right on iPad.

    Neil

  • Curious to see an excerpt from capture

    Just received and installed my new MacPro 8-core and was happy to first Pro CS5 running on it.  I have a Canon HV20 with a number of bands of HD video, and I preview with the HV20 with Premiere Elements on my last computer (a PC running XP) so I was eager to see what I could do with the Mac and eager to create some discs out of sequence that was who languish in a drawer.

    My first task was to capture the video and I was surprised to see that when shooting, it was not in the preview screen.  Apparently, I'm supposed to peer at the tiny screen and try to use it for my clip plugs.  I was really surprised and thought that I had missed a setting somewhere and then I found this link:

    http://help.Adobe.com/en_US/PremierePro/CS/using/WS1c9bc5c2e465a58a91cf0b1038518aef7-7faaa .html

    italic indicates that Mac OS is apparently unable to provide this function.  So, I'm curious - why not?  He worked in elements on my PC of 7 years.  What is the problem?

    Thanks in advance for the info,

    G.

    Sorry, I missed this second question - I lost with Capture HD preview...

    PrPro has always been designed to stop (reading, Capture, etc) when it loses focus. Many have filed feature requests for changing. Historically, the render and export were the only functions that did not leave, when the discussion has been moved.

    I can tell you the reason that the loss of the coding process when the focus was moved, but think that it was introduced with PrPro 1.0, when Adobe has rewritten the program and changed the entire playback engine. Maybe Todd, or Jeremy can comment on that. For me, this is a case of "it's like that" and it's not much of a response.

    One of the places that this judgment is really in the way is if you use PrPro as a monitor to record narration in another program, and they need to turn up the gain, etc. Probably other forums as well.

    Good luck

    Hunt

  • I have firefox clear history when it closes and it clears my exceptions to pop up windows whenever it closes. How firefox can erase history without deleting the exceptions to the pop-up windows?

    I have firefox clear history when it closes and it clears my exceptions to pop up every time it closes. How firefox can erase history without deleting the exceptions to the pop-up windows? Allow this makes it difficult to play of Facebook games like farmville, because I have to allow him every time, and I have to type in rather than it to automatically. Thank you, Jamie

    Do not remove the navigation, search and download history on Firefox to clear the "Site preferences".

    Compensation of the "Site Preferences" clears all exceptions for cookies, images, windows pop up, installation of software and passwords.

  • How to erase history of cards in 9.2.1 iOS

    How to erase history of cards in 9.2.1 on a 6 s iPhone iOS?

    Fist off the coast, maps, type in the search bar. From there, you should see recent, tap it. Then after that, look to the bottom of the page and find the link recent and on it. In the upper left corner, you will see clear. Touch it. You see a warning on the bottom of the page to clear all Recents, or cancel. Disable all the recent and you're good to go.

  • How can I erase history navigation, cache and cookies

    How can I erase history navigation, cache and cookies?

    You'd which using your Safari browser. Perhaps under the menu Safari or in the privacy of the Safari preferences option.

  • How can, during the collection of data, start a new column in my table every 100 data points?

    Hello! I have a problem with my data - I get in a wide range of 1 x 1000, but it's the repeated measures, each taking about 500 data points. I want to break this table for this data string start a new column in my table every 500 points given. I don't know how to do it-please help!

    datacompiler100 wrote:

    Hey thanks for the sponsor and the first off I must apologize for the State, I am attaching my VI. I put the part of the VI that I am working on (my team has access, so didn't post everything here) and also attached the data file (when just written in a spreadsheet file, not through the attached VI). I want to convert the long row of data and then start a new column every 50, 100, 5 points (user-defined).

    Using the data from the file, you can reshape everything simply (as you already!), followed by transposition (since you want columns instead of rows). 2D arrays must always be rectangular, so the last column is filled with zeros if necessary. Is that what you want?

    Of course if you try to add a new column in a file, that will not work. You can only add lines in an existing file because of the way the data is organized. To add columns, the entire file must be read, intertwined and all re-written new data in the file.

  • Every three months or more, the drive letter for the backup drives jumps from one to another

    I posted it here because there is no whole final forum for the Windows OS line.  It is a problem that has been around since Microsoft made Windows XP and, frankly, I'm tired of it.

    I have some backup players; one that I'm pretty much every day, whenever I have the machine and another every two weeks of use.  I make sure they are always attached to a specific USB port so that the computer does not change in response.  But still, every three months or so, the drive letter handling these jumps from one to the other.  I run a Web site today and use a p2p Manager to transfer files to my machine, but most of them depend on the drive, so I could really do without what is happening every three months... all because your company won't repair it or provide an intuitive, ToolPart beginners' of the Windows operating system, forcing to keep a disk permanently assigned to the same letter.

    I know that this is part of basic programming because it is something that Microsoft has simply been unwilling to identify and correct.  I know also there are millions of people like me who suffer from this problem.  For the love of God, please make this tool a priority for Windows 8 and build one for Windows 7/Vista!
    * original title - your drive letter management is (Windows, all versions) *.

    I don't think that the USB ports are wired so that the computer OS is informed of the port which has been consulted.

    I also doubt that you will get Microsoft to change at this point.  As a solution, I give my readers a volume name, and so I don't know which drive is no matter which drive letter that has.

    Steve

  • Is there a way to recover deleted history sites? Also, a way to prevent unauthorized users to erase history?

    Is there a way to recover deleted history sites? Also, a way to prevent unauthorized users to erase history?

    You need administrative rights to do this. Be careful as it is possible to easily create a very difficult to solve waste.

    Run gpedit.msc

    Reach

    -User configuration

    -Administrative templates

    -Windows components

    -Internet Explorer

    -Delete browsing history

    Disable the feature turned on 'delete browsing history '.

    You also probably want to configure

    -InPrivate

    Disable the active InPrivate browsing

    If you use IE8; Otherwise, the user can simply avoid registering in the first place.

    Also - the browser menus

    Tools menu: Disable Internet Options... menu active

    would be a good thing; Anyone who shouldn't be allowed to delete the history of should not be also change too much in the Internet Options.

    For some reason, changes to this setting of group policy have no effect in IE6 and IE8 on a workgroup computer XP Pro.

    In fact, I would like to disable the entire Tools menu item; However, there don't seem to be any means to do.

    Run gpupdate /Wait:0

    Any user who cannot access gpedit.msc, editing the registry (regedit.exe, regedt32.exe) or mmc.exe may re-activate it now grayed out in the menu items.

    Note: mmc.exe can be activated by right clicking my computer even as a limited user. Remove or deny permissions to these files for administrator users.

    I would like to configure them on a per user or user group basis. Does anyone know of a way to do by not part of a domain?

    I know no direct way to recover deleted history sites. Perhaps, they enter the trash somewhere. They may be captured by the network of monitoring programs, even if they have been deleted from the personal computer.

  • Want to do a new install of Windows 7 every 6 months

    Original title: key windows update online

    If I spend 7 prem, 7 pro how can I reinstall it later.

    I want to do a fresh install every 6 months or so to clear the trash, I can save installation pro on a disc or flash drive that has been downloaded from your site to install at a later date to do install prem, then upgrafe to pro

    First, you will need to reinstall Windows 7 Home Premium, reactivate, and then redo the upgrade to Windows 7 Professional.

    To avoid this, I would create a system image of Windows 7 Professional. This will exempt the need to reactivate whenever you need to reinstall.

    Another option is to create a system image of Windows 7 Home Premium before the upgrade.

    Make the update, change the name of the computer and create another image of the system:

    http://www.notebooks.com/2009/10/24/how-to-backup-your-installation-of-Windows-7/

  • Need to create the Partition in the history table

    Hello

    I have an audit table that stores the data for the last 8 years in it and the customer wants to retain the data for the last 8 years. Now as adding data to this table is increasing, there is a delay in execution of report which are acquired by querying on this table.

    Basically, they go a from date and to date. Then these date are compared with two columns of dates in the table. The condition of the query will be as below

    TRUNC (NVL (DATE1, DATE2)) > = TRUNC (TO_DATE (?, ' dd/mm/yyyy ""))

    AND TRUNC (NVL (DATE1, DATE2)) < = TRUNC (TO_DATE (?, ' dd/mm/yyyy ""))

    Users can query for any date range.

    I am thinking of creating a Partition of the range on this table for each month during the 8 years of data. Please suggest on the question of whether I should use partition interval range to make it more effective. And would also create an Index on this partition for the above two day columns.

    12 (months) SO * 8 (years) = 98 would be created partitions. This will not overload the schema of database/Tablespace? Y at - it another effective way to set the table.

    Please suggest and let me know for any clarification.

    There are 2 approaches (but not limited to 2) to create the Partition on an existing table:

    Note: There is no ALTER TABLE statement to convert a heap table to a partitioned table.

    1. create a temporary Partitioned table with the same types of data in the column. Take a dump of the original table (HEAP) export and import the dump into the newly created partitioned intermediate table. After checking the data file the original and rename the interim even as the original table.

    2 using the package Oracle DBMS_REDEFINITION automates the steps above from said (not exactly the same steps, however) and its done online - which means there is no required downtime, the original table may undergo DML operations during this process of redefinition. View partitioning of a table online with DBMS_REDEFINITION | Oracle instructor

    According to my understanding if let us know as a partition interval then in April if there is an inserted record then it will create a new partition for the month of April will be of value less than 30 April 2014 "and all other documents created in April will pass under it"

    Yes, it's a feature of 11g, which Oracle manages adding partitions as needed. In earlier versions DBA can add partitions manually from time to time. Reference www.gavinsoorma.com/2009/09/11g-interval-partitioning/

    Here the reason for check the sent_out_datetime NVL will be NULL for few records, so in this case we want to get the records for dates of mapping them to received_datetime

    In addition, try to replace the NVL with COALESCE and test it. This would help improve performance.

  • How to get the last day of a month for every 2 months for a given period?

    Hello

    Can is it some please let me know how to get the last day, last day of the week, the weekend last day, last Monday, one month for every 2 months for a given period?

    Thanks in advance.

    Try the below

    SELECT LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))) lastday.

    BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'SAT '.

    SO LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))-1

    WHERE TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'Sun '.

    THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))-2

    Of OTHER LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))

    END as lastweekday,

    BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') IN ('Sam', 'SUN')

    THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))

    Of OTHER LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))

    -(TO_NUMBER (TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))),' from)) - 1).

    END as lastweekendday,

    BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'MY

    THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))

    Of OTHER NEXT_DAY (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), "LUN")-7

    END AS lastmonday

    FROM (SELECT SYSDATE startdate,

    SYSDATE + 300 enddate

    THE DOUBLE)

    CONNECT BY LEVEL<=>

  • If I download files using Adobe Acrobat Pro DC, what are the limits on the number of downloads? I publish a set of PDF files every 3 months to about 1600 people. Is that allowed with this product, or should I register for something else?

    I need an affordable way to deliver a 20-20 MB of files PDF zip file every three months to about 1600 people. What program to do this? Load on the storage of Adobe site and then use an e-mail program to send the link to the recipients?

    Hello

    There is no limit to the number of downloads of a file shared on Adobe Document cloud. Please don't forget to create an anonymous link using 'Send & Track' app, and which can be shared with the participants as much as you want.

    Thank you!

  • Select the last disk in the history table

    How to select the last record in a history table? the example data is
    < p >
    Product EffectiveDate

    prod1 01/01/1980

    prod1 01/01/1990

    prod1 01/01/2000

    prod2 02/02/1980

    prod2 02/02/2000
    < /p >
    < p >


    The expected result is



    Product EffectiveDate

    prod1 01/01/2000

    prod2 02/02/2000
    < /p >

    Assuming that there is a single line with max (effectivedate) for a given product

    SELECT product, attrib1, attrib2, ... , max_effective_date
      FROM (SELECT product,
                   attrib1,
                   attrib2,
                   ... ,
                   effectivedate,
                   max( effectivedate ) over (partition by product) max_effective_date
              FROM history_table)
     WHERE effectivedate = max_effectivedate
    

    should work.

    Justin

    Published by: Justin cave on October 30, 2008 18:32

    Formatting changes

  • how every 3 months a year and the dynamics of group a new column?

    I have a sql that allows to display the folders below.
    YEARS MONTHS SUMMONTH SUMYEAR
    ----- ------ -------- -------
     2009 Apr      130288 1720164 
     2009 Aug      138776 1720164 
     2009 Dec      140294 1720164 
     2009 Feb      136422 1720164 
     2009 Jan      148253 1720164 
     2009 Jul      149842 1720164 
     2009 Jun      122805 1720164 
     2009 Mar      145872 1720164 
     2009 May      151193 1720164 
     2009 Nov      133487 1720164 
     2009 Oct      169443 1720164 
     2009 Sep      153489 1720164 
     2010 Apr      142255 1719457 
     2010 Aug      135894 1719457 
     2010 Dec      171203 1719457 
     2010 Feb      137011 1719457 
     2010 Jan      145493 1719457 
     2010 Jul      137474 1719457 
     2010 Jun      154411 1719457 
     2010 Mar      133062 1719457 
     2010 May      146887 1719457 
     2010 Nov      139869 1719457 
     2010 Oct      127191 1719457 
     2010 Sep      148707 1719457 
    
     24 rows selected 
    The SQL code that I use:
    select years, months, summonth, sumyear
    from(
    select years, months, SUM (sumHour) OVER (PARTITION BY years,months) sumMonth, SUM (sumHour) OVER (PARTITION BY years) sumyear
    from (SELECT x.years, x.months, x.days, x.hours, x.mins, sum(x.value) as sumHour
    FROM xmltest, 
    XMLTABLE ('$d/cdata/name' passing xmldoc as "d" 
       COLUMNS 
      years integer path 'year',
      months varchar(3) path 'month',
      days varchar(2) path 'day',
      hours varchar(2) path 'hour',
      mins varchar(2) path 'minute',
      value float path 'value'
      ) as X 
      group by x.years, x.months, x.days, x.hours, x.mins
      order by x.years, x.months, x.days
      )
      )
      group by years,months,summonth,sumyear
      order by years
    and now the problem of problems can group the sum of 3 months of recording as a quarter of the year in a dynamic column?

    The display should be seydou this:
    YEARS MONTHS SUMMONTH SUMQUARTER SUMYEAR
    ----- ------ -------- ---------- -------
     2009 Feb      136422     430547 1720164 
     2009 Jan      148253     430547 1720164 
     2009 Mar      145872     430547 1720164 
     2009 Apr      130288     404286 1720164 
     2009 Jun      122805     404286 1720164 
     2009 May      151193     404286 1720164 
     2009 Aug      138776     442107 1720164 
     2009 Jul      149842     442107 1720164 
     2009 Sep      153489     442107 1720164 
     2009 Dec      140294     443224 1720164 
     2009 Nov      133487     443224 1720164 
     2009 Oct      169443     443224 1720164 
     2010 Feb      137011     415566 1719457 
     2010 Jan      145493     415566 1719457 
     2010 Mar      133062     415566 1719457 
     2010 Apr      142255     443553 1719457 
     2010 Jun      154411     443553 1719457 
     2010 May      146887     443553 1719457 
     2010 Aug      135894     422075 1719457 
     2010 Jul      137474     422075 1719457 
     2010 Sep      148707     422075 1719457 
     2010 Dec      171203     438263 1719457 
     2010 Nov      139869     438263 1719457 
     2010 Oct      127191     438263 1719457 
    
     24 rows selected 
    Thanks everybody helps me. !!

    may be using an external selection:

    SQL> with sample_tab as
      2  (
      3  select  2009 year, 'Aug' month, 138776 summonth , 1720164  sumyear from dual union all
      4  select  2009,'Apr',130288,     1720164 from dual union all
      5  select  2009,'Dec', 140294 , 1720164  from dual union all
      6  select  2009,'Feb', 136422 , 1720164  from dual union all
      7  select  2009,'Jan', 148253 , 1720164  from dual union all
      8  select  2009,'Jul', 149842 , 1720164  from dual union all
      9  select  2009,'Jun', 122805 , 1720164  from dual union all
     10  select  2009,'Mar', 145872 , 1720164  from dual union all
     11  select  2009,'May', 151193 , 1720164  from dual union all
     12  select  2009,'Nov', 133487 , 1720164  from dual union all
     13  select  2009,'Oct', 169443 , 1720164  from dual union all
     14  select  2009,'Sep', 153489 , 1720164  from dual union all
     15  select  2010,'Apr', 142255 , 1719457  from dual union all
     16  select  2010,'Aug', 135894 , 1719457  from dual union all
     17  select  2010,'Dec', 171203 , 1719457  from dual union all
     18  select  2010,'Feb', 137011 , 1719457  from dual union all
     19  select  2010,'Jan', 145493 , 1719457  from dual union all
     20  select  2010,'Jul', 137474 , 1719457  from dual union all
     21  select  2010,'Jun', 154411 , 1719457  from dual union all
     22  select  2010,'Mar', 133062 , 1719457  from dual union all
     23  select  2010,'May', 146887 , 1719457  from dual union all
     24  select  2010,'Nov', 139869 , 1719457  from dual union all
     25  select  2010,'Oct', 127191 , 1719457  from dual union all
     26  select  2010,'Sep', 148707 , 1719457  from dual
     27  )
     28  select year,
     29         month,
     30         summonth,
     31         sum(summonth) over(partition by year || to_char(ym, 'Q') order by year || to_char(ym, 'Q')) sumquarter,
     32         sumyear
     33    from (
     34          select year,
     35                  month,
     36                  summonth,
     37                  sumyear,
     38                  to_date(year || month, 'YYYYMon') ym
     39            from sample_tab)
     40   order by ym
     41  ;
    
          YEAR MONTH   SUMMONTH SUMQUARTER    SUMYEAR
    ---------- ----- ---------- ---------- ----------
          2009 Jan       148253     430547    1720164
          2009 Feb       136422     430547    1720164
          2009 Mar       145872     430547    1720164
          2009 Apr       130288     404286    1720164
          2009 May       151193     404286    1720164
          2009 Jun       122805     404286    1720164
          2009 Jul       149842     442107    1720164
          2009 Aug       138776     442107    1720164
          2009 Sep       153489     442107    1720164
          2009 Oct       169443     443224    1720164
          2009 Nov       133487     443224    1720164
          2009 Dec       140294     443224    1720164
          2010 Jan       145493     415566    1719457
          2010 Feb       137011     415566    1719457
          2010 Mar       133062     415566    1719457
          2010 Apr       142255     443553    1719457
          2010 May       146887     443553    1719457
          2010 Jun       154411     443553    1719457
          2010 Jul       137474     422075    1719457
          2010 Aug       135894     422075    1719457
    
          YEAR MONTH   SUMMONTH SUMQUARTER    SUMYEAR
    ---------- ----- ---------- ---------- ----------
          2010 Sep       148707     422075    1719457
          2010 Oct       127191     438263    1719457
          2010 Nov       139869     438263    1719457
          2010 Dec       171203     438263    1719457
    
    24 rows selected
    
    SQL> 
    

Maybe you are looking for