Query to find SQL with changed plans

I am trying to find out which SQL statements have changed plans since they were first executed.
I'm trying to run this on all databases from 9i upwards and I am assuming that I have no licensed access to the AWR. However, Statspack is installed on all databases. (So querying things like STATS$SQL_PLAN is fine).
I am having difficulty understanding what HASH_VALUE, OLD_HASH_VALUE and PLAN_HASH_VALUE are, and how they can be used to help answer the problem. I am also trying not to use SQL_ID, since that column isn't there in 9i (I think), and I'd like something that is generically usable from 9i to 11g, if at all possible.
Any hints, please.
Edited by: Catfive Lander on May 14, 2012 12:01 AM

Hi Sakshi,
Try out this query if it can help you !
SELECT a.user_name, a.description, c.responsibility_name, c.creation_date as ASSIGNED_DATE>FROM apps.fnd_user a,
>apps.fnd_user_resp_groups b,
>apps.fnd_responsibility_vl c
>WHERE a.user_id = b.user_id
>AND b.responsibility_id = c.responsibility_id
>AND a.creation_date < = '01-JUN-07'
ORDER BY a.user_name;Thanks,
Anchorage :)

Similar Messages

  • Query to find records with more than 2 decimal places

    I have written the below query to find records with more than 2 decimal places, but it is returning records with decimal places 1 & 2.
    The datatype of the AMT column is NUMBER (without any precision).
    SELECT amt  FROM amount_table
    WHERE substr(amt, instr(amt, '.')) LIKE '.%'
           AND length(substr(amt, instr(amt, '.') + 1)) > 2Output:-
    AMT
    *41591.1*
    *275684.82*
    *64491.59*
    *3320.01*
    *6273.68*
    *27814.18*
    *30326.79*
    131.8413635
    162.5352898
    208.5203816
    8863.314632
    22551.27856
    74.716992
    890.0158441
    2622.299682
    831.6683841
    *1743.14*
    2328.195877
    3132.453438
    5159.827334
    3.236234727
    37.784
    Thanks

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    create table amount_table
      LINE_NUMBER        NUMBER not null,
      FEE_AMT            NUMBER not null
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (60208, 41591.1);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (60213, 275684.82);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (60238, 64491.59);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (63026, 3320.01);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (59906, 6273.68);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (83111, 27814.18);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (83114, 30326.79);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112395, 131.8413634682);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112399, 162.5352898104);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112402, 208.5203815738);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112403, 8863.3146321954);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112406, 22551.2785551322);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112407, 74.716992);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112410, 890.015844079);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112411, 2622.2996817048);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112414, 831.6683840698);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112415, 1743.14);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112418, 2328.1958771886);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112419, 3132.4534379886);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112422, 5159.8273341686);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112423, 3.2362347266);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112426, 37.784);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112427, 198.7423503696);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112430, 0.7220848332);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112433, 12.4149375254);

  • Udating material master with changed planned delivery time in contract

    Hi experts ,
    My question is while we are changing the planned delivery time in the contract we need to udate the same in the material master table . so how to update the material master table with new planned delivery time. Is there any FM exits to udate it and if it is then how to use it.
    thanks
    Anshuman

    Hi Madhu ,
    You are right we can use BAPI_MATERIAL_SAVEDATA but if we use it then we have to use BAPI_COMMIT also to make sure that all the changes are saved completly and if we do BAPI_COMMIT then it maye commit all the task which is in queue and it need to update later. So it is again a issue .
    Thanks
    Anshuman

  • SQL Query - To Find Users with end dated responsibilities

    Oracle Apps ver: 11.5.10.2
    Oracle DB - 9i
    How can i list users and the access assigned to them for a specific division irrespective of the responsibility being end dated at responsibility level

    Hi Sakshi,
    Try out this query if it can help you !
    SELECT a.user_name, a.description, c.responsibility_name, c.creation_date as ASSIGNED_DATE>FROM apps.fnd_user a,
    >apps.fnd_user_resp_groups b,
    >apps.fnd_responsibility_vl c
    >WHERE a.user_id = b.user_id
    >AND b.responsibility_id = c.responsibility_id
    >AND a.creation_date < = '01-JUN-07'
    ORDER BY a.user_name;Thanks,
    Anchorage :)

  • Advice with a query to find Accounts with activities within a given period ONLY

    Hello there,
    I am relatively new to Microsoft T-SQL and I was wondering if someone could help shed some light into a requirement I got...
    I have two tables in a database. One with accounts, and another with activities for such accounts. He is a simple diagram:
    *NOTE: Dates are in the DD/MM/YYYY format.
    Here is what I need to do:
    I need to get a list of all the accounts where the LAST activity was created in a date range, along with a count of activities that fall in such range. The idea behind this is to find out accounts with no activity after a certain period.
    I can certainly accounts with activities in a given range -- but that does not mean that there was no activities after the range.
    For example, if I look for Accounts with activities between Feb/2014 and Mar/2014, this query should NOT return the Contoso account, because it ha an activity after Mar/2014 (i.e.: Meeting with John on 15/Apr/14).
    Another example: If I query accounts with activities from 01/Jan/2014 and 03/Apr/2014, it should ONLY return the Adventureworks account:
    Adventureworks (3)
    [the number in parenthesis is the count of activities in that given time]
    This is because all other accounts had activities after 03/Apr/2014.
    Could someone please advise the best way to construct this query?
    Thanks in advance for the help!
    Regards,
    P.

    SELECT * FROM tbl WHERE CreatiinDate BETWEEN @firstactivities AND  lastactivites
    AND NOT EXISTS 
    (SELECT * FROM tbl t WHERE CreatiinDate>=@lastactivites
    AND
    tbl.AccountID=T.AccountID )
    OR
    SELECT * FROM tbl WHERE
    AccountID  NOT IN (SELECT
    AccountID FROM
    tbl t WHERE CreatiinDate>@lastactivites) 
    AND CreationDate BETWEEN
    @firstactivities AND  lastactivites
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Backend query to find metrics with thresholds

    Hi,
    Is there a way to query the backend tables in repository database to find the metrics with thresholds on a database.I want to findout the missing warning/critical thresholds for all the targets.Any inputs for this may be helpful to me.
    Thanks.

    You might want to create a User Deinfed Metric that does a query on the SYSMAN schema to find out.
    Checkout
    Oracle® Enterprise Manager Extensibility Guide
    10g Release 5 (10.2.0.5)
    http://download.oracle.com/docs/cd/B16240_01/doc/em.102/b40007/toc.htm
    For description of all SYSMAN views to select your data
    Regards
    Rob
    http://oemgc.wordpress.com

  • Query Data Finder Server with ActiveX

    I haven't been able to find much resources on how to use ActiveX to Query a Data Finder Server.  I know that this is all supposed to be done with the ToCommand but I have no idea how it is done beyond this.  Can someone give me some direction as to what commands are needed to Open a Data Finder, Create a Query, Merge Queries, and get resulting file paths?
    Thanks,
    David Vanleeuwen

    Hi Djvanlee,
    So they are not ActiveX commands, you would use VBScript Commands with a ToCommand reference writing to DIAdem through invoke nodes.  Are you using LabVIEW with the ToCommand reference?  
    An example of this can be found by opening up the DIAdem - Example Finder by going to Help>>Examples and it will be on the Context tab under the directory Examples>>Create Scripts>>Using Interfaces>>Controlling DIAdem from LabVIEW.  Then the commands can be found in the DIAdem Help on the Contents tab by going to Programming Reference>>Object Oriented Script Interfaces>>DIAdem NAVIGATOR>>Methods.  The methods you would reference are labeled as <DataFinder>.  It looks like the main commands you would need are:
    ConnectDataFinder()
    CreateQuery()
    Load Query()
    SaveQuery()  \\Note when you save the query you will have to indicate the path.
    If you are looking for a good example of programmatically using the DataFinder in the script tab in DIAdem you can find this in the ExampleFinder on the Contents tab at "Extending Functionalities with Scripts>>Context Menu for the Search Results of the DataFinder".  The ResultsList_Menus_Add.VBS connects to the DataFinder programmatically and loads a query.
    Peter T
    Applications Engineer
    National Instruments

  • Query to find numbers with dashes

    Help. I want to write a query that will return all the numbers in my table that have dashes (-) in positions 5, 8 and 12. I tried using the INSTR function, with the positions, but do not get the desired result.
    All suggestions are welcome!

    SQL> create table y as select '1234-67-901-34' y from dual;
    Table created.
    SQL> select to_number(x) from (select replace(y,'-') x from y where substr(y,5,1)='-' and substr(y,8,1)='-' and substr(y,12,1)='-')
    TO_NUMBER(X)
    12346790134

  • Query to find tables with excessive initial extent settings

    After loading a database dump we found many tables occupying large space due to large initial extents storage parameter but with very few rows and am trying to determine if it would be worth the effort to reorganize the entire schema. In other words, we are looking for a query to compare the estimated actual space that would be occupied by the table rows vs. the current size to see the space savings if we were to reorganize.
    I hacked out a script to calculate the estimated size using the table stats (or 64K if estimate is lower) and compared that vs. the extents allocated to each table but this seems a rather inexact way of doing it. Is there a more accurate approach?
    Doing this on Oracle database 10.2.0.4 on Windows Server 2003 SE
    SELECT a.table_name,
               b.table_size_MB,
               ROUND((a.num_rows * a.avg_row_len) / (1024 * 1024),2) calc_size_MB, 
               b.table_size_MB - GREATEST(ROUND((a.num_rows * a.avg_row_len) / (1024 * 1024),2), 0.0625) savings_MB
      FROM dba_tables a,
          (SELECT segment_name, sum(bytes)/(1024*1024) table_size_MB
             FROM dba_extents
            WHERE tablespace_name like 'PMDX' and segment_type = 'TABLE'
            GROUP BY segment_name) b
    WHERE a.owner = 'CAS' and a.table_name = b.segment_name
    ORDER BY b.table_size_MB desc
    TABLE_NAME                     TABLE_SIZE_MB CALC_SIZE_MB SAVINGS_MB
    TPM06_POL_DATA_WRK_PREV                  640       493.46     146.54
    TPM06_POL_DATA_WRK_CURR                  640       496.57     143.43
    TPM06_POL_DATA_201006                    640        496.8      143.2
    TPM06_POL_DATA_201005                    640       494.87     145.13
    TPM06_POL_DATA_201004                    640       490.45     149.55
    TPM07_MOV_DTLS_WRK                       256       198.66      57.34
    ...

    Hi,
    Didn't you check the dba_extents view with respect to the tables which you estimated.
    After loading a database dump we found many tables occupying large space due to large initial extents storage parameterYou might have modified the initial extent size before to your load by pre-created tables ,which might helped out with current situation prior to this as you might be well known with your current database. Does the segement using Autoallocate or Uniform. What is the block size of DB.
    - Pavan Kumar N

  • Query to find customers with cents only

    Can anyone please help we write a query, where I can identify customers who only have cents in the net amount (eg $100.01 or $315.20)?
    Thanks!

    or
    SQL> select t.amount
      2    from (select 123.40 amount
      3            from dual
      4          union
      5          select 8324   amount
      6            from dual
      7          union
      8          select -1     amount
      9            from dual) t
    10   where instr(t.amount,'.') > 0;
        AMOUNT
         123.4
    SQL>

  • SCCM 2012 Query to find units with IPv6 Enabled?

    We've found a need to locate computers that may have IPv6 enabled for audit purposes, and then we'll disable them at a later date.
    Has anyone been able to create a successful query in SCCM 2012 to get that information? 
    I found this but it spit back the IPv4 info for all the units in our device collection, plus it's for SCCM 2007. http://www.myitforum.com/forums/Query-for-systems-with-IPv6-enabled-m227020.aspx
    Appreciate any input, thanks!
    This topic first appeared in the Spiceworks Community

    If you're using % in the value field the operator must be "Like" . In your case, the query should look like
    select SMS_R_USER.ResourceID,SMS_R_USER.ResourceType,SMS_R_USER.Name,SMS_R_USER.UniqueUserName,SMS_R_USER.WindowsNTDomain from SMS_R_User where SMS_R_User.UserPrincipalName Like
    "TQA%" order by SMS_R_User.UserPrincipalName
    Kindly mark as answer/Vote as helpful if a reply from anybody helped you in this forum. Delphin

  • SQL Query to find Receipt No.s which are not matched to AP Invoices

    Hi
    Please help me to frame a query to find list of Receipt No.s which are not matched with AP Invoices.
    Please refer to the below query .
    SELECT
    poh.segment1 "PO No.",
    aps.vendor_name "Supplier Name",
    pol.item_description "Item Description",
    rcvh.receipt_num "GRV No.s",
    rcvl.quantity_received "Quantity",
    pol.unit_price "Rate/Unit",
    rcvtl.tax_name||' - '||initcap(rcvtl.tax_type) "Tax",
    (rcvl.quantity_received * pol.unit_price) + nvl(rcvtl.tax_amount,0) "Amount"
    FROM
    po_headers_all poh,
    po_lines_all pol,
    po_distributions_all pod,
    ap_suppliers aps,
    rcv_shipment_headers rcvh,
    rcv_shipment_lines rcvl,
    rcv_transactions rcvt,
    jai_rcv_line_taxes rcvtl
    WHERE
    poh.po_header_id = pol.po_header_id
    AND poh.po_header_id = pod.po_header_id
    AND pol.po_line_id = pod.po_line_id
    AND aps.vendor_id = poh.vendor_id
    AND aps.vendor_id = rcvh.vendor_id
    AND rcvh.shipment_header_id = rcvl.shipment_header_id
    AND poh.po_header_id = rcvl.po_header_id
    AND pol.po_line_id = rcvl.po_line_id
    AND rcvh.shipment_header_id = rcvt.shipment_header_id
    AND rcvl.shipment_line_id = rcvt.shipment_line_id
    AND poh.po_header_id = rcvt.po_header_id
    AND pol.po_line_id = rcvt.po_line_id
    AND aps.vendor_id = rcvt.vendor_id
    AND rcvh.shipment_header_id = rcvtl.shipment_header_id
    AND rcvl.shipment_line_id = rcvtl.shipment_line_id
    AND rcvt.transaction_id = rcvtl.transaction_id
    AND aps.vendor_id = rcvtl.vendor_id
    AND rcvt.transaction_type = 'RECEIVE'
    AND poh.authorization_status = 'APPROVED'
    AND poh.segment1 = '210001079'
    I have'nt included the Invoice Tables in the above query.
    Please help me in that area.
    This is bit urgent.
    Please help me.
    Regards
    Nakul Venkatraman

    I am using ORACLE 11gR2 If you're licensed for Diangnostics pack then you might want to look at the AWR tables, e.g. DBA_HIST_SQLSTAT and cross-reference with DBA_HIST_SNAPSHOT.
    By this will i get the top 5 consumed queries of DEV user in the whole session or its just the top 5 queries at that particular time. The "executions" columns in this query, does it mean that the no. of. times the query has executed... This will get you a random 5 queries that were first parsed by DEV. Depending on your application code/structure, it may well be that all code (except for system-recursive sql) executed by DEV is parsed by DEV, and all code parsed by DEV is executed by DEV but this isn't true for all.
    In terms of top N queries, you need to ORDER BY and then restrict by ROWNUM at an outer level to the ROWNUM otherwise the ROWNUM filter is applied before the ORDER BY.
    i.e.
    SELECT *
    FROM
    (SELECT ...
    FROM ...
    WHERE
    ORDER BY...)
    WHERE ROWNUM <= ....
    The "executions" columns in this query, does it mean that the no. of. times the query has executedYes.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e25513/dynviews_3064.htm#REFRN30259
    Edited by: Dom Brooks on Oct 24, 2011 9:45 AM

  • How to Use SQL Query having IN Clause With DB Adapter

    Hi,
    I am using 11.1.1.5 want to find out how to Use SQL Query having IN Clause With DB Adapter. I want to pass the IN values dynamically. Any ideas.
    Thanks

    invoke a stored procedure, it's safer than trying to put together an arbitrary SQL statement in the JCA adapter

  • Query to find the latest record with respect to the current status

    Dear gurus
    I have the following data in a table
    Customernum
    bkcode
    reqtdate
    Prevstat
    currstat
    The data will be like this
    CustomerNum bkcode reqdate prevstat currstat
    5900 1 03-Aug-12 0 1
    5900 1 06-Aug-12 1 0
    5900 5 22-Jun-12 0 1
    If a customer has an issue to solved, a record is added with bkcode , register date and currstat will be 1
    If the issue is resolved for the bookingcode,a new record is added, the currentstatus will become 0. and prev stat will show 1. Row no 1 and 2 reflects this case
    If this table is queried for finding the unresolved issues. the output should be only the Last row of the above example. since issue with bookingcode 1 has been resolved
    I have trying hard to get this thing confused what to use Lead or Max
    Kindly guide me

    Hi,
    one way here:
    WITH mytable(CustomerNum, bkcode, reqdate, prevstat, currstat)
    AS
       SELECT 5900, 1, TO_DATE('03-Aug-12', 'DD-Mon-YY'), 0, 1 FROM DUAL UNION ALL
       SELECT 5900, 1, TO_DATE('06-Aug-12', 'DD-Mon-YY'), 1, 0 FROM DUAL UNION ALL
       SELECT 5900, 5, TO_DATE('22-Jun-12', 'DD-Mon-YY'), 0, 1 FROM DUAL
    SELECT CustomerNum, bkcode, reqdate, prevstat, currstat
      FROM (SELECT a.*
                 , ROW_NUMBER() OVER (PARTITION BY CustomerNum, bkcode
                                           ORDER BY reqdate DESC) AS rn
              FROM mytable a
    WHERE rn=1
       AND currstat=1;
    CUSTOMERNUM     BKCODE REQDATE     PREVSTAT   CURRSTAT
           5900          5 22-JUN-12          0          1Regards.
    Al
    Edited by: Alberto Faenza on Dec 18, 2012 5:23 PM
    Changed again!! Previous logic was wrong

  • Sql query to find the balances for a customer account wise.

    Hi,
    Could someone help me with the sql query to find the balances for each customer account wise. This is need to generate the report.
    presently we are using this query, but the output doesnot return the expected result.
    SELECT sum(nvl(ps.acctd_amount_due_remaining,0)) "Balance"
    FROM      ra_cust_trx_line_gl_dist_all gld,
              gl_code_combinations c,
              ar_payment_schedules_all ps,
              RA_CUSTOMER_TRX_ALL rat,
              ra_customers rc
    WHERE      c.CHART_OF_ACCOUNTS_ID = 101
    and gld.code_combination_id = c.code_combination_id
         and rat.CUSTOMER_TRX_ID=gld.CUSTOMER_TRX_ID
         and rat.CUSTOMER_TRX_ID=ps.CUSTOMER_TRX_ID
    and ps.customer_id=rc.customer_id
         and ps.status='OP'
         and ps.gl_date <= :PDATE
         and ps.org_id=:PORGID
         and ps.class in ('GUAR','INV','DM','DEP')
    and c.SEGMENT4=:Account_id
    and ps.customer_id=:Customer_id
    Thanks in advance.
    Kalyan.

    Can someone help us with this.

Maybe you are looking for

  • Can you redeem an iTunes gift card and spend the money across different stores?

    I have a £50 iTunes gift card. I know it can be redeemed in either iTunes, the App Store, iBooks Store or Mac App Store. My question is, can I redeem the code in iTunes and then spend some money on iOS apps, some money on songs and some money on iBoo

  • Passing a socket to a timer invoked function

    I am controlling a computer remotely using PrintWriter to a socket. I want a heartbeat timer to send a small xml message every 10 seconds. I need to know how to pass the fromClient PrintWriter to the timer invoked function. I have a client that opens

  • Changing Date and Time with dng files

    My camera settings for date and time were wrong. So some of my files in Lightroom 3 have the wrong dates. This morning I downloaded Photoinfo 2.0.1 but it doesn't seem to want to accept "dng" files to change the info. It will accept "jpeg" files no p

  • Adapter Engine issue

    Hi, I am workingon JDBCXIRFC scenario. After creating Data types, message types, message interfaces and etc, i started defining communciation channel template under "Adapter Objects". While selecting the particular Adapter type, the window is popping

  • Problem with CALC_DUMMY_ORG

    I can't get CALC_DUMMY_ORG to work on rollup members and I would like suggestions on how I can debug the problem. My logic looks like this (thanks Joost).  Note: DEPARTMENT is of type ENTITY: *XDIM_MEMBERSET ACCOUNT=<ALL> *XDIM_MEMBERSET DEPARTMENT=<