Using the same subquery in several cursors

I have a small subquery that I am currently reuse in many cursors (that he returned to about a thousand files). I was wondering if there is a better way - to a performance and a readability perspective - to go about it rather than rewrite the subquery several times in each cursor? I was thinking about a global temporary table or materialized view, but I don't know if it's necessary here / it will help with performance, because the query is so small.

Here's an example of how I currently my code wrote:
CURSOR sample_a_cur IS
WITH subquery_view AS
(
SELECT *
FROM   table
)
SELECT *
FROM   table_a ta,
       sub_query_view sqv
WHERE  ta.code = sqv.code;

CURSOR sample_b_cur IS
WITH subquery_view AS
(
SELECT *
FROM   table)

SELECT *
FROM    table_b tb,
        sub_query_view sqv
WHERE   tb.code = sqv.code;

etc....
Published by: user652714 on 10 July 2012 09:10

Hello

I guess that there are more subquery_view than what you posted. If it's really just "SELECT * FROM table_x", then you may as well use table_x in each slider.

user652714 wrote:
I have a small subquery that I am currently reuse in many cursors (that he returned to about a thousand files). I was wondering if there is a better way - to a performance and a readability perspective - to go about it rather than rewrite the subquery several times in each cursor? I thought in a global temporary table or materialized view.

How about a regular view?

CREATE OR REPLACE VIEW subquery_view
AS
SELECT  *
FROM        table_x
;

In your PL/SQL code, you can reference it as an array:

CURSOR sample_a_cur IS
    SELECT  *
    FROM    table_a          ta,
                sub_query_view      sqv
    WHERE   ta.code  = sqv.code;

CURSOR sample_b_cur IS
    SELECT  *
    FROM    table_b          tb,
            sub_query_view     sqv
    WHERE   tb.code = sqv.code;

....

You do not need to fill out or refresh the view.

but I don't know if it's necessary here / it will help with performance, because the query is so small.

You're right; It may not be important for performance.
However, the code will be easier to maintain and less likely to have bugs, if you do something, whether a regular view, materialized view, or a global temporary table, so that when you need to change sub_query_view, just make the change in one place.

Tags: Database

Similar Questions

  • How to use the same script for several buttons

    Hello

    I have just started using flash if any help would be great!

    I create a blockbuster game, I have a grid of 20 buttons and I need (individually) to turn blue on red and click double click. I managed to do it with the first using this code;

    --------------------------------------------

    var click: Boolean = false;

    BN1.addEventListener (MouseEvent.CLICK, bn1click);

    function bn1click(event:MouseEvent):void {}

    clicked = true;

    var newColorTransform:ColorTransform = bn1.transform.colorTransform;

    {if (clicked)}

    newColorTransform.color = 0 x 064258;

    }

    BN1. Transform.ColorTransform = newColorTransform;

    }

    /////////////

    BN1.doubleClickEnabled = true;

    var doubleclicked:Boolean = false;

    BN1.addEventListener (MouseEvent.DOUBLE_CLICK, bn1dclick);

    function bn1dclick(event:MouseEvent):void {}

    DoubleClicked = true;

    var newColorTransform:ColorTransform = bn1.transform.colorTransform;

    {if (clicked)}

    newColorTransform.color = 0xac1e23;

    }

    BN1. Transform.ColorTransform = newColorTransform;

    }

    --------------------------------------------

    Now, I'll have trouble doing the same thing to work for the rest of the buttons, they are each named bn2, bn3 etc. They need to work individually and stay blue/red when clicked. I tried to list them as addEventListener orders but not with not a lot of success!

    Any help would be greatly appreciated, thank you!

    Tomo

    To do this is to use arrays to follow the buttons and their properties.

    var buttonList:Array = new Array (bn1, bn2, bn3);

    var clickedList:Array = new Array();

    var doubleClickedList:Array = new Array();

    Then use a loop for to assign functions and properties for each button:

    var thisMany:int = buttonList.length; This will give you the number of items in the buttonList array

    for (var i: int = 0; i

    buttonList [i] .addEventListener (MouseEvent.CLICK, btnClick); assign the function click on each button

    buttonList [i] .addEventListener (MouseEvent.DOUBLE_CLICK, btnDClick); assign the double-click function

    clickedList.push (false);  Add a value of false for each key in this table

    doubleClickedList.push (false);

    buttonList [i] .doubleClickEnabled = true; Set the property of double-tap for each button

    }

    function btnClick(event:MouseEvent):void {}

    var thisButton:int = buttonList.indexOf (event.target);  know which button has been clicked as an element in the table

    clickedList [Ceboutonselectionnel] = true;  Change the value in the table

    var newColorTransform:ColorTransform is buttonList [Ceboutonselectionnel].transform.colorTransform;.

    {if (clickedList [thisButton])}

    newColorTransform.color = 0 x 064258;

    }

    buttonList [Ceboutonselectionnel].transform.colorTransform = newColorTransform;

    }

    function btnDClick(event:MouseEvent):void {}

    var thisButton:int = buttonList.indexOf (event.target);

    doubleClickedList [Ceboutonselectionnel] = true;

    var newColorTransform:ColorTransform is buttonList [Ceboutonselectionnel].transform.colorTransform;.

    {if (doubleClickedList [thisButton])}

    newColorTransform.color = 0xac1e23;

    }

    buttonList [Ceboutonselectionnel].transform.colorTransform = newColorTransform;

    }

    Now you can have any number of buttons, just add their instance names in the table above.

  • How can I use the same sound for several sounds?

    I need my program to play a lot of different mp3 files at different times.  I read that you cannot load different mp3 in the same variable sound files.  But there must be a way around this right?  Can I Unload mp3 files some how?  Or can I remove the sound variable and declare it again?  I don't want to have hundreds of sound variables then what should I do?  Thank you.

    create hundreds of sound variables.  just unnecessary loan for gc and that there should be no problem.

  • Hi, I use Lightroom4 and I can't seem to make one of the photos in the book that I am trying to download on Blurb.  I used the same photo before in other books.  Any help would be appreciated.

    Hi, I am trying to download my Blurb photo book and it does not work.   I use Lightroom4 and recently (and successfully) use the same picture in several other books.  I get an error message that says that the photo cannot be returned.  I don't know if it would work with the rest of the photos, because the one who gets the error message is only the third of about 40 images.  I would appreciate all the advice really.

    Thank you

    Carly

    As I said, I'm never comfortable with special characters like slash, and colon (exception is the underscore), although I have no direct evidence that there is a problem.

    What happens if you rename the photo (using your operating system) to be lake_clouds2.jpg, and then she would have the question mark in LR 4 and you reconnect to the it in LR 4? Renders the picture then?

  • Is it possible under the EULA to have several virtual machines on a single physical hard disk while using the same OS license or do I need a separate license for each virtual computer?

    I have several programs that are not compatible with my 64 bit Windows 7 operating system.  I would like to run each different software under another virtual machine of VMWare (5 packs of different software programs and 5 different virtual machines of Windows XP).  These would all be installed on your laptop.  I can use the same license of Windows XP for each virtual machine, or do I need a separate XP license for each (different XP in case 5 licenses)?

    It is lifted directly from my EULA:

    1. GRANT OF LICENSE.
    The manufacturer that you grant the following rights, provided that
    comply you with all terms and conditions of this EULA:
    1.1 installation and use.  You may install, use, access,
    display and run one copy of the SOFTWARE on
    THE COMPUTER.  The SOFTWARE may not be used
    by more than two 2-processor both on the
    COMPUTER, unless a greater number is
    indicated on the certificate of authenticity.
    Then...
    This means that as long as you are running two or more instances of XP at the same TIME, you agree? Or does this mean that, after you install once, you have reached your limit?
    I imagine that most people (including those who are running Microsoft!) will say that the second interpretation is correct.
    However...
    If this is the case, anyone their hard drive as a backup to clone strategy would violate the EULA!
  • Why can't I find the same theme of mouse cursor that I used it since the beginning of the 1990s on each upgrade of computers I've had since then with the exception of Windows 7?

    Hi, I have used the same system of slider for years and had no problems to find on the Net, or put in my computer over the years, except for this new.  It is the set of mouse cursors when the sliders are all the mice for different functions.  There are other sets in the package, including a dance theme and a theme of Rameau, but I do not remember the others included.  If anyone can help find something similar, I would be very grateful that I HATE the "stuff" regular, ordinary! Thank you

    Hello

    The only thing I can suggest would be to keep looking for a compatible version of Windows 7 that will meet your needs. Compatibility with Windows 7 is the responsibility of the software developer.

    There are tons of these cursor there plans.

    Edit: More information.

    It seems that the standard cursor file ( .cur ) w will work under Windows 7. How to install these may be different from previous versions of Windows. Here are some links with precision.

    How to install & customise cursors in Windows 7 | Windows Club:
    http://www.thewindowsclub.com/how-to-install-customize-Windows-7-cursors

    Top 10 of the best mouse for Windows systems. 7 tutorials:
    http://www.7tutorials.com/top-10-best-mouse-cursor-schemes-Windows

    Eye of ox mouse - homepage:
    http://archive.msdn.Microsoft.com/Bullseye

    Search for Windows 7 cursor plans:

    http://www.bing.com/search?q=%28Windows+7+and+cursor+schemes%29&QS=n&SK=&form=QBRE

    Concerning

  • Using the same set processing on several site to site VPN tunnels

    Hi all. I have a rather strange situation about site-to-site VPN tunnel.

    On the one hand, I have a PIX 501 and on the other end an ASA5505 and a tunnel set up between them.

    The problem is that on the side of the PIX, I can't establish a tunnel, but when the traffic starts on the side of the ASA the tunnel established as usual.

    I checked the configurations on both ends and keys, passwords, mirror that LCD seems OK. The only thing that comes to my attention, it's that I have the same set of transformation used for 2 different tunnel on the side of PIX.

    Can I use the same set of transformation on several tunnels or should I set a different transformation for each tunnel? Could be the source of the problem?

    Use it on PIX

    card crypto set pfs group2

    Or on ASA, use:

    card crypto set pfs Group1

  • several insert using the same sequence number,

    Hello

    I need to use the same sequence number in several documents (insertion).

    Is this possible and how?

    Thank you

    It depends on how you are doing multiple inserts.  If you then run a bunch of single inserts something like:

    dev1 > create table t (ID, descr varchar2 (10));

    Table created.

    dev1 > create sequence t_seq;

    Order of creation.

    dev1 > select double t_seq.nextval;

    NEXTVAL

    ----------

    1

    dev1 > insert into values t (t_seq.currval, 'Rec 1');

    1 line of creation.

    dev1 > insert into values t (t_seq.currval, "Rec 2");

    1 line of creation.

    dev1 > insert into values t (t_seq.currval, 'Rec 3');

    1 line of creation.

    dev1 > insert into values t (t_seq.currval, 'Rec 4');

    1 line of creation.

    dev1 > insert into values t (t_seq.currval, 'Rec 5');

    1 line of creation.

    dev1 > select * from t;

    ID DESCR

    ---------- ----------

    1 rec 1

    1 rec 2

    1 rec 3

    REC 2 4

    REC 2 5

    You can use a similar approach, if you select data from another table as long as you can make the selection sufficiently selective to retrieve only the lines you need.

    John

  • How do you install the creative cloud on several computers using the same license?

    How do you install the creative cloud on several computers using the same license?

    Installation on multiple computers can be done independently of the subscription.  You only need the lic3ense when it comes to activation, you have two active facilities (signed in).  Just install the desktop application and use it to install the applications, and then connect to activate.

    https://helpx.Adobe.com/creative-cloud/help/download-install-app.html

    Creative cloud to desktop
    https://helpx.Adobe.com/creative-cloud/help/creative-cloud-desktop.html

    Sign out, sign in | Creative office cloud app
    http://helpx.Adobe.com/creative-cloud/KB/sign-in-out-creative-cloud-desktop-app.html

    Help of activation & deactivation
    https://helpx.Adobe.com/x-productkb/policy-pricing/activation-deactivation-products.html#a ctivate-how-to's

    Install, update, or uninstall applications
    http://helpx.Adobe.com/creative-cloud/help/install-apps.html

  • How can I use the same graph of façade in several events in a structure of the event?

    I want to display my sensorDAQ signals in a graph.but I have more than one event in the case where the structure to acquire the signal and display it in the first round of graph.the is to acquire signals from threshold and its shown in the graphic as a feedback.after the first event is executed, I'll call the second event, where the other signals are acuired and compared with signals from threshold of event 1 my question is how can I use the same control on front panel in more than two events in the structure of the event? Please answer me I am stuck.

    Hello

    I have attached here an example of doing the same thing using local variables and shift registers. Take a peek inside. Shift register is always a better option than local variables.

    Kind regards

    Amine31

    (Bravo to give good answers, mark it as a solution if your problem is resolved)

  • Several plugins using the same JS file dynamic action

    Hello

    (Apex 4.0.2)

    I created two plugins for dynamic action, say Plugin1 and Plugin2. These two plugins are most of the time used together, so to keep things simple and ease of maintenance that all the JS need to the code specific to each plugin as well as of the common code is in a single file, for example plugins.js. So I download the same JS file to each plugin.

    In the generated page, using two plugins the JS file is loaded twice, as planned. Of course, at Apex, they are two different files even if their content is exactly the same.

    This is not ideal for me. What is the approach suggested in this case? Always keep the JS separate files for each plugin? And on any common code plugins share, duplicate in each JS file?

    Thank you
    Luis

    Hi Luis,.

    apex_javascript.add_library currently does not allow to specify p_key as for example apex_javascript.add_on_load_code is. It automatically calculates the value of 'key' based on the directory and name. I'll add an enhancement request to allow to override this default that will allow both plug-ins use the same 'key' to just load the file once.

    Concerning
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • How to use the same mask, stencil, etc for several layers? Photoshop equivalent of the masked group?

    Hi I spent over half an hour for search manual, forums and the Internet and still can't find the answer. Help, please!

    For example, in a model with 5 or more layers, I want to use the same mask or stencil or what can hide layers 2,3 and 4 but areas layer 5 and all other possible layers below should not be affected.

    1. Before dialing the layers that you want to hide and apply a matte for the demo using the mask. Think to the Dial as an equivalent to the creation of a layer group.
    2. Use the effect on each layer you want to hide. It's easier to do if you apply mast set once and then create an animation preset to apply to the other layers. Just get mast set to do what you want it to do on the first layer, select Set Matte in ECW or in the timeline panel, and then go to the Animation > Save animation preset. Select then all other layers you want to apply the set matte to apply the preset.
    3. Put the mask at the bottom of the layers that you want to hide and turn on the switch to preserve transparency, then this group in composition with other layers of nesting.

    Here's another tip. You can set a custom color for all the layers you want to use the mast, then use the custom color for a group selection. This can make things easier down the line.

  • Use the same code module to multiple steps in the sequence

    Hi all

    I tried to implement a sequence that uses the same code for all steps module in the order, but I'm not returning to it when I need to send it commands.  I got regarding the appellant the VI in a new thread so that it can be executed asynchronously.  I can run the simple sequence and it will indeed open the VI and move to the next step.  When I close the VI manually from the front, the TestStand sequence is completed, as planned.  So it turns out that I have a lot more work.

    My question is how to call the thread separate from the main sequence and other sequences overtime when I need to change the settings.  If I insert a step in the Action, I have to select a file of VI, but from what I can tell, it opens another instance of the file and does not provide an interface with the other asycronously running instance.  My next guess was to use a stage of education, but I was not able to understand how to configure the search string to call the VI settings.  In addition, I don't know how to proceed.  Please notify.

    My intention is to start the module code (asynchronously) VI, run several different subsequences in the main sequence, which call this same VI and edit its settings, close everything and report the results.  If I'm understand how TestStand is supposed to work, please let me know.

    Thank you

    GSinMN

    What I do is use a queue to send data to the asynchronous VI.  So he can run and whatever, but also receive orders from the queue.  I use a motor of Action that contains the reference to queue and sends the commands.  If you really just call the engine of the Action of your sequences.

  • Use the same command

    Hello

    My VI look like her:

    I would like to re - use the same command in my "everything".

    I have several cases and I don't want to create several command text.

    If someone kown one travel, please tell me how.

    Next

    Hello

    I may not be correctly undestand your question, but you can use a local variable for what you're trying to make...

  • Using the same control appeal return of different tabs

    Hello

    I am fairly new to this bare with me for a second...

    I have a situation were I use several tabs with the same exact command buttons in each of them.  Given that the buttons have the same function I want to use the same reminder.  I understand that each TAB is considered as an expert group and has its own Panel of handle.

    My problem is I want the call to make the difference between the button OK of TAB1 and TAB2.  The handle Panel sent back, the call is (from what I can tell) the Panel handle for the tab which is great, but it doesn't have a constant right having at it in the header file.  How sure that TAB1 always has the Panel handle 2 and TAB2 has always handle Panel 3, etc...

    Example: When I click on OK in TAB1 handle Panel sent to the btnOK is = 2 recall.  If I click OK in TAB2 is the handful of Panel = 3.  I want to move to the OK button, but do not want to use hard coded in full.

    int CVICALLBACK btnOK (int command face, int, int event, void * callbackData, int eventData1, int eventData2)

    {

    switch (event)

    {

    case EVENT_COMMIT:

    switch () {}

    case 2:<----I don't="" want="" a="" number="" here="" but="" a="">

    "do this."

    case 3:

    "do this."

    };

    }

    return 0;

    }

    The easy solution would be to have a reminder for each of the buttons.  If it's the only way to go if it's what I'll do, but I am interested in what you think.

    Thank you!

    Hello

    I see at least three ways to get what you want.

    Solution A: depend on constant tab page name (as you can get it back by giving the handle from Panel)

    In the callback, insert this code:

    name char [64];

    GetPanelAttribute (name of Panel, ATTR_CONSTANT_NAME),
    If (! strcmp (name, PAGE1)) {}

    Code for the first page of the tab

    }

    Else if (! strcmp (name, PAGE2)) {}

    Code for the second tab page

    }

    ... code additional pages

    Solution B: based on the attributes of the tab

    int parent, index;

    GetPanelAttribute (Panel, ATT_PANEL_PARENT, & parent);

    GetActiveTabPage (parent, PANEL_TAB, &index);)

    switch (index) {}

    case 0:

    Code for the first page of the tab

    break;

    case 1:

    Code for the second tab page

    break;

    ... Add the code to additional pages

    }

    Solution c: use the callbackData for buttons

    This solution requires code in two different program sections

    * During the loading of the Panel with the tab control

    int pnlH;

    GetPanelHandleFromTabPage (Panel, PANEL_TAB, 0, &pnlH);)

    SetCtrlAttribute (pnlH, PAGE1_BUTTON, ATTR_CALLBACK_DATA, (void *) 1);

    GetPanelHandleFromTabPage (Panel, PANEL_TAB, 1, &pnlH);)

    SetCtrlAttribute (pnlH, PAGE2_BUTTON, ATTR_CALLBACK_DATA, (void *) 2);

    ... and so on

    * In the recall button

    switch (callbackData (int)) {}

    case 1:

    Code for the first page of the tab

    break;

    case 2:

    Code for the second tab page

    break;

    ... Add the code to additional pages

    }

Maybe you are looking for

  • I started the download of el capitan and did not have enough space for the upgrade - I released space, but now the upgrade is blocked for download

    I'm on 10.10.5 and try to upgrade to el capitan via the App Store.  I don't have enough space at the beginning and upgrade wouldn't start - I got error message says not enough disk space.  Once I released space, download hangs and will not end.  I ha

  • New battery for Satellite C650/C650D

    Hello I need a new battery for my Toshiba Satellite C650/C650D.The battery model number is PA3817U-1BRS. 10.8V (48wH). I searched around for buy one online at the United Kingdom and can not find a real one for a reasonable price. I have seem some pri

  • HP Probook 4520 s: HP Probook 4520 s and Windows 10 &gt; Bluetooth

    Dear jury, has obtained a ProBook 4520 s with a Wifi/Bluetooth Combo of Ralink. Updgraded to W10 64bits. Everything works fine, exceppt Bluetooth, be struggling for 2 weeks and about to give up :-( any suggestions, the steps, the pilots could work? T

  • question about ".tin file extension.

    I noticed a file ending with the extension "." TIN"in a temporary files folder.  I do not know what program will open this file or how to find out what this file is or how and why it was created.  Someone has an idea?  I noticed there are websites th

  • For Windows 7 recovery disk

    First of all not to back up files.  Hard drive died.  Wanted to know if I still can do for Windows 7 recovery disk because I still have the product code indicated on the back on my laptop.  Is there a link that I can use.  I got the recovery from the