Lower cost of query sql... but more time to fetch the records...

Hello
I have a 'strange' with a db view situation facing costly.
I tried to reduce the cost of the overview
specifically for 223 records fetched{the cost from 149 reduced to 74,
                                                       the recursive calls from 796 reduced to 224,
                                                       the consistent gets from 311516 reduced to 310341,
                                                        the physical reads from 7 reduced to 0}
but the amount of time needed to fetch the results is greater than the old version of the db view....{it may be the double...}
Have you any idea about this...????

Note: I have got fresh statistics...
         I use db 10g v.2


Thanks,
Sim

Try to trace the query and see what tkprofs shows you.
ALTER session set events 10046 trace context name forever, level 12';
Run the query
"ALTER session set events ' trace 10046 name context off."

Then, run tkprofs on the file path to see where the database devoted his time and effort. Do the same for the baseline query in a different session (so you will generate a different trace file).

If that does not produce something useful, try to use
"ALTER session set events ' trace 10053 name context forever."
Run the query
"ALTER session set events ' trace 10053 name context off."

Then examine the trace file to see if you can learn anything.

Given that you have given us something more to go, it's all the help I can give...

Tags: Database

Similar Questions

  • One more time: Houston-25014: the record has been changed by another user. Please try again.

    Hello

    JDev 11.1.2.4

    I have a workflow where I execute with params VO, and then navigate to a view activity. On this page fragment, I click on a button that calls a PL/SQL procedure in the module of the application. The proceduce updates a row in the table. After this method call, I navigate to the same run with params.

    Execute with params-> view activity method-> call-> Execute with params (the app module method)

    But I have an exceptional:

    oracle.jbo.RowInconsistentException < DCBindingContainer > < reportException > [2669]: Houston-25014: the record has been changed by another user. Please try again.

    at oracle.jbo.server.OracleSQLBuilderImpl.doEntitySelectForAltKey(OracleSQLBuilderImpl.java:1078)

    at oracle.jbo.server.BaseSQLBuilderImpl.doEntitySelect(BaseSQLBuilderImpl.java:552)

    at oracle.jbo.server.EntityImpl.doSelect(EntityImpl.java:8311)

    at oracle.jbo.server.EntityImpl.populate(EntityImpl.java:6975)

    In the log, I see the error.

    Compare entity < EntityImpl > < compare > [2305] has no attribute Addr1

    < EntityImpl > < compare > [2306] original value: COURTUPD

    Target value < EntityImpl > < compare > [2307]: COURTUPDfewfew

    The update in the procedure updates this field. The procedure performs validation, I made the call.

    I suspected that the case of ghost ADF so I put update on update for this field, but it does not work.

    Any idea on who is the user who changes my file without telling me?

    Thank you

    You have something in your entity that has changed.  Call rollback on your transaction module app before executeWithParams put it in a clean condition.

  • I can't open firefox. Home page comes up, I get just the reporter Crash asking to restart/quit but every time I do the same message always comes back.

    I can't open Firefox. Home page comes up, I get just the reporter Crash asking me to restart/quit but every time I do the same message always comes back. I was not able to use Firefox for days now.

    In recent days, we have a lot of crashes with Trusteer report. If you have this program, try to disable it and see if that stops the noise.

    You can stop the report by using the Start Menu > programs > Trusteer report > report stop

    You can ask their helpdesk when a version update of their products will be available or, if you do not need this software, uninstall.

    http://www.Trusteer.com/support/en/report-problem

    If you do not report, so we have a crash report ID. When you send a report of the Mozilla crash puts it right in a gigantic database. We have no way to seek without the ID of the report. I don't know what the problem is without searching the crash report. Please get the ID of your last report of the accident report.

    See https://support.mozilla.com/en-US/kb/Firefox%20crashes

    or http://kb.mozillazine.org/Firefox_crashes

  • For the third time, after re-installing Photoshop components 13, I tried to update, but every time I get the U44M1I200 error code that can help me?

    For the third time, after re-installing Photoshop components 13, I tried to update, but every time I get the U44M1I200 error code that can help me?

    U44... Update error http://forums.adobe.com/thread/1289956 can help

  • update my Photoshop cc through my creative cloud and now takes more time to open the psb files that yesterday were beautiful, moving same layers autour, I now get the beachball! any suggestions?

    update my Photoshop cc through my creative cloud and now takes more time to open the psb files that yesterday were beautiful, moving same layers autour, I now get the beachball! any suggestions?

    Perhaps a preferences Reset could fix.  Cmd k will lead you to the Photoshop preferences where you will see this screen.

  • I already pay for my subscription to Adobe Muse, but every time I open the application appears as I'm always on the free trial version (7 days at the end of the trial), what to do?

    I already pay for my subscription to Adobe Muse, but every time I open the application appears as I'm always on the free trial version (7 days at the end of the trial), what to do?

    Since this is an open forum, not Adobe support... you must contact Adobe personnel to help
    Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)

    Creative cloud support (all creative cloud customer service problems)
    http://helpx.Adobe.com/x-productkb/global/service-CCM.html

  • Reading time to fetch multiple records vs. single record

    Hi all

    I have an application where I need to get several records, I use an SMU-5185, and basically, the problem is that it takes too long to retrieve multiple records, I did a test to measure the time it takes for the reading of the hole 32 MB of data and results.

    Parameters:

    Records to Fetch = 8192 (maximum 1 page = 4 KB, 8192 Records = 32 MB)

    Fetch time = 1100 ms

    Records to Fetch = 1

    Samples to Fetch = (2 ^ 25-1500) = 32MB

    Fetch time = 70 ms

    So, I want to know why it takes more time to get the multiplerecords if both are reading the same amount of data? Is there something I can do to decrease the recovery time?

    Thank you

    Hi Rodrigo,

    In fact, I think that the rate of release should be out of the equation, as in the while loop I wait until the end of the acquisition,

    You're absolutely right, I apologize for this oversight.

    I'm you test your code and see several times (about 930ms) Fetch when only pick a channel.  As soon as I specified two channels, the recovery time is an order of magnitude smaller (around 90ms).  Change the sampling frequency, fetch timeout and record length do not seem to affect this disparity in the order of magnitude.

    So to reiterate:

    In the case of single record , changing from one channel to both channels double recovery time.  It's what I expect.

    In the case of multi recording , changing from one channel to both channels decreases the time of recovery by an order of magnitude.  I don't think that.

    Furthermore, when I test in the example shipping niScope EX Acquisition configured standard I do not see this effect.

    (1) can you confirm that, in the case of multi account for your tests, you see that the recovery time reduced when you specify two channels instead of one?

    (2) can you confirm that you are not able to replicate that in the example Acquisition set up ?

    I have tabled a CAR 350194 to address this behavior more with R & D, but unfortunately I can't promise a timeline for the resolution.  I recommend at this stage unless you change Acquisition is configured when you set up your code instead of starting from scratch.  Support at home OR you can call at any time to check the condition of this CAR.

    To answer your question of why a use case takes more time than another, it will take more time to study according to the guidelines of this CAR.  We have already mentioned there is some overhead involved with multi-record fetch, but whether or not the time more or less long you see are good times is something that R & D will have to answer.

    Please let me know if you can confirm what I see by testing.

    -Andrew

  • query sql delicate... date of the created object.

    friends...
    I am trying to solve this query sql delicate for some time, but unable to progress when it comes to this day...

    Q.
    Query dba_objects and list all tables created yesterday ' sysdate - 1' and in another column of the list all the tables created ' sysdate - 7'.

    -query below gives me to yesterday, but don't know how to have 'Last_week' column filled... maybe I join?
    select owner, object_name, to_char(created, 'MM-DD-YYYY HH24:MI:SS') "Yesterday", to_char(created, 'MM-DD-YYYY HH24:MI:SS') "Last_Week"
    from dba_objects
    where object_type = 'TABLE'
    and created >=trunc(sysdate - 1)
    and created < trunc(sysdate)
    appreciate your time and effort in looking at this...

    Thank you

    Published by: khallas301 on March 19, 2013 09:27
    typo edited... Thanks to frank

    khallas301 wrote:
    Query dba_objects and list all tables created yesterday ' sysdate - 1' and in another column of the list all the tables created ' sysdate - 7'.

    Well, sysdate - 7 ways months ago, not last week. If this is what you want, then:

    select  owner,
            object_name,
            case
              when trunc(created) = trunc(sysdate - 1) then to_char(created,'MM-DD-YYYY HH24:MI:SS')
            end "Yesterday",
            case
              when trunc(created) = trunc(sysdate - 7) then to_char(created, 'MM-DD-YYYY HH24:MI:SS')
            end "Week Ago"
      from  dba_objects
      where object_type = 'TABLE'
        and (
                trunc(created) = trunc(sysdate - 1)
             or
                trunc(created) = trunc(sysdate - 7)
            )
    /
    

    SY.

  • Select the query takes a long time to run the second time

    Hi all

    I have Oracle 11 GR 1 material in windows server 2008 R2.
    I have a few tables with 10 million documents. When I run the select query to the tables of first time, it gives me a result in 15 seconds, but if I run the script even twice in the same session, I get the result in 15 minutes to complete...

    Why it's happening? What can be the solution for this?

    Thank you and best regards,
    Vikash jain (DBA Junior)

    What I know is that this feedback from cardinality generates more problems than improving the performance is, in fact, its main objective. But first look at which is was written in the link I posted above

    "Return of cardinality was introduced in the Oracle 11 g database 2. The purpose of this function is to automatically improve plans for queries that are executed repeatedly, _For that the optimizer does not estimate the cardinalities in the properly_ plan"

    If the cardinality feedback kiks in your case it is certainly because you do not have an exact statistics. Get the command the explain plans that I have shown you with the E-lines and A-lines (lines estimates and actual lines) and see where things are poorly estimated.

    If you want to disable the cardinality feedback then add the indicator according to your request

    /*+ opt_param('_optimizer_use_feedback','false') */
    

    Best regards

    Mohamed Houri
    www.hourim.WordPress.com

    Published by: Mohamed Houri on November 22, 2012 02:11
    Published by: I was looking for the exact indication of how do I deactivate the cardinality feedback and I foud in an ot the Dominic post in otn :-)

    Published by: Mohamed Houri on November 22, 2012 02:15

  • ICX session sharing between EBS and ADF. Navigate from EBS page by page of ADF custom application. but every time I get the session as a GUEST, even if I give valid credentils to enter into EBS.

    Hello

    I am integrating EBS and ADF through sharing of session ICX. Navigate from EBS page by page of ADF custom application. but whenever I get session as GUEST (VALID_GUEST), even if I give credentials valid at the EBS system. I should get a valid session that I have connected with a valid user. As it it a VALID_GUEST that the status of cookie icx, back (he got newspapers/debug) and I am.  Comparing with status cookie VALID icx, so every time system opens the Apps login page.  I used fndext.jar to do this. Please help me on this. I'm not sure it's a problem with DB/EBS EBS system, or the code of the adf. My code spruce is given below.

    import java.io.IOException;

    import java.sql.Connection;

    import java.sql.SQLException;

    Import javax.faces.application.FacesMessage;

    Import javax.faces.context.FacesContext;

    to import javax.servlet.http.HttpServletRequest;

    to import javax.servlet.http.HttpServletResponse;

    Import oracle.adf.controller.v2.lifecycle.Lifecycle;

    Import oracle.adf.controller.v2.lifecycle.PagePhaseEvent;

    Import oracle.adf.controller.v2.lifecycle.PagePhaseListener;

    Import oracle.apps.fnd.ext.common.AppsRequestWrapper;

    Import oracle.apps.fnd.ext.common.CookieStatus;

    Import oracle.apps.fnd.ext.common.EBiz;

    Import oracle.apps.fnd.ext.common.Session;

    / public class MyCustomPhaseListner implements PagePhaseListener {}

    public MyCustomPhaseListner() {}

    Super();

    }

    AppsRequestWrapper wrappedRequest = null;

    HttpServletRequest request = null;

    HttpServletResponse response = null;

    String currentUser store = null;

    String currentUserId = null;

    {} public void afterPhase (PagePhaseEvent pagePhaseEvent)

    If (pagePhaseEvent.getPhaseId () == Lifecycle.PREPARE_RENDER_ID) {}

    System.out.println ("in phase");

    If (wrappedRequest! = null & &)

    wrappedRequest.getConnection ()! = null) {}

    try {}

    If (! wrappedRequest.getConnection () .isClosed ())

    wrappedRequest.getConnection (m:System.NET.Sockets.Socket.close ());

    } catch (SQLException e) {}

    }

    }

    }

    }

    {} public void beforePhase (PagePhaseEvent pagePhaseEvent)

    If (pagePhaseEvent.getPhaseId () == Lifecycle.INIT_CONTEXT_ID) {}

    Channel agent = null;

    System.out.println ("forward Phase");

    FacesContext fctx = FacesContext.getCurrentInstance ();

    request =

    (HttpServletRequest) fctx.getExternalContext () .getRequest ();

    answer =

    (HttpServletResponse) fctx.getExternalContext () m:System.NET.FtpWebRequest.GetResponse ();

    CookieStatus icxCookieStatus = null;

    try {}

    Connection EBSconn = ConnectionProvider.getConnection ();

    EBiz instance = EBizUtil.getEBizInstance ();

    wrappedRequest =

    new AppsRequestWrapper (request, response, EBSconn,

    (instance);

    A session = wrappedRequest.getAppsSession (true);

    tried with "a session = wrappedRequest.getAppsSession ();" / / do not return not of any session

    icxCookieStatus =

    session.getCurrentState () .getIcxCookieStatus ();

    Agent = wrappedRequest.getEbizInstance () .getAppsServletAgent ();

    If (! icxCookieStatus.equals (CookieStatus.VALID)) {}

    response.sendRedirect (agent + "AppsLocalLogin.jsp");

    return;

    }

    currentUser = session.getUserName ();

    currentUserId = session.getUserId ();

    } catch (Exception ob) {}

    ob.printStackTrace ();

    }

    FacesMessage message =

    new FacesMessage ("Session is:" + icxCookieStatus + "" +)

    currentUser + "" + currentUserId);

    fctx.addMessage (null, message);

    }

    }

    }

    Have you checked

    https://blogs.Oracle.com/jruiz/entry/adf_and_oracle_e_business

    https://blogs.Oracle.com/jruiz/entry/adf_and_oracle_e_business2

    http://www.Oracle.com/technetwork/tutorials/EBS-SDK-ADF-1887167.PDF

    https://www.YouTube.com/watch?v=9wGv7yxRgVU

    Timo

  • FDM: Import performance Tuning, where "import processes: Map" is more times that takes the report

    Hi Experts,

    FDM report shows the "import process: map ' activity is much more time during the import process completed by do from the web interface for a unique time period (file 1 month = 4 MB). Please suggest how I can improve it?

    Thank you

    Vivek

    In this doc attached are details on parameters DB contribute to improve performance.

    http://docs.Oracle.com/CD/E40248_01/EPM.1112/fdm_dba.PDF

    A tip, I would also give is the importance of the order of mapping. Basically, if you like the mappings you should order based on volume. If a similar mapping affects a large volume of documents, you want to apply only the first. This allows to reduce the Recordset down over time so that the least used mappings go against the smallest possible demappe data set.

  • Error SQL query while trying to fetch the record that has MAX Effective_Date

    Hello

    Could you please suggest me on request below.
    I need to select the record which is having Maximam effectivity_date.
    Below a no not gives a group of expressin

    SELECT safety_stock_quantity
    OF mtl_safety_stocks
    WHERE inventory_item_id = 936
    GROUP BY safety_stock_quantity
    After having effectivity_date = MAX (effectivity_date);



    Thank you
    Pravin

    855902 wrote:
    Hello

    Could you please suggest me on request below.
    I need to select the record which is having Maximam effectivity_date.
    Below a no not gives a group of expressin

    SELECT safety_stock_quantity
    OF mtl_safety_stocks
    WHERE inventory_item_id = 936
    GROUP BY safety_stock_quantity
    After having effectivity_date = MAX (effectivity_date);

    Thank you
    Pravin

    SQL> select * from emp where mep_hiredate = (select max(mep_hiredate) from emp);
    
        EMP_ID EMP_NAME   EMP_SAL                    MEP_HIREDATE
    ---------- ---------- ------------------------------ -------------------
          COMM
    ----------
          1 ED           2                     2010-12-20 09:40:50
          2
    
  • Query takes more time to execute the query

    Hi all

    Want to help out me, I am request runing takes longer run time.

    Query:

    Select


    *



    Of


    (

    SELECT

    Decode (cla.r_description, 'Central région', 'CR', 'Southern', 'SR', "Northern Region", 'NR', 'Region of Mehran', 'SIR', 'Quetta HO', 'QHO') as a region.
    ''''|| TO_CHAR (trx.trx_number) as challan_Num,
    St.Account_Number as Roll_Number,
    St.party_name as Student_Name
    CLA.class_name: '-' | St.section as Class_Section,
    period.period_name as Fee_Period,
    pay. TRX_DATE as Issue_date,
    pay. End_date as end_date,
    Pay.due_date as valid_date,
    Amount pay.amount_due_remaining

    Of
    ra_customer_trx_all trx,
    St the_city_school_students,
    class_v_table cla,
    period of bill_period
    ar_payment_schedules_all pay
    WHERE

    Trx.attribute_category = nvl(:P_CHALLAN_TYPE,trx.attribute_category)
    AND trx.attribute2 = cla.fee_structure_id
    AND trx.bill_to_customer_id = st.cust_account_id
    AND trx.org_id = nvl(:p_org_id,trx.org_id)
    AND trx.attribute1 = period.period_id
    AND trx.customer_trx_id = pay.customer_trx_id
    AND cla.branch_id = NVL (: p_branch, cla.branch_id)
    AND to_char(trx.creation_date,'YYYY/MM/DD') between substr(:p_date_from,1,10) and substr(:p_date_to,1,10)
    and pay.amount_due_remaining > 0

    - AND cla.class_name = NVL (p_class, cla.class_name)

    UNION ALL

    Select

    decode (A.r_description region, 'Central', 'CR', 'Southern', 'SR', "Northern Region", 'NR', 'Region of Mehran', 'SIR', 'Quetta HO', 'QHO') as region
    acd. ADM_CHALLAN_NO as challan_Num
    bsr. STUDENT_REGISTRATION_NO as Roll_Number
    bsr. STUDENT_NAME as Student_Name
    British Colombia. Class_name as Class_Section
    ,' ' as Fee_Period
    acd. ADM_ISSUE_DATE as Issue_date
    acd. ADM_due_DATE as end_date
    acd. ADM_due_DATE as valid_date
    quantity (ac.original_total + ac.adm_original_optional_total)


    of bill_student_registration bsr
    adm_challan ac
    adm_challan_detail acd
    bill_class, BC.
    branch_network_region_link one

    where
    AC. STUDENT_REGISTARTION_ID = bsr. STUDENT_REGISTRATION_ID
    AND British Colombia. CLASS_ID = bsr. REGISTRATION_CLASS_ID
    AND a.BRANCH = bsr. BRANCH_ID
    AND ac.adm_challan_id = acd.adm_challan_id
    - and ADM_PAID = n
    AND bsr.ORG_ID = nvl(:p_org_id,bsr.ORG_ID)
    AND to_char (bsr. STUDENT_REGISTRATION_DATE, ' DD/MM/YYYY') between substr(:p_date_from,1,10) and substr(:p_date_to,1,10)
    AND decode (A.r_description region, 'Central', 'CR', 'Southern', 'SR', "Northern Region", 'NR', 'Region of Mehran', 'SIR', 'Quetta HO', 'QHO') is not null
    AND bsr. BRANCH_ID = NVL (: p_branch, bsr.) BRANCH_ID)

    )


    Union of all the

    SELECT

    Decode (cla.r_description, 'Central région', 'CR', 'Southern', 'SR', "Northern Region", 'NR', 'Region of Mehran', 'SIR', 'Quetta HO', 'QHO') as a region.
    ''''|| TO_CHAR (trx.trx_number) as challan_Num,
    St.Account_Number as Roll_Number,
    St.party_name as Student_Name
    CLA.class_name: '-' | St.section as Class_Section,
    period.period_name as Fee_Period,
    pay. TRX_DATE as Issue_date,
    pay. End_date as end_date,
    Pay.due_date as valid_date,
    Amount pay.amount_due_remaining

    Of
    ra_customer_trx_all trx,
    St the_city_school_students,
    class_v_table cla,
    period of bill_period
    ar_payment_schedules_all pay
    WHERE

    Trx.attribute_category = nvl(:P_CHALLAN_TYPE,trx.attribute_category)
    AND trx.attribute2 = cla.fee_structure_id
    AND trx.bill_to_customer_id = st.cust_account_id
    - AND trx.org_id = nvl(:p_org_id,trx.org_id)
    AND trx.org_id = nvl (trx.org_id, trx.org_id)
    AND trx.attribute1 = period.period_id
    AND trx.customer_trx_id = pay.customer_trx_id
    - AND cla.branch_id = NVL (: p_branch, cla.branch_id)
    AND cla.branch_id = NVL (cla.branch_id, cla.branch_id)
    AND to_char(trx.creation_date,'YYYY/MM/DD') < substr(:p_date_from,1,10)
    and pay.amount_due_remaining > 0
    and st.account_number in
    (
    SELECT distinct
    St.Account_Number as Roll_Number

    Of
    ra_customer_trx_all trx,
    St the_city_school_students,
    class_v_table cla,
    period of bill_period
    ar_payment_schedules_all pay
    WHERE

    Trx.attribute_category = nvl(:P_CHALLAN_TYPE,trx.attribute_category)
    AND trx.attribute2 = cla.fee_structure_id
    AND trx.bill_to_customer_id = st.cust_account_id
    AND trx.org_id = nvl(:p_org_id,trx.org_id)
    AND trx.attribute1 = period.period_id
    AND trx.customer_trx_id = pay.customer_trx_id
    AND cla.branch_id = NVL (: p_branch, cla.branch_id)
    AND to_char(trx.creation_date,'YYYY/MM/DD') between substr(:p_date_from,1,10) and substr(:p_date_to,1,10)
    and pay.amount_due_remaining > 0
    )

    Hello

    I see a lot of problem in your query.
    First, there is the request of duplication in Union all, who take.
    There is also the filter condition that is of no use.

    AND trx.org_id = nvl(trx.org_id,trx.org_id)
    
    AND cla.branch_id = NVL (cla.branch_id, cla.branch_id)
    

    Conditional is just out from the first query in the union. and again you choose the same lines using account_number, which is nothing else than the same thing.

    and st.account_number in
    (   SELECT distinct
         st.account_number as Roll_Number
    
         FROM
         ra_customer_trx_all trx,
         the_city_school_students st,
         class_v_table cla,
         bill_period period,
         ar_payment_schedules_all pay
         WHERE
    
         trx.attribute_category = nvl(:P_CHALLAN_TYPE,trx.attribute_category)
         AND trx.attribute2 = cla.fee_structure_id
         AND trx.bill_to_customer_id = st.cust_account_id
         AND trx.org_id = nvl(:p_org_id,trx.org_id)
         AND trx.attribute1 = period.period_id
         AND trx.customer_trx_id = pay.customer_trx_id
         AND cla.branch_id = NVL (:p_branch, cla.branch_id)
         AND to_char(trx.creation_date,'YYYY/MM/DD') between substr(:p_date_from,1,10) and substr(:p_date_to,1,10)
         and pay.amount_due_remaining >0 )
    

    so I think that under query will work

    SELECT
    decode(cla.r_description,'Central Region','CR','Southern Region','SR','Northern Region','NR','Mehran Region','MR','Quetta HO','QHO') as Region,
    ''''|| to_char(trx.trx_number) as challan_Num,
    st.account_number as Roll_Number,
    st.party_name as Student_Name,
    cla.class_name||'-'||st.section as Class_Section,
    period.period_name as Fee_Period,
    pay.TRX_DATE as Issue_date ,
    pay.DUE_DATE as due_date,
    pay.due_date as valid_date,
    pay.amount_due_remaining amount
    FROM
    ra_customer_trx_all trx,
    the_city_school_students st,
    class_v_table cla,
    bill_period period,
    ar_payment_schedules_all pay
    WHERE
    trx.attribute_category = nvl(:P_CHALLAN_TYPE,trx.attribute_category)
    AND trx.attribute2 = cla.fee_structure_id
    AND trx.bill_to_customer_id = st.cust_account_id
    AND trx.org_id = nvl(:p_org_id,trx.org_id)
    AND trx.attribute1 = period.period_id
    AND trx.customer_trx_id = pay.customer_trx_id
    AND cla.branch_id = NVL (:p_branch, cla.branch_id)
    AND (
         (trx.creation_date between TO_DATE(substr(:p_date_from,1,10),'YYYY/MM/DD') and TO_DATE(substr(:p_date_to,1,10),'YYYY/MM/DD'))
              OR
         (trx.creation_date < TO_DATE(substr(:p_date_from,1,10),'YYYY/MM/DD'))
         )
    and pay.amount_due_remaining >0
    UNION ALL
    select
    decode(A.r_description,'Central Region','CR','Southern Region','SR','Northern Region','NR','Mehran Region','MR','Quetta HO','QHO') as Region
    ,acd.ADM_CHALLAN_NO as challan_Num
    ,bsr.STUDENT_REGISTRATION_NO as Roll_Number
    ,bsr.STUDENT_NAME as Student_Name
    ,bc.CLASS_NAME as Class_Section
    ,' ' as Fee_Period
    ,acd.ADM_ISSUE_DATE as Issue_date
    ,acd.ADM_due_DATE as due_date
    ,acd.ADM_due_DATE as valid_date
    ,(ac.original_total+ac.adm_original_optional_total) amount
    from bill_student_registration bsr
    , adm_challan ac
    , adm_challan_detail acd
    , bill_class bc
    , branch_network_region_link a
    where
    ac.STUDENT_REGISTARTION_ID = bsr.STUDENT_REGISTRATION_ID
    AND bc.CLASS_ID = bsr.REGISTRATION_CLASS_ID
    AND a.BRANCH = bsr.BRANCH_ID
    AND ac.adm_challan_id = acd.adm_challan_id
    ---and ADM_PAID = 'N'
    AND bsr.ORG_ID = nvl(:p_org_id,bsr.ORG_ID)
    AND bsr.STUDENT_REGISTRATION_DATE between TO_DATE(substr(:p_date_from,1,10),'YYYY/MM/DD') and TO_DATE(substr(:p_date_to,1,10),'YYYY/MM/DD')
    AND decode(A.r_description,'Central Region','CR','Southern Region','SR','Northern Region','NR','Mehran Region','MR','Quetta HO','QHO') is not null
    AND bsr.BRANCH_ID = NVL (:p_branch, bsr.BRANCH_ID);
    

    Hope this helps

    Thank you!!!
    Didier

  • Query SQL with multiple tables - what is the most effective way?

    Hello I learn PL/SQL. I have a simple procedure, where I need to find the number of employees and departments by location according to location_id user input.

    I have 3 Tables:

    LOCATIONS
    Location_id (pk)
    location_name
    ...
    DEPARTMENTS
    department_id (pk)
    Location_id (fk)
    department_name
    ....
    EMPLOYEES
    employee_id (pk)
    department_id (fk)
    Employee_Name
    ....

    1 location can have 0 - SEVERAL departments
    1 employee has 1 Department

    Here's the query I come up with for PL/SQL procedure:

    / * Ecount, Dcount are variable NUMBERS * /.

    SELECT SUM (EmployeeCount), COUNT (DepartmentNumber)
    IN Ecount, Dcount
    Of
    (SELECT COUNT (employee_id) EmployeeCount, department_id DepartmentNumber
    Employees
    GROUP BY department_id
    HAVING department_id IN
    (SELECT department_id
    Ministries
    WHERE location_id = userInput));

    I get the correct result, but I wonder if my query is on the right track and if there is a more "efficient" method to do so.
    Thanks in advance for help a beginner.

    Hello

    Welcome to the forum!

    Something like this will be more effective:

    SELECT    COUNT (employee_id)               AS ECount
    ,       COUNT (DISTINCT department_id)     AS DCount
    FROM       employees
    WHERE       department_id IN (     SELECT     department_id
                        FROM      departments
                        WHERE      location_id = :userInput
                      )
    ;
    

    You should also try a join instead of the IN subquery.

    For efficiency, do only the things you need to do.
    For example, you need not a number of employees in each Department, in order to not calculate one. This means that you will not need the notice online, so do not have.
    You needn't PL/SQL for this work, so don't use PL/SQL, if you do not have to (I know this question was out of context, then you may have good reasons to do this in PL/SQL.)

    Perform all the filtering as soon as possible. Do not waste it effort on the things that will not be used.
    An example of this is: never use a HAVING clause when you can use a WHERE clause. What is the difference between a WHERE clause and a HAVING clause? The WHERE clause is applied until the aggregate functions are calculated and the HAVING clause is applied after; There is no other difference. Therefore, if the HAVING clause is not reference an aggregate function, it could be done in a WHERE clause instead.

  • BitDefender Quickscan is in the lower right corner of Firefox, but is not installed on the computer. I can't use it or delete it. I want to go!

    BitDefender window is constantly present in the lower right of Firefox, and it covers the lower scroll button. It is said to "Bitdefender QuickScan you don't have not scanned your computer in some time. Would you start QuickScan now? Clicking on it does nothing. BitDefender does not appear in the programs or remove programs in Control Panel. I searched and deleted all references to bitdefender in the registry, but the small window is still annoyingly. How can I get rid of him?

    BitDefender QuickScan Web Netscape Plugin shows in your addons > plugins. You must remove it from there.

    See your details above system.

Maybe you are looking for