executes a select statement, each minute for half an hour

Hi all

I want to run a SELECT statement on a table every minute for half an hour.

Something like this:

Begin

Do all the 1 minute for 30 Min

Select col1, col2 from mytable

End

I thought about PL/SQL loop. But no matter what example with timekeeping.

I don't care?

Thank you and best regards.

Hello

As John said, you can use DBMS_SCHEDULER for this. That being said, you just can't run a query and do nothing with its result. You must do something with it.

Here is an example showing how to create a task that runs every minute for a total of 30 min

BEGIN

DBMS_SCHEDULER. Create_Job (job_name-online 'MY_JOB',

job_type-online "PLSQL_BLOCK."

job_action => ' DECLARE val1 number; val2 number; BEGIN SELECT 1, 2 INTO val1, val2 FROM DUAL; END;',

start_date => SYSDATE,

End_date => SYSDATE + 30 /(24*60),

repeat_interval => ' FREQ = MINUTELY ",

auto_drop => TRUE,

enabled-TRUE online

);

END;

/

It will start immediately and end 30 minutes later (it will be automatically abandoned). As you can see, the result of the query is placed in the variables. Thus, this work is useless.

Tags: Database

Similar Questions

  • Download stopped at 60% and has been there for half an hour.

    I am trying to download my old CS5.5 Design Premium package, but he stopped at 60%. I restarted my computer, but it stopped again at 60% for and has been there for half an hour. What is going on?

    Check your (win) Task Manager or activity (mac) for a suspended adobe monitor process (like adobe that helps) and end it.

    failure help, put an end to the installation, uninstall anything cs 5.5 which is installed in clean by the use of the Adobe Creative Cloud cleaning tool to solve installation problems, restart your computer and run the Setup again.

    If this fails, what is your operating system?

  • How to use the select statement in loop for

    Hi all

    My question is can I use a select statement in for loop like as follows.

    for the key in the selection of one_table key.

    When I use this am getting an error as found select invalid I ID

    How to select a statement use in loop for

    Please suggest me.

    Thank you
    Sree

    Hello

    You can use code below

    For key in (select button from table_a)
    loop
    If key.key = 1 then
    -insert statement
    on the other
    -Select statement
    end loop;

    Thank you
    Naveen.

  • create view force executes a select statement

    I have the following script, which is called during the installation as a user the_owner with @Code\Views\VW_TODO. from sqlplus
    Prompt View VW_TODO;
    
    CREATE OR REPLACE FORCE VIEW the_owner.VW_TODO (THE_ID, COUNT) AS
    --+============================================================================
    -- Project Code:  
    -- Project Name:  
    -- Module Type:   View
    -- Change History:
    --
    -- Name                 Version  Date        Comment
    --
    -- =============================================================================
    
         SELECT   the_id, COUNT ( * ) COUNT
           FROM   the_owner.todo_list
          WHERE   completed IS NULL
       GROUP BY   the_id;
    /
    I get the following output in my journal...
    View VW_TODO
    
    no rows selected
    
    
    no rows selected
    I have tried with and without the trailing slash and the final semicolon... no work...
    When I run SQL Developer, it creates the view.
    Can someone tell me why?

    Thanks in advance,
    Gus...

    Gus,

    It seems that you have a completely empty line in your CREATE VIEW statement. This will cause the statement fails. If please remove this line and try again.

    Andy

  • request to execute the select statement conditionally

    Desire: when a variable is null then run a full report, if two variables are not null and then run the report with the specified range
    I have the following query, but kept getting an error sql invliad. Can you help me?

    -------------------
    IF (: P1_START_DATE IS NULL or: P1_END_DATE IS NULL)
    THEN SELECT ename, empno, mgr, hiredate from emp;
    ELSE IF (: P1_START_DATE IS NOT NULL and: P1_END_DATE IS NOT NULL)
    Select ename, empno, mgr, hiredate from emp where hiredate between: P1_START_DATE and: P1_END_DATE;
    end if;



    Tai

    Go only;

    select empno, ename, job, mgr, hiredate
    from emp
    where (:p1_start_date is null or :p1_end_date is null)
    or (:p1_start_date is not null and :p1_end_date is not null and
          hiredate between :p1_start_date and :p1_end_date);
    
  • I want to upgrade my Safari v, but don't want to go to the Capitan - been on the website of apple for half an hour, how do I do this? Any suggestions?

    I run 10.7.5 and want to update my browser safari only, do not go to Capitan. Find a Mountain Lion or Yosemite upgrade in the apple website? I watched for an hour? And Yes, I know I should have kept with upgrade... but don't want to go to Capitan, as my book air is very low.

    Mountain Lion can be purchased on the Apple Online Store. If you have already not Mavericks or Yosemite from the Mac App Store, go into a physical Apple store and ask the version you want.

    It is not possible to update Safari past 6.1.6 on Lion and 6.2.8 on Mountain Lion.

    (139064)

  • I was put on hold with customer service for half an hour only to be directed on the forums. Wow. My license key for Windows CS6 has suddenly stop working for no reason and now considers all my programs for free trials and refuses to recognize the key

    Suddenly, she considers the invalid key in spite of owning for almost 3 years. Anything I can do to make it work again?

    Hello

    My apologies for the inconvenience, please see the following links:

    Invalid serial number error

    Warning: "Adobe software real failure of Validation...". » | Windows

    Failure audit download or installation. CS6

    Let us know if that helps.

    Kind regards

    Bani

  • Create table as select statement (ETG) takes a long time.

    Hi all

    One of my procedure launched a table create as select statement each month.
    Usually it ends in 20 minutes. for 6172063 records and 1 hour in 13699067.
    But this time it never even takes to 38076 records.
    When I checked everything he does is the CPU usage. No e/s.
    I did a count (*) using the query, it has brought very good results.
    BUT guard going on DEC.
    I use Oracle 10.2.0.4.
    temp_ip of the main table has 38076
    table nhs_opcs_hier has 26769 records.
    and table nhs_icd10_hier 49551 records.
    -------------------
    Query is:
    create the table analytic_hes.temp_ip_hier as
    Select b.*, (select nvl (max (hierarchy), 0))
    of ref_hd.nhs_opcs_hier one
    where fiscal_year = b.hd_spell_fiscal_year
    and a.code in
    (primary_PROCEDURE, secondary_procedure_1, secondary_procedure_2,
    secondary_procedure_3, secondary_procedure_4, secondary_procedure_5,
    secondary_procedure_6, secondary_procedure_7, secondary_procedure_8,
    secondary_procedure_9, secondary_procedure_10,
    secondary_procedure_11, secondary_procedure_12)) as hd_procedure_hierarchy,
    (select nvl (max (hierarchy), 0) for ref_hd.nhs_icd10_hier one)
    where fiscal_year = b.hd_spell_fiscal_year
    and a.code in
    (primary_diagnosis, secondary_diagnosis_1,
    secondary_diagnosis_2, secondary_diagnosis_3,
    secondary_diagnosis_4, secondary_diagnosis_5,
    secondary_diagnosis_6, secondary_diagnosis_7,
    secondary_diagnosis_8, secondary_diagnosis_9,
    secondary_diagnosis_10, secondary_diagnosis_11,
    secondary_diagnosis_12, secondary_diagnosis_13,
    secondary_diagnosis_14)) as hd_diagnosis_hierarchy
    of analytic_hes.temp_ip b
    -----------------

    Any help would be greatly appreciated

    Hello

    It is a bit of a wild card, I think because it will require 14 scans to fill the table temp_ip to unpivot codes diagnostic and procedure, so this lilkely things are moving slower than the original. However, as it is a temporary table, I guess you could have some control over its structure, or at least be able to dismiss it and try something else. If you are able to change the structure of this table, you could make the application much simpler and probably much faster. I think that you need a list of codes of procedure for the year and a list of diagnosis for fiscal codes. I do this through the large list of UNION all THE INSTRUCTIONS, but you can have a more efficient way to do according to the base tables you are people temp_ip of. In any case, it's here (as far as I can tell this will do the same job)

    WITH codes AS
    (   SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            primary_PROCEDURE       procedure_code,
            primary_diagnosis       diagnosis_code,
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_1    procedure_code,
            secondary_diagnosis_1    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_2    procedure_code ,
            secondary_diagnosis_2    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_3    procedure_code,
            secondary_diagnosis_3    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_4    procedure_code,
            secondary_diagnosis_4    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_5    procedure_code,
            secondary_diagnosis_5    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_6    procedure_code,
            secondary_diagnosis_6    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_7    procedure_code,
            secondary_diagnosis_7    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_8    procedure_code,
            secondary_diagnosis_8    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_9    procedure_code,
            secondary_diagnosis_9    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_10  procedure_code,
            secondary_diagnosis_10    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_11  procedure_code,
            secondary_diagnosis_11    diagnosis_code
        FROM
            temp_ip
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_12  procedure_code,
            secondary_diagnosis_12    diagnosis_code
        FROM
            temp_ip
    ), hd_procedure_hierarchy AS
    (   SELECT
            NVL (MAX (a.hierarchy), 0) hd_procedure_hierarchy,
            a.fiscal_year
        FROM
            ref_hd.nhs_opcs_hier a,
            codes pc
        WHERE
            a.fiscal_year = pc.hd_spell_fiscal_year
        AND
            a.code = pc.procedure_code
        GROUP BY
            a.fiscal_year
    ),hd_diagnosis_hierarchy AS
    (   SELECT
            NVL (MAX (a.hierarchy), 0) hd_diagnosis_hierarchy,
            a.fiscal_year
        FROM
            ref_hd.nhs_icd10_hier a,
            codes pc
        WHERE
            a.fiscal_year = pc.hd_spell_fiscal_year
        AND
            a.code = pc.diagnosis_code
        GROUP BY
            a.fiscal_year
    )
    SELECT b.*, a.hd_procedure_hierarchy, c.hd_diagnosis_hierarchy
      FROM analytic_hes.temp_ip b,
           LEFT OUTER JOIN hd_procedure_hierarchy a
              ON (a.fiscal_year = b.hd_spell_fiscal_year)
           LEFT OUTER JOIN hd_diagnosis_hierarchy c
              ON (c.fiscal_year = b.hd_spell_fiscal_year)
    

    HTH

    David

  • JDBC PreparedStatement gives null after the execution of a valid SELECT statement

    Hello

    I have the following code:
        public static String GetJobLogLocation(Connection connection, int jobId) throws SQLException
        {
            String sqlstr = "SELECT LOGFILE_NAME FROM apps.fnd_concurrent_requests WHERE REQUEST_ID = ?";
            PreparedStatement prest = connection.prepareStatement(sqlstr);
            prest.setInt(1, jobId);
            ResultSet rs1 = prest.executeQuery();
            String rv = null;
            if (rs1.next())
            {
                rv = rs1.getString(1);
                System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + rv);
            }
            rs1.close();
            prest.close();
            return rv;
        }
    As you can see, this function executes a select statement. Before I continue, let me first say that executing the exact same statement in PL/SQL Developer (external program) gives correct/expected results. In addition, run this on my Windows gives correct results environment. I seem to have this problem only on my Unix (SunOS) environment.

    in any case, I get out of this function (running against my Unix environment, of course):

    + > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > + null

    The thing is, it doesn't error out, which means that the result set contains a string, but the string is returned to me with the null value, even if there is a real valid result (that is, in this case, a path).

    Someone has an idea, what happens? I tried to use ojdbc6.jar AND ojdbc14.jar is, with the same results. I just don't understand...

    Thank you.

    Published by: 964530 on 4 January 2013 14:31

    Published by: EJP on 01/07/2013-17:48: added {noformat}
    {noformat} tags and removed your bizarre bold formatting. Please do this properly in future.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

    ASCI says:
    I'm glad that this is a not prove to be a stupid question. At least I'm feeling a little justified due to this fact.

    There is no stupid question...; (o)

    So what remains is: your selection is too early. Can join after insertion, update to each line to trigger the table that loggs insert/update timestamp and the contents of the LOGFIILE_NAME field?

    Good bye
    DPT

  • Get the types of columns in a select statement

    Hello

    Is there a way to get the types of columns that results in a select statement?

    For example to force an analysis on this topic and then look for the types of columns resulting in the view v$?

    Best regards

    Klaus Mogensen

    declare
      c       number;
      d       number;
      col_cnt integer;
      rec_tab dbms_sql.desc_tab;
      col_num number;
    begin
      c := dbms_sql.open_cursor;
      dbms_sql.parse(c, 'select dummy, 33 x, sysdate now from dual', dbms_sql.native);
      dbms_sql.describe_columns(c, col_cnt, rec_tab);
      col_num := rec_tab.first;
      while col_num is not null
      loop
        dbms_output.put_line( rec_tab(col_num).col_name || ' ' ||
                              case rec_tab(col_num).col_type
                                when 1 then 'varchar2'
                                when 2 then 'number'
                                when 12 then 'date'
                                else '???? ' || rec_tab(col_num).col_type
                              end
                            );
        col_num := rec_tab.next(col_num);
      end loop;
      dbms_sql.close_cursor(c);
    end;
    /
    DUMMY varchar2
    X number
    NOW date
    
  • Update a field using a select statement?

    Hello
    I guess it's pretty easy, but I do not understand.
    I have 2 tables REQUEST and NOBODY and I want to update

    UPDATE REQUEST SET SysKD = (SELECT DISTINCT PERSON. SysPERSON OF PERSON WHERE PERSON. SysVM = REQUEST. SysVK PER PERSON. SysVM > 0) WHERE REQUEST. SysLS IN (11,12).

    This book error "subquery returns multiple rows. I assume that due to the fact that I have more than one record in REQUEST which fullfills REQUEST. SysLS IN (11,12).
    NO ONE. SysVM > 0 is necessary because they are in PERSON and REQUEST with ANYONE. SysVM = 0 and REQUEST. SysVK = 0 (where does not REQUEST.) SysLS is 11 or 12, they all REQUEST. SysVK > 0).

    I have no idea how to get a single returnvalue out of the select statement.

    Thanks for help
    Concerning
    Carsten

    Hi CarstenDD,

    In the script you

    SELECT DISTINCT PERSON.SYSPERSON) FROM PERSON
      WHERE PERSON.SYSVM = ANTRAG.SYSVK
        AND PERSON.SYSVM > 0
    

    return of two or more lines, using subquery on implementation day you can use only the single row function.

    You can modify your script

    UPDATE ANTRAG SET SYSKD =
    (SELECT MAX(PERSON.SYSPERSON) FROM PERSON
      WHERE PERSON.SYSVM = ANTRAG.SYSVK
        AND PERSON.SYSVM > 0)
     WHERE ANTRAG.SysLS IN (11,12);
    

    then ty this please

  • Laptop gets really hot after half an hour and stops

    hope you can help me, when I have my laptop for half an hour, its starting to get really hot then stops, you don't what I please.

    The main fan in the unit has stopped working.

    You have two choices...

    1. Have it repaired by a competent technician
    2. Buy a cooler really good temporary basis...

    A really good cooler base... The X of Coolermaster series SLIM model. He works for a Toshiba laptop whjich has the same problem you have...

  • 'Your order is processed' taking half an hour! What should do?

    I have tried to treat my creative cloud of the student for half an hour and he has not yet processed.

    If you are still experiencing a problem, use a browser that allows popups and cookies, contact adobe for hourly pst by clicking here and, when support available, click on "still need help," http://helpx.adobe.com/x-productkb/global/service-ccm.html

  • validation for each 1,000 records to be inserted in the select statement

    Hi, I have the following INSERTION in the SELECT statement.
    The SELECT statement (who joined) data fo about 6 crores. I need to insert this data into another table.

    Please suggest me the best way to do it.
    I use the INSERT in the SELECT statement, but I want to use the statement commit for each 1,000 records.

    How can I do this...
    insert into emp_dept_master 
     select e.ename ,d.dname ,e.empno ,e.empno ,e.sal 
       from emp e , dept d
      where e.deptno = d.deptno       ------ how to use commit for every 1000 records .
    Thank you

    Method 4 is the best

    You could combine method 3 and 1 (without dynamic SQL)

    Method 2 is the less optimal solution from the list.

  • SQL - last selection query save values for each date in term

    Hello

    Can anyone help me please with my problem.

    I'm trying to get the last balance recorded for each day of specific box (1 or 2) in a given period of days of the database ms access using ADOTool.

    I'm trying to get this information with SQL query but so far without success.

    My table looks like this:

    Name of the table: TestTable

    Date         Time      Location  Box  Balance
    20.10.2014.  06:00:00     1       1    345
    20.10.2014.  12:00:00     1       1    7356
    20.10.2014.  18:45:00     1       1    5678
    20.10.2014.  23:54:00     1       1    9845
    20.10.2014.  06:00:02     1       2    35
    20.10.2014.  12:00:04     1       2    756
    20.10.2014.  18:45:06     1       2    578
    20.10.2014.  23:54:10     1       2    845
    21.10.2014.  06:00:00     1       1    34
    21.10.2014.  12:05:03     1       1    5789
    21.10.2014.  15:00:34     1       1    1237
    21.10.2014.  06:00:00     1       2    374
    21.10.2014.  12:05:03     1       2    54789
    21.10.2014.  15:00:34     1       2    13237
    22.10.2014.  06:00:00     1       1    8562
    22.10.2014.  10:00:00     1       1    1234
    22.10.2014.  17:03:45     1       1    3415
    22.10.2014.  22:00:00     1       1    6742
    22.10.2014.  06:00:05     1       2    562
    22.10.2014.  10:00:16     1       2    123
    22.10.2014.  17:03:50     1       2    415
    22.10.2014.  22:00:10     1       2    642
    23.10.2014.  06:00:00     1       1    9876
    23.10.2014.  09:13:00     1       1    223
    23.10.2014.  13:50:17     1       1    7768
    23.10.2014.  19:47:40     1       1    3456
    23.10.2014.  21:30:00     1       1    789
    23.10.2014.  23:57:12     1       1    25
    23.10.2014.  06:00:07     1       2    976
    23.10.2014.  09:13:45     1       2    223
    23.10.2014.  13:50:40     1       2    78
    23.10.2014.  19:47:55     1       2    346
    23.10.2014.  21:30:03     1       2    89
    23.10.2014.  23:57:18     1       2    25
    24.10.2014.  06:00:55     1       1    346
    24.10.2014.  12:30:22     1       1    8329
    24.10.2014.  23:50:19     1       1    2225
    24.10.2014.  06:01:00     1       2    3546
    24.10.2014.  12:30:26     1       2    89
    24.10.2014.  23:51:10     1       2    25
    ...
    

    Let's say that the period is 21.10.2014. -23.10.2014. and I want to get the last balance recorded for zone 1. for each day. The result should look like this:

    Date         Time      Location  Box  Balance
    21.10.2014.  15:00:34     1       1    1237
    22.10.2014.  22:00:00     1       1    6742
    23.10.2014.  23:57:12     1       1    25
    

    So far, I managed to write a query that gives me the balance so that a SINGLE date (date more time in the table), but I need balance for EACH date in a specific period.

    My incorrect code (has not managed to implement "BETWEEN" for the dates...):

    SELECT TestTable.[Date], TestTable.[Time], TestTable.[Location], TestTable.[Box], TestTable.[Balance]
    FROM TestTable
    WHERE Time=(SELECT MAX(Time)
    FROM TestTable
    WHERE Location=1 AND Box=1 );
    

    TNX!

    NP

    Here's the correct query (just copy - paste):

    SELECT
    T1.Date,
    T1.Time,
    T1.Location,
    T1.Box,
    T1.Balance
    FROM TestTable T1
    INNER JOIN (
    SELECT
    MAX(Time) AS Max_Time
    FROM TestTable
    WHERE Location=1 AND Box=1 AND Date BETWEEN #10/27/2014# AND #11/1/2014#
    GROUP BY Date) T2
    ON T1.Time=T2.Max_Time;
    

    The problem is in the SELECTION within the INNER JOIN. This SELECTION selects the time max for each date, because we want this and then the entire table, we choose filelds we want, but now we have only fields with the time max.

    Here is a really good explanation of INNER JOIN if anyone is interested--> JOINT INTERNAL

    Peace!

Maybe you are looking for