Remove rows older than the number of hours given

Hello

I'm a student of the table that contains the following columns

ID Number (5)
Name varchar2 (20)
Strt_Time timestamp (6)

Strt_time is the timestamp when the individual is inserted in the table.

I need a query to delete all the lines that are inserted before considering the specific number of hours.

For example. If I pass the input as 2 parameter all lines that are inserted before 2 a.m. now should get deleted.

Hello

944160 wrote:
... I need to spend many hours as the query parameter, and I struggle to execute the below query

What front end do you use? How you are and passing the parameter? The example that I gave

REMOVE FROM STU
WHERE STRT_TIME< systimestamp="" -="" numtodsinterval="" (:num_hours,="">

works in SQL * Plus (among others), assuming you have previously set and the value of the variable binding: num_hours in the same session. For example:

VARIABLE  num_hours    NUMBER;
EXEC     :num_hours := 2;

DELETE  FROM STU
WHERE     STRT_TIME < SYSTIMESTAMP - NUMTODSINTERVAL (:num_hours, 'HOUR');

Instead of a link as variable: num_hours, you can use an expression that evaluates to a NUMBER, including


  • SQL * more variable substitution
  • a scalar subquery involving any one or more tables
  • a pacakge PL/SQL variable
  • a function call
  • a combination of the foregoing, by using CASE and/or arithmetic operators, such as + and -.

Tags: Database

Similar Questions

  • Then updates older than the newest one be removed safely?

    original title: I'm removing unnecessary programs from my PC and there are as many old updates MS still displayed in the populous.  Then updates older than the newest one be removed safely?

    When I go into Control Panel, then add/remove programs, there are many old updates ongoing MS.  My question is, can those older newer be removed safely?

    On this issue, see the following web pages:

    http://www.PAGESTART.com/NTUninstall.html>

    http://www3.TELUS.NET/dandemar/spack.htm>

    http://taurarian.MVPs.org/WU_XP/removing_old_windows_updates.htm>

    07/18 / 1106:19:10

  • Delete files older than the time period

    I have a sub (attached) vi which I have short after a period of time checks the files and comapres them against a time constraint. If this time constraint is met the files are deleted or moved. My current Setup uses file vi information to check the path of the folder. I want to delete or copy files after a period of time. In view of the last exit of change on the file information this only checks the date of last modification of the file, and I want that it checks the files in the folder. How can I do this?

    Hi CAEHP

    I finally get it to work. I join all of the finished program. Feel free to use and change around to meet your needs. The finished application to remove or move the files in the specified folders older than the set time. You can also set the frequency with which the application to check the folders.

    Hope this helps

  • Special characters other than the number and the hyphen

    Hi all

    I have a table that has a column named ID. This column contains the employee id, but during the loading of the files in the Tables, some records are contains various special characters. The sould IF contains number and hyphen (-) only. All other characters are special characters.

    I need to write a procedure/function, where I spend that id and check in the table if this ID contains special characters other than the number and the dash and remove it and then check the length of it (say 10).

    It should then resubmit this comment to refer to another ID such as "invalid ID".

    Can someone help me how to write the procedure/function with this feature?
    with t1 as(
    select '12345-2345 ' val from dual
    union
    select '34556- 5627'  from dual
    union
    select ' 56556-5236'  from dual
    union
    select '11111-1111' from dual
    ) select regexp_substr(val,'^[0-9]+-[0-9]+$') FROM t1
    where regexp_substr(val,'^[0-9]+-[0-9]+$') is not null
    
  • My Dell 1014 works on Windows Vista and I want to install Windows XP on it. "I am train to install a version that is older than the version that I already have."

    My Dell 1014 works on Windows Vista and I want to install Windows XP on it. When I insert the XP CD and try to install, the system throws a message saying that I am trying to install a version that is older than the version that I already have. How to solve this problem?

    original title: Windows XP installation

    Hi Ribhu,

    How did you start the Windows XP installation? This is the start of the Windows CD or Windows itself?

    You can try a new installation of Windows XP after formatting the hard drive Vista and check.

    You can consult the following wire link and check if it helps.

    How can I replace Vista with XP?

    Note: The above mentioned thread contains third party links.

    Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.

    Also check out the link:

    How to install or upgrade to Windows XP

  • Windows tells me that I can't install it because the software on the CD is older than the version that I am running.

    I have Win XP Home SP3 and bought an upgrade - Win XP Pro SP1.  Windows tells me that I can't install it because the software on the CD is older than the version that I am running.  They all have two say version 2002.  Am I expected to find an upgrade with SP3?  How does this work?  Thanks for any help.

    http://support.Microsoft.com/kb/292607

    Microsoft Windows XP Home Edition

    Windows XP Professional Retail (full) version
    Windows XP Professional Upgrade Version
    Microsoft Windows XP Home Edition with SP1

    Windows XP Professional with Service Pack 1 retail (full) Version
    Windows XP Professional with Service Pack 1 Upgrade Version
     

    In other words, if Win Home SP3 level and your professional drive upgrade is say SP1, it will not work.

    Win Home should be flush to the SP even the Professional upgrade.

    You could integrate the Win teacher disc with the complete file SP3

    Windows XP Service Pack 3 network installation Package for IT professionals and developers
    (Unique facilities for the PC can use the same file)
    http://www.Microsoft.com/downloads/details.aspx?FamilyId=5B33B5A8-5E76-401F-BE08-1E1555D4F3D4&displaylang=en

  • The InstallScript engine on this machine is older than the version reqired to run this installer. Currently have IScript7.dll (dated from: June 2002). Upgrade Windows Vista to Windows 7.

    The InstallScript engine problem

    The InstallScript engine on this machine is older than the version reqired to run this installer.  Currently have IScript7.dll (dated from: June 2002).  Upgrade Windows Vista to Windows 7.  I tried to install Word Perfect 10 on this machine.

    How to install the latest Version ofISScript . MSI

  • Accounting software Microsoft Error Message: can not connect because the version of the application is older than the data base of the company

    Original title:

    Error message

    I use windows 7 laptop I format. After installation of Microsoft, accounting software and I wanted to backup restored it gives me error massage "can not connect because the version of the application is older than the data base of the company.» Up grade the application. " Eventhough I used the software even before I format the computer laptop and does ' t give me the options to upgrade. Need help.

    This means MS accounting requires the latest updates that have been installed originally creating this accounting database

    Accounting MS was abandoned a few years previously, so updates are not driven by windows/office update

  • Count the number of hours between the dates off holiday/weekend

    Hi all

    I've not worked with dates and was recently asked to create a report where I am looking for the number of hours between two dates only count business days.

    So for example I have given as follows

    Created on 2011-03-30 15:00
    Treaty of 2011-03-30 15:03:46
    Filled 2011-04-01 17:25:02
    Posted 2011-04-01 17:45

    For a total of looking for the CREATION and dates

    50 hours and 45 minutes

    IM also trying to exclude weekends and holidays, I read around and was able to also find an array of dates where I main date, the HOLIDAY_IND column, and the column WEEKDAY_IND

    If the calendar table I have looks like

    CALENDER_DATE HOLIDAY_IND WEEKDAY_IND
    2011-03-31 YY
    2011-04-01 N Y
    2011-04-02 N N

    IM really very puzzled to know where to start

    I thought I'd try to write with PL/SQL, but I don't have access of the user to create procedures/functions, so looks like right up to SQL

    Any help is appreciated!

    Hello

    Depeneding on your data and your needs, you can do something like this:

    SELECT     created_DATE,
    ,     mailed_date
    ,     24 * ( (mailed_date - created_date)
              - (
                SELECT  COUNT (*)
                FROM        table_o_dates
                WHERE    main_date > created_date
                AND        main_date < TRUNC (mailed_date)
                AND        (   holiday_ind = 'Y'
                         OR  weekday_ind = 'N'
                      )
              )
               )               AS hours_between
    FROM     table_x
    ;
    

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.

    What do you do if created_date or mailed_date is not a working day? Examples in you data and results.

  • In subtracting two stamps, and indicating the number of hours between them.

    Hello people,

    I have two tables, each of them has a timestamp column. I want to do a select with a join that will show a column with the number of hours between the two times.

    (I added the columns as timestamp (0) since I have no need for decimals)

    Here's what I have:

    a table name: conc_test

    table information:

    P_DATE---JOB_NO---MIX---POUR_NO---AMB_T---CONC_T--SLUMP---AIR---DENSITY---CYL_CAST_TIME
    09-MAR-10---9-12-796---80---100309A---2.5---16---135---2.5---2501---09-MAR-10 AM 10.00.00

    the two table name: rls_break

    Info table two:

    JOB_NO---POUR_NO---CYL_ID---SPEC_STR---STR---MIX---BREAK_D_T
    9-12-796---100309A---100309A1---20---27---80---10-MAR-10 07.15.00 AM

    (I put the - between columns, so it would be more readable to reading the forum, FYI)

    That's what I was trying to do:

    Select
    rls_break.cyl_id "Cylinder ID",
    rls_break. Mix "Mix."
    trunc(rls_break.break_d_t-conc_test.cyl_cast_time) 'Age. '
    rls_break.spec_str '' appropriate Force. ''
    rls_break. Str "Specimen Strength".
    from rls_break inner join conc_test on rls_break.pour_no = conc_test.pour_no
    where pour_no = '100309A ';.


    I want the column 'Age' to display the total number of hours between (cyl_cast_time of the conc_test column) cast time and pause time (column break_d_t of rls_break)


    I thank the of for any help.
    ...
    extract(day from rls_break.break_d_t-conc_test.cyl_cast_time)*24
     + extract(hour from rls_break.break_d_t-conc_test.cyl_cast_time)
     + extract(minute from rls_break.break_d_t-conc_test.cyl_cast_time)/60
     + extract(second from rls_break.break_d_t-conc_test.cyl_cast_time)/(60*60) "Age",
    ....
    
  • Remove values lower than the desired increment

    Hello

    When you perform a simulation of multi-body with a step size fix that I receive some additional values smaller than the normal increment in output data or values are duplicated. The time channel looks like:

    0

    0.0002738

    0.001

    0.002

    0.002

    0.003

    0.004

    ....

    I think that with a simple script I can remove the extra valuues (in this case 0.0002738, 0.002).

    E offer this code, but it does not work:

    Hello Fischerg,

    I would like to know how it works:

    Option Explicit
    Dim timechannel, CLength CNumber, dBase, limit, K, CurrValue, Epsilon, Delta

    timechannel = "[1] / TIME."
    CLength = Val (ChnPropGet (timechannel, 'length'))
    CNumber = NOC (timechannel)

    Epsilon = 0.00001
    Limit = 0.001 - Epsilon

    dBase = CHDx(1,CNumber)
    For K = 2-CLength
    CurrValue = CHDx (K, CNumber)
    Delta = CurrValue-dBase
    "Compare using the value of the Epsilon. Compare float numbers
    "with '=' does not always work
    If (Delta< limit="" )="" then="">
    CHDx (K, CNumber) = NULL
    On the other
    "Set new base
    CurrValue = dBase
    End If
    Next
    Call ChnCharacter (timechannel)
    'Delete tagged values. If there are more channels in parallel to the string "TIME."
    "those who can be adjusted with the same call. See the online help for ChnNovHandle for more details
    Call ChnNovHandle(timechannel,"","Delete","X",1,1,0)

  • In Windows Live Mail, how to attached photos to come in full size rather than the number of pixels reduce serverly who normally comes?

    I am frustrated by the size of the images that come in attachments to Windows Live.  The number of pixels is reduced so violently that the photos cannot be saved or extended.  How can I get full screen?

    Are you referring to how the photo looks like if you view
    it in the body of the e-mail message?

    If you save the picture in a folder on your hard drive
    It is further reduced? (File / save attachments)

  • You can remove some microsoft updates that are older than the recent updates that are being installed

    I need to know if I can remove old updates from microsoft after upgrades

    Thanks for any help I receive

    E-mail address is removed from the privacy *.

    NO, you cannot uninstall updates if the operating system has been updated because it would mean that another edition of Windows is now installed.

    MowGreen
    Expert in Windows IT Pro - consumer safety

    * - 343-* FDNY
    NEVER FORGOTTEN

  • I have 50 40M each places.sqlite files. Can I remove the "old" and firefox stop recording of older than the most recent files, while retaining history?

    Thank you.

    It's not bad.

    These files are all in the same Firefox profile folder?

    They have the name of places.sqlite or is there something added?

    You only need one of them and this is the file that Firefox currently uses to store the history and bookmarks.

    You can check for problems with the database places.sqlite file in the Firefox profile folder.

  • The engine script installation on this machine is older than the version required... »

    When I do rightclip on window xp scren RISEUP POPUP WINDOW INSTALLATION (ATI CATALYST CONTROL CENTER).
    THEN, (happy install the latest version of ISScript.msi) RISEUP WINDOW POPUP. The latest version of ISScript.msi pleasure
    App.

    Hello

    Run the checker system files on the computer. Link, we can see: Description of Windows XP and Windows Server 2003 System File Checker (Sfc.exe): http://support.microsoft.com/kb/310747

    Note that: if he asks you the service pack CD, follow these steps from the link: you are prompted to insert a Windows XP SP2 CD when you try to run the tool on a Windows XP SP2 computer system File Checker: http://support.microsoft.com/kb/900910 (valid for Service pack 3)

Maybe you are looking for