• <legend id='Ct9KS'><style id='Ct9KS'><dir id='Ct9KS'><q id='Ct9KS'></q></dir></style></legend>
      <bdo id='Ct9KS'></bdo><ul id='Ct9KS'></ul>

    1. <tfoot id='Ct9KS'></tfoot>

      <small id='Ct9KS'></small><noframes id='Ct9KS'>

      <i id='Ct9KS'><tr id='Ct9KS'><dt id='Ct9KS'><q id='Ct9KS'><span id='Ct9KS'><b id='Ct9KS'><form id='Ct9KS'><ins id='Ct9KS'></ins><ul id='Ct9KS'></ul><sub id='Ct9KS'></sub></form><legend id='Ct9KS'></legend><bdo id='Ct9KS'><pre id='Ct9KS'><center id='Ct9KS'></center></pre></bdo></b><th id='Ct9KS'></th></span></q></dt></tr></i><div id='Ct9KS'><tfoot id='Ct9KS'></tfoot><dl id='Ct9KS'><fieldset id='Ct9KS'></fieldset></dl></div>

        我们如何在PL SQL中在特定时间后自动删除表行

        时间:2023-11-28
          <tbody id='EPqv4'></tbody>
          <bdo id='EPqv4'></bdo><ul id='EPqv4'></ul>
          1. <tfoot id='EPqv4'></tfoot>

              <small id='EPqv4'></small><noframes id='EPqv4'>

              1. <i id='EPqv4'><tr id='EPqv4'><dt id='EPqv4'><q id='EPqv4'><span id='EPqv4'><b id='EPqv4'><form id='EPqv4'><ins id='EPqv4'></ins><ul id='EPqv4'></ul><sub id='EPqv4'></sub></form><legend id='EPqv4'></legend><bdo id='EPqv4'><pre id='EPqv4'><center id='EPqv4'></center></pre></bdo></b><th id='EPqv4'></th></span></q></dt></tr></i><div id='EPqv4'><tfoot id='EPqv4'></tfoot><dl id='EPqv4'><fieldset id='EPqv4'></fieldset></dl></div>
              2. <legend id='EPqv4'><style id='EPqv4'><dir id='EPqv4'><q id='EPqv4'></q></dir></style></legend>

                  本文介绍了我们如何在PL SQL中在特定时间后自动删除表行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有下面给出的相同列的拖车表:

                  I have Tow table with Identical Columns Given Below:

                  表 1 工资单:

                  表 2 TEMP_PAYROLLFILE:

                  Table-2 TEMP_PAYROLLFILE:

                  我编写了一个 PL SQL 函数,它从表 PAYROLLFILE 中插入一个重复的行到 TEMP_PAYROLLFILE 并从表 PAYROLLFILE 中删除原始行.所以简而言之,表 TEMP_PAYROLLFILE 为从表 PAYROLLFILE 中删除的数据保留备份.

                  I have written a PL SQL Function, which inserts a duplicate row from Table PAYROLLFILE to TEMP_PAYROLLFILE and remove the original row from Table PAYROLLFILE.So in short, Table TEMP_PAYROLLFILE is keeping a backup for deleted data from Table PAYROLLFILE.

                  这里是PL SQL函数代码:

                  Here is the PL SQL Function Code:

                  FUNCTION Remove_transaction_by_id(employee_id NUMBER)
                  RETURN CLOB
                  AS
                    cnt INT;
                  BEGIN
                      INSERT INTO temp_payrollfile
                      SELECT *
                      FROM   payrollfile
                      WHERE  empid = employee_id;
                  
                      DELETE FROM payrollfile
                      WHERE  empid = employee_id;
                  
                      SELECT Count(*)
                      INTO   cnt
                      FROM   payrollfile;
                  
                      COMMIT;
                  
                      RETURN '<result><status>success</status> <row>'
                             ||cnt
                             || '</row></result>';
                  EXCEPTION
                    WHEN OTHERS THEN
                               RETURN '<result><status>Error</status></result>';
                  END remove_transaction_by_id; 
                  

                  但是,我想做的不止这些,我想从表 TEMP_PAYROLLFILE 在特定时间段结束后自动删除备份行 特定行.我需要触发器吗.我是新手,以前从未做过此类工作.如果有人知道这种技术,那么我将非常感谢您的帮助.如果需要更多详细信息,请告诉我.谢谢

                  However, I want to do more than that, I want to Delete Backup rows Automatically from Table TEMP_PAYROLLFILE after a specific time period is over fort that specific row.Do i need triggers.I am new on that and never done this type of work before.If anyone know this kind of technique, then i would really appreciate your help.please let me know if further details required.Thanks

                  更新:

                  我写了这个作业来清理旧行:它会起作用吗?

                  I have write this job to cleanup old rows: will it work?

                  BEGIN
                  DBMS_SCHEDULER.CREATE_JOB (
                     job_name             => 'oe.REMOVE_TEMP_PAYROLLFILE_JOB',
                     job_type             => 'PLSQL_BLOCK',
                     job_action           => 'BEGIN DBMS_STATS.GATHER_TABLE_STATS('oe',
                                              'TEMP_PAYROLLFILE'); 
                                              delete from TEMP_PAYROLLFILE where RECORDDATE < sysdate-1;
                                              END;',
                     start_date           => '20-JAN-16 1.00.00AM US/Pacific',
                     repeat_interval      => 'FREQ=DAILY', 
                     end_date             => '25-JAN-16 1.00.00AM US/Pacific',
                     enabled              =>  TRUE,
                     comments             => 'Gather table statistics');
                  END;
                  

                  推荐答案

                  您需要的是定期清理工作. 使用 DBMS_SCHEDULER 您可以配置重复执行此操作的作业:

                  What you need here is a periodic cleanup job. Using DBMS_SCHEDULER you can configure a job that does this repeatedly:

                  delete from TEMP_PAYROLLFILE where recorddate < sysdate-60;
                  

                  删除超过 60 天的记录.

                  to delete records that are more than 60 days old.

                  这些是一些关于如何创建预定的工作.如下所示,job_action 部分接受 Pl/SQL 脚本,您可以在其中放置清理逻辑.

                  These are some examples on how to create a scheduled job. As you see below, the job_action sections accepts a Pl/SQL script, in which you can place your cleanup logic.

                  BEGIN
                  DBMS_SCHEDULER.CREATE_JOB (
                     job_name             => 'oe.my_job1',
                     job_type             => 'PLSQL_BLOCK',
                     job_action           => 'BEGIN DBMS_STATS.GATHER_TABLE_STATS(''oe'',
                                              ''sales''); END;',
                     start_date           => '15-JUL-08 1.00.00AM US/Pacific',
                     repeat_interval      => 'FREQ=DAILY', 
                     end_date             => '15-SEP-08 1.00.00AM US/Pacific',
                     enabled              =>  TRUE,
                     comments             => 'Gather table statistics');
                  END;
                  /
                  

                  这篇关于我们如何在PL SQL中在特定时间后自动删除表行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 PL/SQL 过程中,在 HTML 表中包装查询或引用 下一篇:如何在窗口中安排 Oracle DBMS 作业

                  相关文章

                    <bdo id='JNZjr'></bdo><ul id='JNZjr'></ul>
                  <tfoot id='JNZjr'></tfoot>

                    <i id='JNZjr'><tr id='JNZjr'><dt id='JNZjr'><q id='JNZjr'><span id='JNZjr'><b id='JNZjr'><form id='JNZjr'><ins id='JNZjr'></ins><ul id='JNZjr'></ul><sub id='JNZjr'></sub></form><legend id='JNZjr'></legend><bdo id='JNZjr'><pre id='JNZjr'><center id='JNZjr'></center></pre></bdo></b><th id='JNZjr'></th></span></q></dt></tr></i><div id='JNZjr'><tfoot id='JNZjr'></tfoot><dl id='JNZjr'><fieldset id='JNZjr'></fieldset></dl></div>

                    <small id='JNZjr'></small><noframes id='JNZjr'>

                  1. <legend id='JNZjr'><style id='JNZjr'><dir id='JNZjr'><q id='JNZjr'></q></dir></style></legend>