Report is taking time to execute the following query

Hi All,
I have one query using in reports6i,which i am describing down,its taking half an hour to execute.
I need to tune the query,if any one could help or any suggestions...........highly appreciable.
SELECT +ALL_ROWS
DISTINCT sm.orgn_code,
sm.sample_no,
-- DECODE (sm.batch_id, NULL, 'Item/Locn', 'Production') AS sample_type,
NVL2(sm.batch_id, 'Production', 'Item/Locn') AS sample_type,
sm.date_drawn,
su.user_name AS drawn_by,
im.item_no,
lm.lot_no,
im.inv_type,
qt.test_code,
rm.user_name AS result_by,
rm.result_date,
qt.test_type,
qv.min_value_num,
qv.max_value_num,
DECODE(qt.test_type, 'N', TO_CHAR(qv.min_value_num) || ' - ' || TO_CHAR(qv.max_value_num), NULL) AS the_range,
DECODE(qt.test_type, 'N', TO_CHAR(qv.target_value_num), qv.target_value_char) AS the_spec,
DECODE(qt.test_type, 'N', TO_CHAR(rm.result_value_num), rm.result_value_char) AS the_result,
DECODE(qt.test_unit, 'N/A', NULL, qt.test_unit) AS qc_uom,
DECODE(sm.sample_disposition,
'0RT',
'RETAIN',
'1P',
'PENDING',
'2I',
'IN PROGRESS',
'3C',
'COMPLETE',
'4A',
'ACCEPT',
'5AV',
'ACCEPT WITH VARIANCE',
'6RJ',
'REJECT',
'7CN',
'CANCEL',
NULL) AS disposition
FROM gmd.gmd_samples sm,
-- gmd.gmd_results rm,
gmd.gmd_qc_tests_b qt,
gmd.gmd_specifications_b sp,
gmd.gmd_spec_tests_b qv,
gmi.ic_lots_mst lm,
apps.ic_item_mst im,
applsys.fnd_user su,
(SELECT gr.result_date,
gr.sample_id,
gr.test_id,
gr.result_value_num,
gr.result_value_char,
ru.user_name
FROM gmd_results gr,
applsys.fnd_user ru
WHERE (to_date(to_char(gr.result_date,'mm/dd/yyyy'),'mm/dd/yyyy') BETWEEN
to_date(to_char(:p_2_start_date,'mm/dd/yyyy'),'mm/dd/yyyy') AND
to_date(to_char(:p_3_end_date,'mm/dd/yyyy'),'mm/dd/yyyy'))
AND gr.result_date IS NOT NULL
AND ru.user_id = gr.last_updated_by) rm
WHERE 1 = 1 --rm.result_date IS NOT NULL
-- AND TO_DATE (TO_CHAR (rm.result_date, 'mm/dd/yyyy'), 'mm/dd/yyyy') >=TO_DATE (TO_CHAR (:p_2_start_date, 'mm/dd/yyyy'), 'mm/dd/yyyy')
-- AND TO_DATE (TO_CHAR (rm.result_date, 'mm/dd/yyyy'), 'mm/dd/yyyy') <=TO_DATE (TO_CHAR (:p_3_end_date, 'mm/dd/yyyy'), 'mm/dd/yyyy')
AND im.inv_type = NVL (UPPER (:p_inv_type), im.inv_type)
AND sm.orgn_code = UPPER (:p_1_orgn)
AND sm.item_id = lm.item_id --double
AND sm.lot_id = lm.lot_id
AND sm.item_id = lm.item_id --double
AND sm.item_id = im.item_id
AND sp.item_id = im.item_id
AND rm.sample_id = sm.sample_id
AND su.user_id = sm.sampler_id
-- AND ru.user_id = rm.last_updated_by
AND rm.test_id = qt.test_id
AND qt.test_id = qv.test_id
AND qv.spec_id = sp.spec_id
AND sp.spec_status = 700
AND qt.test_code LIKE NVL(:p_test, '%')
AND ( ( qt.test_type = 'N'
AND ( rm.result_value_num < qv.min_value_num
OR rm.result_value_num > qv.max_value_num))
OR ( qt.test_type <> 'N'
AND rm.result_value_char <> 'OK'
AND rm.result_value_char <> qv.target_value_char)
Thanks in Advance

You may want to consider demoralization views/tables or create indexes etc. to improve performance. Post it to
PL/SQL
to get more and quicker responses.

Similar Messages

  • How to add a receipt number in the following Query for PO Report

    Hi Guys,
    I need a help regarding following query.
    Its a PO report for 11.5.10.2
    select distinct pv.segment1 supplier_number,
    pv.vendor_name supplier_name,
    pha.segment1 po_number,
    pha.revision_num revision_num,
    pha.authorization_status po_status,
    to_char(pha.creation_date, 'DD/MM/YYYY') creation_date,
    pha.currency_code currency_code,
    pla.sum_amount_ordered sum_amount_ordered,
    pda.sum_quantity_ordered sum_quantity_ordered,
    pda.sum_amount_received sum_amount_received,
    pda.sum_quantity_received sum_quantity_received,
    (pla.sum_amount_ordered - pda.sum_amount_received) sum_accrued, --AVI
    ( pda.sum_quantity_ordered - pda.sum_quantity_received) quantity_accrued, --AVi
    to_char(rsl.date_receipt, 'DD/MM/YYYY') date_receipt,
    -- rsl.receipt_num receipt_number,
    ppa.segment1 project_code, ppa.project_status_code, --10.0.0.4
    aia.invoice_num invoice_num,
    aia.invoice_date invoice_date, --AVI 
    aia.creation_date invoice_creation_date, --AVI 
    aia.amount invoice_amount_allocated_to_po, --AVI
    pla.purchase_basis,
    pla.category_id,
    -- pda.item_description,
    haou.name organisation, --10.0.0.3
    pda.sum_quantity_billed sum_quantity_billed , --10.0.0.3
    gcc1.CONCATENATED_SEGMENTS,
    gcc2.CONCATENATED_SEGMENTS
    from po_headers_all pha,
    po_vendors pv,
    pa_projects_all ppa,
    hr_all_organization_units haou,
    (select po_header_id,
    sum(quantity * unit_price) sum_amount_ordered,
    org_id,
    purchase_basis,
    category_id
    -- pla.item_description,
    from po_lines_all
    group by po_header_id, org_id
    , purchase_basis,
    category_id
    -- pla.item_description
    ) pla,
    (select pla.po_header_id,
    pda.project_id,
    sum(pda.quantity_ordered) sum_quantity_ordered,
    sum(pda.quantity_delivered * pla.unit_price) sum_amount_received,
    sum(pda.quantity_delivered) sum_quantity_received,
    sum(pda.quantity_billed) sum_quantity_billed, --10.0.0.3
    accrual_account_id
    from po_distributions_all pda, po_lines_all pla
    where pla.po_line_id = pda.po_line_id
    group by pla.po_header_id, pda.project_id,accrual_account_id
    ) pda,
    (select po_header_id, charge_account_id,
    -- rsh.receipt_num,
    min(rsl.creation_date) date_receipt
    from rcv_shipment_lines rsl
    where rsh.SHIPMENT_HEADER_ID=rsl.SHIPMENT_HEADER_ID
    group by po_header_id,charge_account_id
    ) rsl,
    (select distinct aia.invoice_num, pda.po_header_id , aia.invoice_date --10.0.0.3
    , aia.creation_date , sum(aida.amount) amount
    from po_distributions_all pda,
    ap_invoice_distributions_all aida,
    ap_invoices_all aia
    where pda.po_distribution_id = aida.po_distribution_id(+)
    and aia.invoice_id(+) = aida.invoice_id
    Group by
    aia.invoice_num, pda.po_header_id , aia.invoice_date --10.0.0.3
    , aia.creation_date) aia,
    (select haou2.organization_id, haou2.name
    from fnd_flex_value_sets ffvs,
    fnd_flex_value_norm_hierarchy ffvnh,
    fnd_flex_values_vl ffvv,
    hr_all_organization_units haou1,
    FND_FLEX_VALUE_CHILDREN_V ffvcv,
    hr_all_organization_units haou2
    where ffvs.FLEX_VALUE_SET_NAME = 'CAP_CODE_BU'
    and ffvs.FLEX_VALUE_SET_ID = ffvnh.flex_value_set_id
    and ffvnh.parent_flex_value like 'PO%'
    and ffvv.FLEX_VALUE_SET_ID = ffvnh.flex_value_set_id
    and ffvv.FLEX_VALUE between ffvnh.child_flex_value_low and ffvnh.child_flex_value_high
    and substr(haou1.name, 1, Instr(haou1.name, '-')) =
    substr(ffvv.DESCRIPTION, 1, Instr(ffvv.DESCRIPTION, '-'))
    and haou1.organization_id = fnd_global.org_id
    and ffvcv.parent_flex_value = ffvnh.parent_flex_value
    and ffvcv.flex_value_set_id = ffvs.flex_value_set_id
    and substr(haou2.name, 1, Instr(haou2.name, '-')) =
    substr(ffvcv.DESCRIPTION, 1, Instr(ffvcv.DESCRIPTION, '-'))
    union --10.0.0.1
    select f.organization_id, f.name --10.0.0.1
    from hr_all_organization_units f --10.0.0.1
    where f.organization_id = fnd_global.ORG_ID --10.0.0.1
    ) bu
    , po_line_locations_all plla --10.0.0.4
    , gl_code_combinations_kfv gcc1
    ,gl_code_combinations_kfv gcc2
    where pv.vendor_id = pha.vendor_id
    and pla.po_header_id = pha.po_header_id
    and pda.po_header_id = pha.po_header_id
    and pha.po_header_id = rsl.po_header_id(+)
    and pda.project_id = ppa.project_id(+)
    and pha.po_header_id = aia.po_header_id(+)
    and aia.po_header_id = pha.po_header_id
    and pla.org_id = haou.organization_id
    and pha.authorization_status in ('APPROVED', 'OPEN')
    and plla.po_header_id = pha.po_header_id --10.0.0.4
    and plla.closed_code in ('APPROVED', 'OPEN', 'CLOSED FOR INVOICE', 'CLOSED FOR RECEIVING', 'CANCELLED') --10.0.0.4
    and bu.organization_id = haou.organization_id
    AND gcc1.code_combination_id = pda.accrual_account_id
    AND gcc2.code_combination_id =rsl.CHARGE_ACCOUNT_ID
    In the following query I have commented receipt_num using the table rcv_transaction_headers.
    If I uncomment it the query results huge number of unexpected report.
    How can I add receipt number to the following query?
    Should I use rcv_transactions. If yes, what would be the join conditions.
    Kindly help as its urgent.
    Thanks in advance.
    Regards
    Avijit

    Sandeep is correct. I don't have time to tell you the correct query, but mine is something like this based on Sandeep's information:
    SELECT rsh.receipt_num
    FROM   rcv_transactions      rcvt,
           po_lines_all          pla,
           rcv_shipment_headers  rsh
    WHERE  rcvt.shipment_header_id   = rsh.shipment_header_id
    AND    rcvt.PO_LINE_ID          = pla.PO_LINE_ID
    AND    pla.item_id              = (select distinct inventory_item_id
    from mtl_system_items
    where segment1 = '1216107-2')

  • MY QUERY IS TAKING TIME WHILE EXECUTING IN WAD

    HI BW GURUS
    If i execute the report(using query with variables) which contains 8,50,000 records in WAD then its taking more than 900 seconds and say Connection timed out at the end.
    If i execute the same query in Query designer using Web browser then it will take 400 seconds to show all the data in hierarchy or tabular view.
    I've done tuning using RSRT on query read mode and persistent mode etc..
    Can you please help me?

    Execution plan depends on many factors, statistics status of the objects, system statistics if you are using, init.ora parameters like mulitblock_read_count, parallellism, etc.
    If you want to use same execution plan for all database, you should refer stored_outline. In 10g you can try sql profiling.
    Ashok

  • AutoConfig could not successfully execute the following scripts afcpnode.cm

    When i run the autoconfig, it end up with following error message:
    [AutoConfig Error Report]
    The following report lists errors AutoConfig encountered during each
    phase of its execution. Errors are grouped by directory and phase.
    The report format is:
    <filename> <phase> <return code where appropriate>
    [SETUP PHASE]
    AutoConfig could not successfully execute the following scripts:
    Directory: d:\oracle\prodcomn\admin\install\PROD_oraprod
    afcpnode.cmd INSTE8_SETUP 1
    [PROFILE PHASE]
    AutoConfig could not successfully execute the following scripts:
    Directory: d:\oracle\prodcomn\admin\install\PROD_oraprod
    afcpgsm.cmd INSTE8_PRF 1
    AutoConfig is exiting with status 2
    this error is comming after running the FNDCPASS utility to change apps and other schema password. i also changed the password for sys and system and remote_login_passwordfile parameter is set to exclusive. This error is comming on application node. On Database node there is no error.
    Thanls and Regards

    Is this problem is linked with apps user's password length because it is 17 char long and may be apps password variable is not that much longI could not find any reported bugs/notes about the password length, only a bug (5859062) about the domain name length.
    Note: 418403.1 - AUTOCONFIG FAILURE AFCPNODES.SQL DOMAIN NAME LONGER THAN 30 CHARACTERS
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=418403.1

  • AutoConfig could not successfully execute the following scripts bisdblrp.cm

    When i run the autoconfig, it end up with following error message:
    AutoConfig could not successfully execute the following scripts:
    Directory: E:\oracle\fincomn\admin\install\FIN_ora-fin
    bisdblrp.cmd INSTE8_APPLY -1
    this error is comming after running the FNDCPASS utility to change apps and other schema password. i also changed the password for sys and system and remote_login_passwordfile parameter is set to exclusive.
    AutoConfig is exiting with status 1
    regards

    There are many reported Metalink notes about bisdblrp.sh (bisdblrp.cmd), here are some links:
    Note: 397773.1 - bisdblrp.sh failed with ORA-01031: insufficient privileges while running Autoconfig
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=397773.1
    Note: 431079.1 - Bisdblrp.sh Fails With ORA-06502 Error
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=431079.1
    Note: 417073.1 - Bisdblrp.Sh Fails During Clone Autoconfig
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=417073.1
    Note: 360679.1 - Adautocfg errors on bisdblrp.sh - buffer too small ora-06502
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=360679.1
    So, checking AutoConfig log file should be helpful in revealing more details about the error.

  • When connecting my iphone 4 to itunes for the first time i get the following message "cannot connect to this device because Apple Mobile Service is not started" what does this mean and how do I solve it?

    when connecting my iphone 4 to itunes for the first time i get the following message "cannot connect to this device because Apple Mobile Service is not started" what does this mean and how do I solve it?

    I'd start with the following document with that one:
    iPhone, iPad, iPod touch: How to restart the Apple Mobile Device Service (AMDS) on Windows

  • While executing the following pl/sql block   Iam getting  following error

    While executing the following pl/sql block
    Iam getting following error
    ORA-06550: line 5, column 11:
    PLS-00320: the declaration of the type of this expression is incomplete or malformed
    ORA-06550: line 5, column 11:
    PL/SQL: Item ignored
    declare
    TYPE t_customer_details IS REF CURSOR;
    o_customer_details t_customer_details;
    v_rec o_customer_details%ROWTYPE;
    begin
    o_customer_details:=pkg_search.fngetcustdetails( 2727,1000841, NULL,NULL,119105329);
    LOOP
    FETCH o_customer_details INTO rec ;
    EXIT WHEN o_customer_details%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(' print' );
    END LOOP;
    CLOSE o_customer_details;
    end;

    sorry
    declare
    TYPE t_customer_details IS REF CURSOR;
    o_customer_details t_customer_details;
    begin
    o_customer_details:= pkg_search.fngetcustdetails( 2727,1000841, NULL,NULL,119105329);
    FOR v_rec IN o_customer_details
    LOOP
      DBMS_OUTPUT.PUT_LINE(' print' );
    END LOOP;
    END;I changed code,
    Can you say , o_customer_details:= pkg_search.fngetcustdetails( 2727,1000841, NULL,NULL,119105329); is it right?
    pkg_search.fngetcustdetails return ref cursor??

  • Report Generator has failed, please send the following information to your

    Hi I am trying to generate a report from Designer. I am getting the following error
    Report Generator has failed, please send the following information to your support person
    Assertion failure at crrma_bld_orapp at crrm.cpp:459
    What should I do to get a report from Designer.
    Thanks in advance,
    Archna

    danie,
    please contact oracle support. this will most likely go beyond the scope of what we can do here in the forum.
    thanks,
    ph.

  • HT3275 I recently bought a new Time Capsule and the following message is shown:- "Time Machine could not complete the back up. The backup disk image "/Volumes/Data-1/Brian's iMac.sparsebundle" is already in use." Can anyone help?

    I recently bought a new Time Capsule and the following message has started to show:-
    "Time Machine could not complete the back up. The backup disk image “/Volumes/Data-1/Brian’s iMac.sparsebundle” is already in use."
    Can anyone help?

    Pondini is the resident Time Machine expert on the forums, and he has all the answers.
    Check is excellent Time Machine - Troubleshooting support document
    http://pondini.org/TM/Troubleshooting.html
    See # C17 in particular

  • Difference between DB time OLAP time frontend time when execute the query

    hi all,
    can you any one explain the difference between DB time, OLAP time, frontend time when execute the query

    Each BEx quey form a SQL query which is called query execution plan.
    So,
    DB Time is the time taken to read the record from data base by the SQL statement.
    OLAP time is the time taken to process the calculations/formula involved.
    Frontend Time is the time taken to present the output. For ex: while displaying the data in Bex analyser if your query involves a hierarchy, then the presentation time will be more. It also includes the time user taken to enter the query selection input.

  • HT3775 MPEG-4 movie the quick time I get the following msg---1080p.mp4" could not be opened. The movie's file format isn't recognized.

    MPEG-4 movie the quick time I get the following msg---1080p.mp4” could not be opened. The movie's file format isn't recognized.
    Is there any way to make the movie work....anybody can help????

    Hi,
    Not all .mp4 items are created equal as there are many subvariants.
    You may want to Install Perian and/or Flip4Mac
    8:57 pm      Monday; January 27, 2014
      iMac 2.5Ghz 5i 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • AutoConfig could not successfully execute the following scripts adsvalsn.cm

    When i run the autoconfig, it end up with following error message:
    AutoConfig could not successfully execute the following scripts:
    Directory: E:\oracle\fincomn\admin\install\FIN_ora-fin
    adsvalsn.cmd INSTE8_APPLY -1
    AutoConfig is exiting with status 1
    And because of this error autoconfig takes more than an hour to complete. please help me
    regards

    - Do not run AutoConfig command from any terminal clients
    - Make sure the apps listener is down when you run AutoConfig
    In addition, you may review the following notes:
    Note: 218089.1 - Autoconfig FAQ
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=218089.1
    Note: 393788.1 - Autoconfig Gives Installation Failed And Then Hangs
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=393788.1
    Note: 260365.1 - Adconfig.cmd Hangs When Starting Apps Listener
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=260365.1

  • Unable to execute the following sql statement in Jdev10g -- custom sql quer

    Hi All,
    I have requirement where I need to execute the below Query String through Jdev10g to Sql Server 2005.
    Query string -- select * from table where #InputString
    << Input String -- col3 like 'col%' and col1 like 'col2%' ...... >>
    Here the Input string will be generated by the client and the results will be transferred back to the client. Can any one help how to do this? Input string would like
    col1 like 'col%' and col2 like 'col2%' and so on.. and this is dynamic which can be changed in runtime like col3 like 'col3%' and col1 like 'col1%' and so on..
    I have tokenized the string and assinged the values and executed the custom string through Input parameters for all the fileds instead of only search string .. since table having so many null fields not receiving the exact row counts and records.. hence I have to pass only the Input string as I mentioned like Query String.. If some body got the same concern please let me know..
    Your help would be greatly appreciated..
    Thanks & Regards,
    Khasim

    Hi All,
    Even though the answer is a bit tedious by formulating the where clause with all fields and dynamic parameters, I achieved the goal. But we do have another option to use orcl:query-database in the transformation. But this one give tedious results when you are trying to achieve multiple rows from this. If some one have a better idea to utilize this query-database function, you are most welcome.
    Thanks & Regards,
    Khasim

  • Execute the same query twice, get two different results

    I have a query that returns two different results:
    Oracle Version : 10.2.0.1.0
    I am running the following query on the Oracle server in SQL*Plus Worksheet.
    SELECT COUNT(*)
    FROM AEJOURNAL_S1
    WHERE CHAR_TIME BETWEEN TO_DATE('12-AUG-10 01:17:39 PM','DD-MON-YY HH:MI:SS AM') AND
    TO_DATE('13-AUG-10 14:17:34','DD-MON-YY HH24:MI:SS')
    AND DESC2 LIKE '%'
    AND DESC1 LIKE '%'
    AND DESC2 LIKE '%'
    AND ETYPE LIKE '%'
    AND MODULE LIKE '%'
    AND LEVELL = '11-WARNING'
    ORDER BY ORDD DESC;
    The very first time the query is run, it will return a count of 259. The next time the query is run, lets say, 10 seconds later, it will return a count of 260. The above query is exemplary of the kind of thing I'm trying to do. It seems like the more fields filtered against '%', the more random the count return becomes. Sometime you have to execute the query three or four times before it levels out to a consistent number.
    I'm using '%' as the default for various fields, because this was the easiest thing to do to support a data-driven Web interface. Maybe I have to 'dynamically' build the entire where clause, instead of just parameterizing the elements and having default '%'. Anyway, to eliminate the web interface for the purpose of troubleshooting the above query was run directly on the Oracle server.
    This query runs against a view. The view does a transpose of data from a table.
    Below is the view AEJOURNAL_S1
    SELECT
    CHAR_TIME,
    CHAR_INST,
    BATCH_ID,
    MIN(DECODE(CHAR_ID,6543,CHAR_VALUE)) AS ORDD,
    MIN(DECODE(CHAR_ID,6528,CHAR_VALUE)) AS AREAA,
    MIN(DECODE(CHAR_ID,6529,CHAR_VALUE)) AS ATT,
    COALESCE(MIN(DECODE(CHAR_ID,6534,CHAR_VALUE)),'N/A') AS CATAGORY,
    MIN(DECODE(CHAR_ID,6535,CHAR_VALUE)) AS DESC1,
    MIN(DECODE(CHAR_ID,6536,CHAR_VALUE)) AS DESC2,
    MIN(DECODE(CHAR_ID,6537,CHAR_VALUE)) AS ETYPE,
    MIN(DECODE(CHAR_ID,6538,CHAR_VALUE)) AS LEVELL,
    MIN(DECODE(CHAR_ID,6539,CHAR_VALUE)) AS MODULE,
    MIN(DECODE(CHAR_ID,6540,CHAR_VALUE)) AS MODULE_DESCRIPTION,
    MIN(DECODE(CHAR_ID,6541,CHAR_VALUE)) AS NODE,
    MIN(DECODE(CHAR_ID,6542,CHAR_VALUE)) AS STATE,
    MIN(DECODE(CHAR_ID,6533,CHAR_VALUE)) AS UNIT
    FROM CHAR_BATCH_DATA
    WHERE subbatch_id = 1774
    GROUP BY CHAR_TIME, CHAR_INST, BATCH_ID
    So... why does the query omit rows on the first execution? Is this some sort of optimizer issue. Do I need to rebuild indexes? I looked at the indexes, they are all valid.
    Thanks for looking,
    Dan

    user2188367 wrote:
    I have a query that returns two different results:
    Oracle Version : 10.2.0.1.0
    I am running the following query on the Oracle server in SQL*Plus Worksheet.
    SELECT COUNT(*)
    FROM AEJOURNAL_S1
    WHERE CHAR_TIME BETWEEN TO_DATE('12-AUG-10 01:17:39 PM','DD-MON-YY HH:MI:SS AM') AND
    TO_DATE('13-AUG-10 14:17:34','DD-MON-YY HH24:MI:SS')
    AND DESC2 LIKE '%'
    AND DESC1 LIKE '%'
    AND DESC2 LIKE '%'
    AND ETYPE LIKE '%'
    AND MODULE LIKE '%'
    AND LEVELL = '11-WARNING'
    ORDER BY ORDD DESC;
    The very first time the query is run, it will return a count of 259. The next time the query is run, lets say, 10 seconds later, it will return a count of 260. The above query is exemplary of the kind of thing I'm trying to do. It seems like the more fields filtered against '%', the more random the count return becomes. Sometime you have to execute the query three or four times before it levels out to a consistent number.
    I'm using '%' as the default for various fields, because this was the easiest thing to do to support a data-driven Web interface. Maybe I have to 'dynamically' build the entire where clause, instead of just parameterizing the elements and having default '%'. Anyway, to eliminate the web interface for the purpose of troubleshooting the above query was run directly on the Oracle server.
    This query runs against a view. The view does a transpose of data from a table.
    Below is the view AEJOURNAL_S1
    SELECT
    CHAR_TIME,
    CHAR_INST,
    BATCH_ID,
    MIN(DECODE(CHAR_ID,6543,CHAR_VALUE)) AS ORDD,
    MIN(DECODE(CHAR_ID,6528,CHAR_VALUE)) AS AREAA,
    MIN(DECODE(CHAR_ID,6529,CHAR_VALUE)) AS ATT,
    COALESCE(MIN(DECODE(CHAR_ID,6534,CHAR_VALUE)),'N/A') AS CATAGORY,
    MIN(DECODE(CHAR_ID,6535,CHAR_VALUE)) AS DESC1,
    MIN(DECODE(CHAR_ID,6536,CHAR_VALUE)) AS DESC2,
    MIN(DECODE(CHAR_ID,6537,CHAR_VALUE)) AS ETYPE,
    MIN(DECODE(CHAR_ID,6538,CHAR_VALUE)) AS LEVELL,
    MIN(DECODE(CHAR_ID,6539,CHAR_VALUE)) AS MODULE,
    MIN(DECODE(CHAR_ID,6540,CHAR_VALUE)) AS MODULE_DESCRIPTION,
    MIN(DECODE(CHAR_ID,6541,CHAR_VALUE)) AS NODE,
    MIN(DECODE(CHAR_ID,6542,CHAR_VALUE)) AS STATE,
    MIN(DECODE(CHAR_ID,6533,CHAR_VALUE)) AS UNIT
    FROM CHAR_BATCH_DATA
    WHERE subbatch_id = 1774
    GROUP BY CHAR_TIME, CHAR_INST, BATCH_ID
    So... why does the query omit rows on the first execution? Is this some sort of optimizer issue. Do I need to rebuild indexes? I looked at the indexes, they are all valid.
    Thanks for looking,
    DanIn fact you the first time you ran the query the data has been retrived from disk to memory , in the second time the data is already in memory so the respnse time should be faster ,but if you chagne any condition or column or letter case the optimizer will do the first step (data will be retrived from disk to memory )

  • Problem in finding Exact result by using the following Query

    Hello,
    I am finding difficulty in producing the required result by using the following Query in Reports 6i
    (Note: - The query actual output and the required output are as follows: -)
    SELECT
    DISTINCT
    SH.S_HEAD_CODE,
    B.BILL_ID,
    B.SANCTION_DATE,
    E.EMP_NAME,
    E.EMP_DESIGNATION,
    B.TOTAL_BILL,
    NVL((SH.INITIAL_ALLOCATION-B.TOTAL_BILL), 0) BALANCE
    FROM BILL B, PARAMETERS P,SUB_HEAD SH, EMPLOYEES E, BILL_DETAIL BD
    WHERE
    SH.S_HEAD_CODE=B.S_HEAD_CODE
    AND B.S_HEAD_CODE=BD.S_HEAD_CODE
    AND B.EMP_ID_NO=E.EMP_ID_NO
    AND B.BILL_ID=BD.BILL_ID
    The Output of the above query is as follows: -
    Let say we have Total Amount Sanctioned Rs. 15,000,00/-
    Name Total Bill (Rs.) Balance (Rs.)
    Sohail 7147 1492853
    Saqib 2131 1497869
    Amir 6802 1493198
    Shafiq 1214 1498786
    Note:- In the above output the above query is subtracting the current balance from Total Sanctioned Amount (Rs. 1500000) each time, but
    it should actually subtract the current bill amount from the previous balance like the below said result.
    Name Total Bill (Rs.) Balance (Rs.)
    Sohail 7147 1492853 {Previous Balance - Current Bill Amount (1500000-7147) }........ The previous balance was actual amount Rs. 1500000
    Saqib 2131 1490722 {Previous Balance - Current Bill Amount (1492853 - 2131)}
    Amir 6802 1483920 {Previous Balance - Current Bill Amount (1490722 - 6802)}
    Shafiq 1214 1482706 {Previous Balance - Current Bill Amount (1483920 - 1214)}
    Results Continue...........................
    Please help me to solve this problem.
    Thank you in advance

    just check if this meets your requirements,
    SQL>
    SQL> With t As
      2  (
      3  Select 'Sohail' c1 ,7147 c2 ,1492853 c3 From dual Union All
      4  Select 'Saqib'   ,2131 ,1497869         From dual Union All
      5  Select 'Amir'    ,6802 ,1493198         From dual Union All
      6  Select 'Shafiq' ,1214 ,1498786          From dual
      7  )
      8  Select c1,
      9         c2,
    10         prv_amt - c2 current_amt
    11  From
    12  (
    13  Select c1,
    14         c2,
    15         c3,
    16         lag(c3,1,1500000) over(Order By c3) prv_amt
    17  From t
    18  );
    C1             C2 CURRENT_AMT
    Sohail       7147     1492853
    Amir         6802     1486051
    Saqib        2131     1491067
    Shafiq       1214     1496655
    SQL>

Maybe you are looking for

  • Hy i Upgrade my iPhone and now my mp4 Data are in the file Video and i can't make any Playlist with them! Any idea?

    Hy i Upgrade my iPhone and now my mp4 Data are in the file Video and i can't make any Playlist with them! Any idea?

  • Build Problem in NWDI

    Hi SDN, I have developed an Webdynpro application in NWDI and i have created an external library DC  with all the dependent jars put in to that. I have build the external library DC with the public parts created. These public parts are referred in th

  • Opening & Saving JPEGS in Camera RAW

    I just started using Photoshop ( version CS3) and am concerned that I'm doing things incorrectly already. I'm not doing any huge retouching work, but am using camera RAW to open and clean up some JPEG files. I'm just doing a bit of re-white balancing

  • PID control in FPGA

    Hi, New year wishes to all. the Pid control block of FPGA(I think even in windows), LabVIEW is differentiating the Process variable instead of differentiating the error, Is that same? Regard, N. Madhan Kumar. Solved! Go to Solution. Attachments: pid

  • Re: Mac won't boot up

    Hello, I made a bit of a cardinal schoolboy error yesterday when I started deleting files to free up space from my macbook. I was using a piece of software called Omnidisksweeper which shows all files by size, anyway I got rid of some files that were