PL/SQL: Cursor with list filling can do IF EXISTS on Table

Here's my problem. The DB I work with is a database of events (network events). I have a task to take a list of nodes of 2600 and see whether these nodes exist in a set of events that would be with a certain WHERE clause. On my first pass, I did WHERE AND NŒUD clause in (list of 2600 nodes). Well you can put only 1,000 items in a list so I've divided into 3 reports and served while a UNION all between them. This used 15% of the resources of the db and ran for hours and the Group dba like me to find a better way. They would prefer that I use PL/SQL.

I am new to pl/sql (but not programming or SQL). So the first thing I've done is just figure out how to get my list in a Varray, which I then went to a table because I couldn't find examples, after hours and hours of searching the Web,.
referencing a Varray with SQL syntax.

START CODE sample 1 *.
DECLARE
DECLARE
TYPE NodeList IS TABLE OF VARCHAR2 (255);
Node NodeList: = NodeList ('node1', node2', [.. .list of 2597 nodes..], 'node2600')

BEGIN
dbms_output. Enable (1000000);
FOR i IN Nodes.FIRST... Nodes.LAST
LOOP
DBMS_OUTPUT. Put_line (' relevant points: ' |) Nodes (i));
END LOOP;
END
END CODE Sample 1 *.

The pseudo-code I'm envisioning goes something like this:

IF one of these nodes (nodes of 2600 list),
There are in the nodes for this WHERE clause (which is taken from the event db table).
then print the records (of the events in the event db table) that contains the nodes (ie the list nodes).

I think I found an example with 2 sliders, but I can't find this example once again. And anyway, I can't figure out how to get my list in a cursor. I have many examples of how to complete a cursor on a select statement against a database.

I tried this but it did not work:
START the CODE sample 2 *.
DECLARE
DECLARE
TYPE NodeList IS TABLE OF VARCHAR2 (255);
Node NodeList: = NodeList ('node1', node2', [.. .list of 2597 nodes..], 'node2600')

CURSOR MOM_OVO_NODES IS
SELECT the node
OF NodeList
ORDER BY node;

BEGIN
dbms_output. Enable (1000000);

FOR nodelist_rec IN MOM_OVO_NODES
LOOP
dbms_output.put_line (' relevant nodes: ' | nodelist_rec.) Node);
END LOOP;

END
END CODE sample 2 *.

Is there a way to get this list in a slider? Or I think about this correctly?

Brad

Brad Bueche wrote:
Here's my problem. The DB I work with is a database of events (network events). I have a task to take a list of nodes of 2600 and see whether these nodes exist in a set of events that would be with a certain WHERE clause. On my first pass, I did WHERE AND NŒUD clause in (list of 2600 nodes). Well you can put only 1,000 items in a list so I've divided into 3 reports and served while a UNION all between them. This used 15% of the resources of the db and ran for hours and the Group dba like me to find a better way. They would prefer that I use PL/SQL.

PL/SQL is probably going to be a slower solution, then SQL. It's almost always.

Your best bet would be to maintain a table of nodes. You can then use a single SQL query with an IN WHERE clause as:

WHERE node in (SELECT node FROM node_table)

Or you can use a join (the method preferred honestly, gives Oracle more optimization options).

If you don't want to maintain a table of node, you can always create a global temporary Table or the external Table that could be loaded prior to running your report.

If you have tried these methods, and it is still too low or high intensity of resources, then we should look at the SQL and chorus only. See the PL/SQL FAQ's for more information on setting the SQL statements.

Tags: Database

Similar Questions

  • I have an existing web site was not created with Muse.  Can I import existing site pages and Muse allows to update and modify.

    I have an existing WEB site, not created with Muse.  Can I import the pages and update / change with Muse.

    Unfortunately not. Muse is a street in this regard. You can download the assets of the existing site, but you will need rebuild the site of Muse.

    I hope this helps.

    David

    http://creativemuse.co

  • Oject list filling with PL/SQL

    Hello together,

    I use Forms6i and I want to fill an object list (popup list) with values in a PL/SQL Code. But I can't find a way to change the items in the list- value of this object.

    Thanks for your help,
    Stefan

    Hello

    View your online help, and then search for the built-ins Populate_Group() and Populate_List().

    François

  • Char invalid when you use dynamic sql statements with cursor

    Hello guys,.
    I'm opening a following cursor with dynamic sql
     v_sql := 'SELECT OS.table_name FROM OBJECT_STATS_CONTROL OS, ALL_TABLES AT
                    WHERE OS.analyze_flag <> ''N''
                    AND OS.last_analyze < sysdate -1 AND AT.last_analyzed < sysdate - 1 '||v_1||';'; 
    my cursor statement is
    BEGIN
           OPEN v_cur FOR v_sql; 
           LOOP
           FETCH v_cur INTO v_tabname;
    ......
    I get an error message
    0911 invalid char
    can any body suggest me where I'm wrong

    Thank you

    Remove the semicolon at the end:

    ||';'  -- remove this.
    
  • I can't boot into windows xp. The windows logo comes on but then a black screen blank (you can see and move the cursor with the mouse however) is displayed.

    I can't boot into windows xp. The windows logo comes on but then a black screen blank (you can see and move the cursor with the mouse however) is displayed.

    anesvet,
    I'm going to sound like I'm repeating myself tonight... (see previous 4 posts...)  but try this:

    When you start start pressing F8 until you get the Windows startup options.  Then try "Last known good configuration" see if that helps.  If this does not work, try to F * then try to go to Safe Mode.  If those who do not help, I would start with your XP CD to recovery mode and run "chkdsk/r" then "sfc/scannow".  QQ learn manage!

  • Can fill us transitional attribute in the table with no serial like 1,2,3, etc.? And how?

    Mr President.

    Can fill us transitional attribute in the table with no serial like 1,2,3, etc.? And how?

    Concerning

    You want to show serial No. on the page for all the lines?

    Check once-

    Blog of Ashish Awasthi (Jdev/ADF): Add the serial number to the table of the ADF, column to auto-increment in the table to the ADF

    Actually transitional attribute loses its value when page refreshes or viewObject is not appropriate in this case if your use case is different, so please tell us

    Ashish

  • Is it possible that I can have a spindle of pinterest this button that only appears to fly into a rectangle with image fill?

    Is it possible that I can have a spindle of pinterest this button that only appears to fly into a rectangle with image fill? In any case for also not having to add each individual image, but all the photos on the page would have a?

    The code is not in the head section, but in the body section. Try to paste the code in the html body and test it again. Sick it works. I couldn't make it work for rectangle with image fill, but it works for images.

  • In our Web page we have pages with lists of the pdf reports that we want to make available. I tried a search engine, but it only directs you to the page with the list. How can we lead the researcher to a specific report?

    In our Web page we have pages with lists of the pdf reports that we want to make available. I tried a search engine, but it only directs you to the page with the list. How can we lead the researcher to a specific report?

    Exactly, it would depend on how you have set the referencing of your site, please check the suggestions made in this tutorial:

    https://helpx.Adobe.com/Muse/how-to/sitemap-XML-file-explained.html

    In addition, you can check these:

    http://musewidgets.com/collections/all/SEO

    Thank you

    Sanjit

  • How can I keep a link when printing with PDF fill?

    I lose my links when I print a document with PDF fill.

    Fill PDF is not an Adobe product. You'll want to find support from the company that makes it.

  • Parsing sql - cursor parent and child

    Hi all

    What is the parent and child when parsing sql cursor?

    Thank you

    John

    Well, as Anand mentioned you could yourself. Here's a demo of the workaround based. Based on the change of environment, the sliders would be created and will not be shared that I made using the change of parameter of optimizer_mode. This is done in 11201 with the setting optimizer_features_enable on 10201.

    SQL> drop table t purge;
    
    Table dropped.
    
    SQL> select sql_text from V$sqlarea where sql_text like 'select * from t%';
    
    SQL_TEXT
    --------------------------------------------------------------------------------
    select * from t
    
    SQL> alter system flush shared_pool;
    
    System altered.
    
    SQL> select sql_text from V$sqlarea where sql_text like 'select * from t%';
    
    no rows selected
    
    SQL> save a
    Created file a.sql
    SQL> select * from t;
    select * from t
                  *
    ERROR at line 1:
    ORA-00942: table or view does not exist
    
    SQL> create table t(a char);
    
    Table created.
    
    SQL> select * from t;
    
    no rows selected
    
    SQL> select sql_text from V$sqlarea where sql_text like 'select * from t%';
    
    SQL_TEXT
    --------------------------------------------------------------------------------
    select * from t
    
    SQL> select * from T;
    
    no rows selected
    
    SQL> select sql_text from V$sqlarea where sql_text like 'select * from t%';
    
    SQL_TEXT
    --------------------------------------------------------------------------------
    select * from t
    
    SQL> select sql_text from V$sqlarea where sql_text like 'select * from t%' or sql_text like 'select * from T%';
    
    SQL_TEXT
    --------------------------------------------------------------------------------
    select * from t
    select * from T
    
    SQL> select sql_text,version_count, executions from V$sqlarea where sql_text like 'select * from t%' or sql_text like 'select * from T%';
    
    SQL_TEXT
    --------------------------------------------------------------------------------
    VERSION_COUNT EXECUTIONS
    ------------- ----------
    select * from t
                1          1
    
    select * from T
                1          1
    
    SQL> column sql_text format a40
    SQL> /
    
    SQL_TEXT                                 VERSION_COUNT EXECUTIONS
    ---------------------------------------- ------------- ----------
    select * from t                                      1          1
    select * from T                                      1          1
    
    SQL> select * from T;
    
    no rows selected
    
    SQL> select sql_text from V$sqlarea where sql_text like 'select * from t%' or sql_text like 'select * from T%';
    
    SQL_TEXT
    ----------------------------------------
    select * from t
    select * from T
    
    SQL> select sql_text,version_count, executions from V$sqlarea where sql_text like 'select * from t%' or sql_text like 'select * from T%';
    
    SQL_TEXT                                 VERSION_COUNT EXECUTIONS
    ---------------------------------------- ------------- ----------
    select * from t                                      1          1
    select * from T                                      1          2
    
    SQL> alter session set optimizer_mode=first_rows;
    
    Session altered.
    
    SQL> select * from T;
    
    no rows selected
    
    SQL> select * from t;
    
    no rows selected
    
    SQL> select sql_text,version_count, executions from V$sqlarea where sql_text like 'select * from t%' or sql_text like 'select * from T%';
    
    SQL_TEXT                                 VERSION_COUNT EXECUTIONS
    ---------------------------------------- ------------- ----------
    select * from t                                      1          1
    select * from test_sharing where id=:a               1          3
    select * from test_sharing where id=1                1          0
    select * from test_sharing where id=99               1          0
    select * from T                                      2          3
    
    SQL> select sql_text, child_number, optimizer_mode, plan_hash_value from V$sql where sql_text like 'select * from t%' or sql_text like 'select * fro
    
    SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_ PLAN_HASH_VALUE
    ---------------------------------------- ------------ ---------- ---------------
    select * from t                                     0 FIRST_ROWS      1601196873
    select * from test_sharing where id=:a              0 ALL_ROWS        3492249339
    select * from test_sharing where id=1               0 ALL_ROWS        3492249339
    select * from test_sharing where id=99              0 ALL_ROWS        2354865636
    select * from T                                     0 ALL_ROWS        1601196873
    select * from T                                     1 FIRST_ROWS      1601196873
    
    6 rows selected.
    
    SQL> alter session set optimizer_mode=first_rows_1;
    
    Session altered.
    
    SQL> select * from t;
    
    no rows selected
    
    SQL> select * from T;
    
    no rows selected
    
    SQL> select sql_text, child_number, optimizer_mode, plan_hash_value from V$sql where sql_text like 'select * from t%' or sql_text like 'select * fro
    
    SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_ PLAN_HASH_VALUE
    ---------------------------------------- ------------ ---------- ---------------
    select * from t                                     0 FIRST_ROWS      1601196873
    select * from test_sharing where id=:a              0 ALL_ROWS        3492249339
    select * from test_sharing where id=1               0 ALL_ROWS        3492249339
    select * from test_sharing where id=99              0 ALL_ROWS        2354865636
    select * from T                                     0 ALL_ROWS        1601196873
    select * from T                                     1 FIRST_ROWS      1601196873
    
    6 rows selected.
    
    SQL> alter session set sql_trace=true;
    
    Session altered.
    
    SQL> alter session set optimizer_mode=first_rows_1;
    
    Session altered.
    
    SQL> select * from t;
    
    no rows selected
    
    SQL> select * from T;
    
    no rows selected
    
    SQL> select sql_text,version_count, executions from V$sqlarea where sql_text like 'select * from t%' or sql_text like 'select * from T%';
    
    SQL_TEXT                                 VERSION_COUNT EXECUTIONS
    ---------------------------------------- ------------- ----------
    select * from t                                      2          3
    select * from test_sharing where id=:a               1          3
    select * from test_sharing where id=1                1          0
    select * from test_sharing where id=99               1          0
    select * from T                                      3          5
    
    SQL> select sql_text, child_number, optimizer_mode, plan_hash_value from V$sql where sql_text like 'select * from t%' or sql_text like 'select * fro
    
    SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_ PLAN_HASH_VALUE
    ---------------------------------------- ------------ ---------- ---------------
    select * from t                                     0 FIRST_ROWS      1601196873
    select * from t                                     1 FIRST_ROWS      1601196873
    select * from test_sharing where id=:a              0 ALL_ROWS        3492249339
    select * from test_sharing where id=1               0 ALL_ROWS        3492249339
    select * from test_sharing where id=99              0 ALL_ROWS        2354865636
    select * from T                                     0 ALL_ROWS        1601196873
    select * from T                                     1 FIRST_ROWS      1601196873
    select * from T                                     2 FIRST_ROWS      1601196873
    
    8 rows selected.
    
    SQL> select sql_id,sql_text, child_number, optimizer_mode, plan_hash_value from V$sql where sql_text like 'select * from t%' or sql_text like 'selec
    
    SQL_ID        SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_
    ------------- ---------------------------------------- ------------ ----------
    PLAN_HASH_VALUE
    ---------------
    89km4qj1thh13 select * from t                                     0 FIRST_ROWS
         1601196873
    
    89km4qj1thh13 select * from t                                     1 FIRST_ROWS
         1601196873
    
    7gbgb5nzcdcf3 select * from test_sharing where id=:a              0 ALL_ROWS
         3492249339
    
    SQL_ID        SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_
    ------------- ---------------------------------------- ------------ ----------
    PLAN_HASH_VALUE
    ---------------
    0890tcnrf5jsv select * from test_sharing where id=1               0 ALL_ROWS
         3492249339
    
    7hg3cujy0ya0r select * from test_sharing where id=99              0 ALL_ROWS
         2354865636
    
    ahgbnyrbh7bp1 select * from T                                     0 ALL_ROWS
         1601196873
    
    SQL_ID        SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_
    ------------- ---------------------------------------- ------------ ----------
    PLAN_HASH_VALUE
    ---------------
    ahgbnyrbh7bp1 select * from T                                     1 FIRST_ROWS
         1601196873
    
    ahgbnyrbh7bp1 select * from T                                     2 FIRST_ROWS
         1601196873
    
    8 rows selected.
    
    SQL> set pagesize 9999
    SQL> /
    
    SQL_ID        SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_
    ------------- ---------------------------------------- ------------ ----------
    PLAN_HASH_VALUE
    ---------------
    89km4qj1thh13 select * from t                                     0 FIRST_ROWS
         1601196873
    
    89km4qj1thh13 select * from t                                     1 FIRST_ROWS
         1601196873
    
    7gbgb5nzcdcf3 select * from test_sharing where id=:a              0 ALL_ROWS
         3492249339
    
    0890tcnrf5jsv select * from test_sharing where id=1               0 ALL_ROWS
         3492249339
    
    7hg3cujy0ya0r select * from test_sharing where id=99              0 ALL_ROWS
         2354865636
    
    ahgbnyrbh7bp1 select * from T                                     0 ALL_ROWS
         1601196873
    
    ahgbnyrbh7bp1 select * from T                                     1 FIRST_ROWS
         1601196873
    
    ahgbnyrbh7bp1 select * from T                                     2 FIRST_ROWS
         1601196873
    
    8 rows selected.
    
    SQL> set linesize 200
    SQL> /
    
    SQL_ID        SQL_TEXT                                 CHILD_NUMBER OPTIMIZER_ PLAN_HASH_VALUE
    ------------- ---------------------------------------- ------------ ---------- ---------------
    89km4qj1thh13 select * from t                                     0 FIRST_ROWS      1601196873
    89km4qj1thh13 select * from t                                     1 FIRST_ROWS      1601196873
    7gbgb5nzcdcf3 select * from test_sharing where id=:a              0 ALL_ROWS        3492249339
    0890tcnrf5jsv select * from test_sharing where id=1               0 ALL_ROWS        3492249339
    7hg3cujy0ya0r select * from test_sharing where id=99              0 ALL_ROWS        2354865636
    ahgbnyrbh7bp1 select * from T                                     0 ALL_ROWS        1601196873
    ahgbnyrbh7bp1 select * from T                                     1 FIRST_ROWS      1601196873
    ahgbnyrbh7bp1 select * from T                                     2 FIRST_ROWS      1601196873
    
    8 rows selected.
    
    SQL> select child_number, child_address, stats_row_mismatch, optimizer_mode_mismatch
      2  from v$sql_shared_cursor where sql_id='ahgbnyrbh7bp1';
    
    CHILD_NUMBER CHILD_AD S O
    ------------ -------- - -
               0 1A610050 N N
               1 1F148DA4 N Y
               2 1A630C90 Y N
    
    SQL>
    

    You can see an inconsistency in the optimizer_mode resulting in another creation of child cursor. You can try to use the parameter cursor_sharing similar value and bind variables that would also cause child several sliders to create. For the view V$ sql_shared_cursor, check the docs.

    HTH
    Aman...

    PS: Please don't bump up to the thread. This is not support so people are not forced to update immediately. All are volunteers so assume that they would update the thread as and when they have / get time to do.

  • Firefox will not continue to load unless I keep my cursor moving. How can I fix it?

    Firefox will not continue to load any request that I have unless I keep my cursor moving. If I stop my cursor, it stops to load my request until I have move the cursor again. How can I fix it please?

    Hey even once - another user reported that he could solve the problem with a sweep for malware.would you can try with firefox 32 new and run a scan with adwcleaner?

    http://www.bleepingcomputer.com/download/adwcleaner/

  • Qosmio G10-166 - the cursor blink, but I can't do anything

    I received a G10-166 with a broken power connector. The laptop had no disks or a battery, I made a temporary solution and the portable lights only problem is that after the load screen where its Qosmio, then said to the screen where the icons are the following has letters everywhere. I can see the cursor blinking, but I can't do anything with it.

    I tried to access the page of the BIOS pressing F1 but nothing just this screen with the strange letters on it. Also I don't know the history of the laptop so any ideas what is wrong I want to get the job of the laptop?

    Hello

    You can access the BIOS if you press ESC I n know why you try F1?

    You have installed a new HARD drive now? If so, you should check if the HARD drive is recognized correctly in the BIOS. If so, you can start with the installation of the driver because the new hard drives are empty then the cursor blinks and nothing happens.

    Simplest is that you use the Toshiba recovery disc because it contains an image of the settings from the factory with all the drivers and tools. Just follow the instructions of scree and Windows will be reinstalled.
    Alternative, you can also take a Microsoft Windows disk, but you will need to download and install all the drivers step by step.

  • Control chart cursor with keyboard

    Is there a way to move the cursor with the keyboard arrowsbuilt in graphics? If this isn't the case, I think it would be simple to do with the dynamic event record. If the user clicks on the graph, save the events during the arrows button and use the down arrows to move the cursor some default step size. How can only problem, I determine when the user has clicked everywhere except on the graph (graph lost focus) to unregister the key down events? The only way I can think of is to use a component-based mouse event and calculate if the mouse coordinates are on the chart control, and if they are, then don't unsubscribe the events down button again.

    Hello

    I did small example to move the cursor by using the keyboard.

    What I've done is, you press F10 to access the keyboard mode and move the slider or just as you mentioned, click on the graph, it will start

    move the cursor with the keys and when you click anywhere else in the public Service, it will stop that.

    I would like to know if that's what you want.

  • Change the problem of direction of the cursor with new 2nd monitor

    original title: problem of direction of the cursor with new 2nd monitor

    I just added a 2nd monitor to my computer. The 2nd monitor is left of my laptop but I have to move the cursor to the right in order to get on the new monitor. How can I change so I can just move my cursor to the left and get it on my new 2nd monitor?

    Right-click on the desktop and then clicking display settings by clicking Customize to open the display settings. In the display settings box, click and drag the image to the monitor 2 to the left of the screen 1. Click on the button apply, then check. Click Ok to exit.

  • Where are the mouse pointer/cursor themes stored and can copy them to another computer?

    I have my own theme mouse and custom cursor, with a complete record of pointers favorite that I have used for several years. It takes a long time to copy on every new computer that I use and set up.

    Is it possible to copy these themes of pointer and keep them with the custom pointers folder, save me time setting them up again?  Or are they kept individually in the registry?

    You can try to save as part of a Pack, but I do not think the themes compress and store cursors internally as they do with wallpapers.  Unfortunately the only way I know to do what you want is to export the registry, but that only works if the new computer has the cursor files stored in the same exact path.

    If it was useful, you can vote by clicking on the green triangle. If it solves the problem, click on propose as answer. Thank you!

Maybe you are looking for

  • necessary to sync books iCloud?

    I have ePub files not iBook store.  they appear well in iBooks on mac.  in order to sync my iPad, it is necessary to store in iCloud, or is it sufficient to simply check the preferences in iBook on mac and iPad can use iTunes?  I want to free space i

  • HP ENVY notebook - m7-n101dx: graphics card in replacement for laptop HP ENVY - m7-n101dx

    I have a HP ENVY notebook - m7-n101dx my graphics card appears to not follow very well on demanding games and I wouldn't mind buying a new card. I'm relatively unknowledgable on the compatabilities of these cards and how they work, but I want to know

  • When I get Qosmio G35-AV660 in Europe?

    cannot find information when g35-av660 will be available for sale in europe... have no idea how much of time to wait or just buy any other laptop Merom

  • Merger of two plots

    Hello I have a simple question, I have two plots now. I want to merge into a single parcel. I have included the code below, with highlight properly the graphics I want to merge. Is there a way to do it. > ?? Thank you

  • 1315: power of paper together to the top

    I lost the manual and seems its is no longer available on the HP site. I moved the printer and now cannot get the tray plastic for paper to insert correctly so that the printed paper falls to the ground. How can I configure this return? Thank you