Using cursors for long-running processes

Hi all

I know I could probably just google it or run tests, but if it is not an imposition, I just want to hear the responses with a "personal touch."

I write a PL/SQL process that performs the tasks against the rows in a table that can end up having about a quarter of 1 million rows. Each line will take about one second to process, so we don't talk about something that's going to run everything straight for about 60 hours. There is a very high probability that the lines corresponding to the criteria for cons who should run the process will change during these 60 hours. In as few words as possible, the process runs on all rows in the table with a status 'active', and I also gave users a 'priority' indicator that is designed to enable them to identify which objects should run as soon as POSSIBLE against those who can wait. New active lines could be added, the lines that were active at the time of execution could be removed during transformation gets their etc..

Is a slider, the wrong solution for this type of architecture? I thought I should do the following:

1. Add a flag "transformed" in the table I am crossing
2. clear a beginning of a journey
3. use a loop where each time through the loop I interrogate the first line matching the criteria which the transformed flag is NOT set
4 treat
5. set his transformed Pavilion
6. go back to 3 and exit the loop when no objects match the criteria, and not have the indicator defined

Moreover, in the future phases of the project probably add us servers to the architecture and/or rewrite the code to take advantage of the multithreading and partitioning table to ensure that it runs overnight. We don't have time or the budget right now. Users understand that their data cannot be ready available and have need to look for the transformed flag know if yes or not it's been updated.

So knowing that, for now, we have something that is going to run for 60 hours, is my approach better than just using a slider? Is there a better option I think not?

Thank you
DTXCF

tennismanjoe wrote:

In fact, for each row in the table, I have to go around and ask OTHER tables and perform calculations and whatnot and then update the results in the current line.

Fortunately SQL update syntax lets you reference other tables and perform calculations.

The fourth example of manual illustrates this.

http://download.Oracle.com/docs/CD/B28359_01/server.111/b28286/statements_10008.htm#i2189756

Tags: Database

Similar Questions

  • Disable the input from the user during the long running process

    Hello

    I use JDev 11.1.1.4.0.

    When the user clicks on the 'save' button, I have to call a procedure stored prior to validation. This procedure takes about a minute to complete the race. My problem is, while the process is running, the user can click or change the values in the page. Is there a way to lock the page until the process is complete and ok to return control over the user?

    Thank you

    Bones Jones

    Another example:
    http://www.gebs.ro/blog/Oracle/Oracle-ADF-glass-pane-for-blocking-user-input-in-case-of-long-running-tasks/

    Thank you
    Nini

  • flashing cursor for long hours after the installation of finished windows7

    I have an office foxconn a74ml-k amd x 2 cpu, 250 GB hard drive, 1 GB of ram, I launched format and installed windows 7, installation is going well, completed, after restart only blinks for long hours, I have the cd drive as a secondary port to SATA master hard drive as 3rd, I only have one ide connector I tried my best, always the cursor blinks, I connected the drive hard ide also, same result, mobo is foxconn a74ml-k, help me please

    drive cd and hard drive are connected in SATA

    I removed the cd player and tried only with hard disk, always the cursor blinks

    then I removed full sata only hdd connected in IDE slot, installed as usual, always cursor blinks

    I format the drive hard zero level, completely erase

    also changed the ram

    other information, I treid with a hard drive install windows vista 32 bit, same result

    Windows 7 32 bit, 64 bit I tried the same result, mind blowing

    What would be the problem! Please help me,

    Thanks for the reply, finally I fixed it, after a serious analysis, the problem was, front usb port and card reader, I deleted and erased cmos, boot through hard drive, it came nicely, now its working perfect!

  • How to use the structures of the event for long-running tasks

    I created a state machine that scans a cluster of Boolean controls in a State of 'home '. Most of the States run a Subvi or two in ~ 100 ms or less.

    However, a State run for 10 seconds.

    The code works but the user interface is limited because the controls are outside the cluster because they provide inputs to the structure of State machine case but do not cause changes in the State. In other words, I all orders cluster stacked vertically on one side of the main panel and do not have the flexibility to move the controls to the more intuitive positions on the Panel.

    My question: How can I convert this code in a structure of the event and keep this long term 'event' and prevent that the operator by clicking another button event during the execution of this event?

    Thank you

    You say you have controls outside of your main code... You should really put these inside and manipulate them in a State of your state machine is initialized. This allows you to make changes to the code easier and limits of line entering your outside loop.

    You can do different things to lock the user.

    You can disable specific controls so that they can't be clicked or edited.

    You can use the palette of the mouse to define the busy cursor and disabled again once finished, I do this a lot during treatment when my code something loads the user just clicked.

    One of my favorites is to set a Boolean value in your data that passes through you event titled structure "disable mouse." When the value is True, a mouse down event will effectively reject the event, clicking on disable. I also added an event mouse move where if the bool disable the mouse is set to True, it moves an indicator of string with the mouse by telling the user why it is disabled.

    If you want more specific suggestions, I suggest to post an excerpt of your code, or attach your screws, so that we can better help you.

  • Long running process - the comments of users

    Hello!

    Do you know a solution on how to reviews the status of some time to the user process running? ProgressBar or something else. Would be the ability to stop the slow operation (page) of the process as well.

    A.

    Hello

    Apex provide the API APEX_PLSQL_JOB
    http://download.Oracle.com/docs/CD/E17556_01/doc/apirefs.40/e15519/apex_plsql_job.htm#BGBFGBIB

    And you can also use DBMS_SCHEDULER
    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14258/d_sched.htm

    Kind regards
    Jari

  • UDM for long running sql

    Hello

    I intend to use enterprise grid control manager to create a UDM for the following sql which alert me for the sql that runs to learn more then an hour for all the basics of ideas on how to do this
    SELECT 
            substr(swn.sql_text,40),
            ||'SQL is Running on Instance ' ||s.inst_id || 'Since '|| ROUND(sl.elapsed_seconds/60) elapsed_mins,       
    FROM   gv$session_longops sl,
    gv$session s ,
    gv$sql swn
    WHERE  s.sid     = sl.sid
    AND    s.inst_id = sl.inst_id
    AND    s.serial# = sl.serial#
    AND    s.inst_id = swn.inst_id
    AND    s.sql_address = swn.address
    AND    s.sql_hash_value = swn.hash_value
    AND    sl.sofar  <> sl.totalwork
    AND    sl.totalwork <> 0
    AND    round((sl.elapsed_seconds)/60,0) > 60
    order by 7
    Published by: user9243284 on June 7, 2010 03:48

    Could you tell us please my useful answer?
    Thank you

  • long-term process and using animation

    Hello

    I want to show an animation until I download xml data.

    Once the download is complete, animation showing should stop.

    The animation should run only the length of time that takes the data xml downlaod.

    Help, please.

    Thanks in adavnce.

    Hello

    Finally, the code below solved my purpose

         // the inner class thread to download updates and synchronize two animations
        private class XMLDownloadingThread extends Thread{
    
    public void run() {
        synchronized (Application.getEventLock()) {
    
         //add loading(animation 01) manager
             addSpinner(_ESHFManager, _loadingProgressAnimationField);
    
         //add manager to screen
          add(_ESHFManager);
        //ensure repaint view
        invalidate();
    
        }// end of syschronized block
    
        try {
        // doing XML downloading here
        Thread.sleep(15*1000);// just for demo a long running process
        } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
                    }
    
    // ready for show animation two
    synchronized (Application.getEventLock()) {
    
    //remove loading (Animation 01)
                        _ESHFManager.delete(_loadingProgressAnimationField);
    
    //intantiate second animation
    
    _rotatingLogoProgressAnimationField=new ProgressAnimationField( Bitmap.getBitmapResource( "test/splashscreen_480_360.png" ), 10, Field.FIELD_HCENTER );
    
    //add second animation to manager
        addSpinner(_ESHFManager,  _rotatingLogoProgressAnimationField);
    
        //repaint view
        invalidate();
    
        }// end of 2nd synchronized block
    
                }// end of run method
            }// end of inner class
    

    the constructor in

           // start xml downlaoding of upadates with synchronize to animation
              new XMLDownloadingThread().start();
    

    That's all

  • CURSOR for loops or an associative array

    I just want to know the advantages and disadvantages of the CURSOR for loops. As a general rule, what guys do you prefer: associative array with CURSOR for loops?


    If you use the CURSOR for loop, is it not difficult to debug?

    PL/SQL Developer, I do not see what values are stored in the CURSOR for loop (in SP master_proc below) as
    There are no variables to watch. Not sure if the TOAD can show these values

    If I had used an associative array (master_proc2 below), I can see the values stored in the table by clicking on "show Collection"variable in PL/SQL developer.




    create table emp2 as select * from emp;
    
    
    create or replace procedure my_proc(p_empno in number)
    as
    begin
    update emp2 set sal=sal+100 where empno=p_empno;
    end;
    /
    
    --Using CURSOR FOR loop
    
    create or replace procedure master_proc
    as
    begin
         for rec in (select empno from emp2 where empno>7700)
         loop
              my_proc (rec.empno);
         end loop;
    end;
    /
    
    -- Using Associative arrays
    create or replace procedure master_proc2
    as
    type v_empno_type is table of number index by pls_integer;
    v_empno v_empno_type;
    
    begin
    select empno bulk collect into v_empno from emp2 where empno>7700;
    
    for i in 1..v_empno.count
     loop
        my_proc (v_empno(i));
     end loop;
    end;
    /

    VitaminD wrote:
    Thank you Tubby. If you are faced with a situation where you MUST use a loop. Then you would go to associative arrays rather than CURSOR FOR loops. Right?

    Doesn't happen too often, but if/when then I would do as I said in my first post. Use the transformation, the collection table in BULK and FORALLs.

    If we use your example posted, I would NOT spend a single table (in a loop mode) value I would be transmitted in the OVERALL picture and treat it with FORALL.

    So, I would still use neither of the approaches that you mentioned.

  • Cursor object and cursor for loop back

    I am beginner in Oracle and the serious database of programming in general. Right now I'm studying the sliders. I more or less understand how works when the cursor returns a record, but I can't understand why this does not work when the cursor return object and I use "cursor for loop.

    Here's the test code:

    CREATE or REPLACE TYPE typ_Test () AS OBJECT
    text VARCHAR2 (50)
    );

    CREATE TABLE t_Test to typ_Test;

    INSERT INTO t_Test VALUES (typ_Test('111'));
    INSERT INTO t_Test VALUES (typ_Test('222'));

    -work, simple loop
    DECLARE
    CURSOR cur IS SELECT VALUE (o) FROM t_Test o;
    typ_Test obj;
    BEGIN
    Heart OPEN;
    LOOP
    Fetch cur INTO obj;
    OUTPUT WHEN heart % NOTFOUND;
    dbms_output.put_line (obj. (Text);
    END LOOP;
    CLOSE cur;
    END;



    -doesn't work, cursor for loop
    DECLARE
    CURSOR cur IS SELECT VALUE (o) FROM t_Test o;
    BEGIN
    FOR news of obj IN LOOP
    dbms_output.put_line (obj. (Text);
    END LOOP;
    END;



    Error report:
    ORA-06550: line 5, column 30:
    PLS-00302: 'TEXT' element must be declared.
    ORA-06550: line 5, column 5:
    PL/SQL: Statement ignored
    06550 00000 - "line %s, column % s:\n%s".
    * Cause: Usually a PL/SQL compilation error.


    EDIT:
    In fact I found no examples on the net of its use "cursor for loop" with cursor that returns the object. Only when the record is returned...

    Published by: user10393567 on February 10, 2009 07:38

    user10393567 wrote:
    Now, in the 'loop' example for what looks "obj" is a folder, not an object, and 'x' is attribute of this recording... But the cursor must return an object, not a record... What Miss me?

    In the FOR loop "obj" is a pointer to the cursor/query, not a subject in its own right. It gives you just a reference in the query.

    So with that you are referring to the query, but then you need to refer to the column in the query that you are interested, so why there need a name (in my case I called it 'x'). 'x' is the object, and then you refer to the attribute of this object "text".

    In the first request that you simply select the value directly object in a variable, so no matter what it's called in the query values are returned by the position that is the first column in the query goes into the first variable in the INTO clause. Once you have that then the variable itself contains the object, and you can just refer to the attribute within that.

    Hope that makes sense.

  • Hi all, after happily using CC for almost a year he no longer works: the creative cloud icon continue on spinning and when I try to open ANY CC applications a warning saying "Adobe Application Manager is needed to solve this problem. However, he

    Hi all, after happily using CC for almost a year he no longer works: the creative cloud icon continue on spinning and when I try to open ANY CC applications a warning saying "Adobe Application Manager is needed to solve this problem. However, it is missing or damaged. Please download and install a new copy ecc ecc. Tried all that but I'm stuck. any help, please? Thank you.

    Hello

    Please try following steps depending on your operating system

    (Windows)

    (1) close adobe all processes in the Task Manager (Core sync services for the desktop application adobe, adobe office, broker CIB Adobe updater AAM service)

    2) navigate to the following locations and assign all permissions to the adobe folders to the current user.  (Right click on adobe folder select properties then click on the Security tab, click on edit and select current user, that you are connected to, select full control, click on apply and then ok)

    C: / / program data (to view hidden files to see this folder)

    C: / / program files 86 x files / common

    C: / / program files x 86.

    C: / / program files common files

    C: //program files.

    Go to c:/programdata/Adobe and oobe and rename it oobe.old

    Go to c: / / programfiles86x/common files/adobe/and rename the oobe oobe.old and aamupdator to ammupdator.old and delete the folder Adobe application manager

    Go to c: / / Users/username/appdata/local/adobe/rename in oobe to oobe.old and aamupdator.old aamupdator

    Go to Control Panel/Add or remove programs and uninstall cloud creative app

    Install app creative cloud from link according to https://creative.adobe.com/products/creative-cloud

    Run it and it should work.

    (MAC)

    (1) close adobe all processes in the activity monitor (cloud Creative), synchronization of the base, CC, ccx, services for the desktop application adobe, adobe office, CIB Adobe updater AAM Broker service

    2) navigate to the following locations and assign all permissions to the adobe folders to the current user. To navigate, click on go in the bar on then click goto... type/library/application support of / and then click OK.

    (3) to assign the authorization right click on adobe folder and click on Get info... A window will open. Then click on the lock symbol to allow editing. Then click on sign + to add your user name. Then change read only to read and write. Then click gear icon on the bottom and click on apply to the elements included and click ok... Go to the next step then.

    3) navigate to the location following support/adobe application and rename in oobe to oobe.old and aamupdator.old aamupdator.

    (4) place you ~/Library/application support/adobe/oobe and rename in oobe to oobe.old and aamupdator.old aamupdator.

    Cloud creative library and remove 5 open application).

    (6) open utility library of the application itself and delete Adobe application manager and creative cloud

    (7) install creative cloud from link according to https://creative.adobe.com/products/creative-cloud

    (8) launch cc app and it should work properly

  • Why the fan on my macbook pro continue to run at a fast pace for long periods?

    The MacBook Pro mid-2010

    OS X El Capitan, 10.11.3 version

    Processor: 2.4 GHz Intel Core 2 duo

    Memory: 4 GB 1067 MHz DDR3

    Graphics card: NVIDIA GeForce 320 M 256 MB

    163 GB available

    iWorks ' 09 has been upgraded to the latest versions

    No new upgrade is available for the system.

    My Question: Why the fan on my macbook pro continues to run at a fast pace for long periods?

    I guess that the fan runs constantly, because the CPU is working at a high rate. I rebooted several times but without any resolution systems. At the bottom of the computer is very hot at times so place the laptop on an object that allows good air circulation. This problem occurs intermittently every few weeks or more. I wonder if it is downloading an important upgrade, do a scan of viruses, or by working as a bot. Lights for hours. Currently, I estimate that it has worked rapidly to possible 6 hours. Thank you.

    It will usually be to dissipate internal heat from running resource intensive applications.

    Download and install a temperature/speed control application.

    Open the activity monitor all THE PROCESSES and CPU to display values between high and low.

    When the fan speeds up, post pictures of both for review.

    Also run Apple Hardware Test:

    https://support.Apple.com/en-us/HT201257

    Note that an error free AHT is inconclusive.

    Ciao.

  • performance problem, when I use the lappy for long periods... he get odious

    I installed windows 7 in my lappy... When I use the lappy for long... he get odious... I'm irritating with that... and when I restart it started working as usual.please help me form this problem

    Hello

    1. have there been recent changes to the computer before the show?

    2. this happens to you when you work on any specific application?

    I suggest you follow the given steps and later a update on the State of the question.

    Method 1: Try to run the troubleshooter of Performance:

    http://Windows.Microsoft.com/en-us/Windows7/open-the-performance-Troubleshooter

    Method 2: Optimize Windows 7 for better performance:

    http://Windows.Microsoft.com/en-us/Windows7/optimize-Windows-7-for-better-performance

    Important: when running chkdsk on the drive hard if bad sectors are found on the disk hard when chkdsk attempts to repair this area if all available on which data may be lost.

    Ways to improve your computer's performance:

    http://Windows.Microsoft.com/en-us/Windows7/ways-to-improve-your-computers-performance

    For all windows questions do not hesitate to contact us and we will be happy to help you.

  • When to use the cursor for loop and the cursor (open, fetch, close)

    Hello world
    I have a small doubt about when to use the cursor for loop and when to use the cursor for loop and the cursor (open, fetch, close).
    Well, I'm not the difference between implicit and explicit cursor. So please tell me how I got to know, what to use and when?




    Kind regards
    BS2012

    Published by: BS2012 on January 29, 2013 12:15

    All SQLs are analyzed, stored and executed as cursors. Thus, you will always use a cursor.

    The problem is that languages, such as PL/SQL, provide different interfaces to interact with the SQL cursor. As the ref, the slider interface, the interface DBMS_SQL slider interface and so on.

    Each of these interfaces offers different features. For example, using the interface DBMS_SQL allows binding dynamics and dynamic recovery. The Ref Cursor interface allows your code PL/SQL pass a handle to a reference pointing to the SQL cursor, to an external client. Etc.

    The fundamental reason for the use of an explicit cursor interface is mainly that you own and manage bulk made extraction output provided by PL/SQL cursor.

    With a cursor FOR , the motor loop of PL/SQL optimize the loop by extracting block a 100 lines both. However, you cannot access this collection in bulk directly inside the loop.

    With an explicit cursor interface, you specify the size of the extraction in bulk via the clause LIMIT , and you set the variable of collection to use. This allows you to use the collection directly variable inside the loop.

    However, the need to do - code manually in bulk collection - rarely occur in the daily programs in PL/SQL. A line of treatment is both slow and not well fits. And even if your bulk code collects lines, these lines must still be processed one at a time in your code. It is much more efficient and scalable rather write SQL code, and make the engine SQL the line of treatment for you.

  • Using your computer to video processing for the web

    Hello

    I've heard of some people, I really trust and respect that we should never use your video server for any other purposes other than the video work.   They say that if you are using other applications, including the use of the Internet, it is systematically to mess things up in the long run.

    I want to do the right thing.  But I have to admit, it's SO convenient to be able to encounter a problem in PrPro and just go online here and ask.

    What should I do more?  They respect the point of view of the dedicated video machine?

    Thank you

    Matt Dubuque

    Matt,

    Which can spoil things is the first of all the games and second Microsoft Office. Internet is not a problem. Many other programs cause any problems either.

    I'll give you an example. On my video machine, I have several versions of the workshop of the Master Collection and Production. When I need to update the reference PPBM, I need to access my G-mail with bid forms. I need to download the submitted data and files with Filezilla, store on a server, as well as another system to import them in the Excel worksheet. Save the worksheet again on the server, then the video machine change the pages with a few VBS scripts, edit them in Dreamweaver and download them again on the Web site, including updated graphics to date with Filezilla. To view these pages, I use IE, Chrome and FF on my video machine and perform the optimizations with Firebug and PageSpeed.

    In addition, I sometimes use TeamViewer to help others in my video machine for the simple reason that it has enough real estate screen with two monitors to easily see the computer on the other side. I've no problem with this kind of applications on the video machine.

    So, don't worry about it.

  • Use the MacBook Air as a second screen for iMac running Windows 10

    Hello

    is it possible to use my MacBook Air running El Capitan as a second screen to my iMac with 10 Windows under Boot Camp? I have to use the iMac for work and wants to extend the screen of my MacBook Air. I couldn't find solutions, as target display mode does not work in Boot Camp. Does anyone know an app solution or a third party for this?

    Thank you very much.

    Best,

    B.

    Please visit http://symless.com/synergy/ .

Maybe you are looking for