How to get SQL that do not use bind variables

Hello

I am trying to identify the SQL code which should benefit from the use of bind variables.
First of all, I tried to get the common signature of all the sql calls, using:
select * from (
select  force_matching_signature, count(1) from v$sql where force_matching_signature<>0 group by force_matching_signature order by 2 desc
) where rownum < 50;
Then I copied these values to the Clipboard and run:
select sql_text from v$sql where force_matching_signature=<<<copied_signature_value>>>;
Now, I want to make it automatically and get only 1 occurrence of each SQL that resembles others by using a query.

I tried this:
select sql_text from
(
select sql_text, force_matching_signature, row_number() over (partition by force_matching_signature order by sql_text desc)rn from v$sql where force_matching_signature <>0
)where rn <2 and rownum < 10 order by force_matching_signature desc
But it is not returning results by showing up at the count (1) from the first query, I've used. How can I change this if I get the results in order of "importance"?




Thank you

And I said. First use the command by then use rownum. I did not mention row_number. Also, there should be no need to add more columns.
Have you tried it? Why it did not work?

example not tested

select * from (
   select sql_text from (select sql_text, force_matching_signature, row_number() over (partition by force_matching_signature order by sql_text desc) rn from v$sql where force_matching_signature != 0)
   where rn = 1
   order by force_matching_signature desc /* add any ordering you like here */
   )
where rownum < 10  /* then filter on the first 10 results */

If you want to order that the statement that found most of the time comes first, say so. However, I don't see how to group in your case.
Maybe like this

example of tested

select * from (
   select cnt, sql_text
   from (select sql_text, force_matching_signature, row_number() over (partition by force_matching_signature order by sql_text desc) rn , count(*) over (partition by force_matching_signature) cnt
         from v$sql
         where force_matching_signature != 0)
   where rn = 1
   order by cnt desc, force_matching_signature desc /* add any ordering you like here */
   )
where rownum < 10  /* then filter on the first 10 results */
;

Published by: Sven w. October 11, 2012 14:49

Published by: Sven w. October 11, 2012 14:51

Published by: Sven w. on October 11, 2012 14:56 - number column added to the output

Tags: Database

Similar Questions

  • Smartphones blackBerry [9700 "Bold"] how to get emails that are not gmail, yahoo,...?

    Hi guys,.

    I saw a small company and goes to buy a Blackberry Bold 9700. I read a lot of forums and boards, but I have still not found an answer to the question: "is it possible to get e-mails from accounts that are not google or yahoo etc."?

    I have a clean online store or the domain and so my email address is something like info @.com

    I am currently using Thunderbird on my laptop to get and send e-mails via pop3/smtp.

    So, it is possible to have access to e-mail via a pop3 server and send emails using smtp on a Blackberry 9700 Bold?

    Greetings,

    Marco.

    Yes, you can access most of the protocols POP3 or IMAP mail server.

  • I have 3 I paid and you want to delete all the information that a a them. How to be painful that will not delete fron the 2 that I paid I want to use

    I have 3 I paid and you want to remove all the information ONLY one of them. How to be painful that will not delete the other

    You can go to settings > General > reset > erase all content and settings and will erase the iPad that you perform this action on. It has no effect on another device.

    See you soon,.

    GB

  • Adobe Player/Flash receives the error notice that he not use 32-bit 64-bit

    problems when you try to view things through Adobe Player/Flash receives the error notice that it uses 32-bit 64-bit not, I try to follow the instructions how to fix problem with on any what success iohow to use

    Help please, problem with the Windows Vista, 64-bit computer.

    Whenever I want to display items through opinion of get Adobe Player/Flash that he not use 32 bits 64 bits, I try to follow the instructions.

    I'd appreciate it, step by step instructions how to solve the problem, cannot view images, videos, etc. via internet.

    Thank you

    Marty 720

    http://social.answers.Microsoft.com/forums/en-us/InternetExplorer/thread/babaa5f8-FF06-4EA2-aef6-a9416d65f981

    Read all the foregoing by PA bear MVP.

    See you soon.

    Mick Murphy - Microsoft partner

  • How to get more themes online, to use as a wallpaper?

    Original title: wallpaper

    How to get more themes online, to use as a wallpaper?

    I would like to know how.

    Thank you, with best regards,
    Ana Luisa 22

    Microsoft has a huge Gallery of themes and wallpapers which you can see here:

    Background screen Windows Gallery

    And you can also use your favorite search engine to find images to use also.  Just looking for pictures and when you see one that you like, right click to save it.  Later, you can go where you've saved (probably your photos or download folder) and right click any image for "(définir comme fond d'écran)."

  • 12 c call Webservice JDeveloper get "SQL string is not a DML statement" as a SQLException exception

    Hi guys,.

    I developed a java class to access the database using the OracleDataSource class and run a SQL query with a select statement. It works very well. I have built a wrapper class and as a Web service. I get "SQL string is not a DML statement" as a SQLException exception when I run as a Web service, but it works very well as an application.

    No idea why I get this error? Not sure why WebSercie is having a problem while this works as an application.

    Thank you and best regards,

    Srini Mel

    Solved the problem by myself.

    The first release "SQL string is not a DML statement" is due to an additional line (pstmt2.executeUpdate ()) in the code.

    Second question, receives not the query response is due to bad user input. I walked into 13.21651 instead of 31.21651.

    Thank you!

    Srini

  • queue on the profile that are not used

    Hi guys,.

    is anyway to wrap on the profile that are not used or attributed to any user name or roles?

    flaskvacuum wrote:
    Hi guys,.

    is anyway to wrap on the profile that are not used or attributed to any user name or roles?

    SQL> CREATE PROFILE test LIMIT
      2     FAILED_LOGIN_ATTEMPTS 5
      3     PASSWORD_LIFE_TIME 60
      4     PASSWORD_REUSE_TIME 60
      5     PASSWORD_REUSE_MAX 5
      6     PASSWORD_VERIFY_FUNCTION null
      7     PASSWORD_LOCK_TIME 1/24
      8     PASSWORD_GRACE_TIME 10;
    
    Profile created.
    
    -- Created but not assigned --
    SQL> select distinct profile from dba_profiles where profile not in (select profile from dba_users);
    
    PROFILE
    ------------------------------
    TEST
    
    SQL>
    
  • Find indexes in the schema that are not used

    Hello
    Anyone know an easy way to SQL or EM to find all indexes that are not used (not accessed) in a schema?
    Greetings

    Published by: user552215 on January 26, 2012 04:15

    Salvation;

    Please see:

    Identify unused indexes [ID 144070.1]
    Identify unused indexes with the ALTER INDEX TRACKING controls [ID 136642.1]

    Respect of
    HELIOS

  • Identify a tablespace that is not used in the database

    Hello

    How to find the tablespace that is not assigned to any user? Note that I have a table partition in which there is table space where the records will be placed in the future based on the requirement on this partition table. I gave the unlimited tablespace on these tablespace privilege for the user. How to find storage space that is not used at any time in the database?


    Kind regards

    007

    007 wrote:
    Hello

    How to find the tablespace that is not assigned to any user? Note that I have a table partition in which there is table space where the records will be placed in the future based on the requirement on this partition table. I gave the unlimited tablespace on these tablespace privilege for the user. How to find storage space that is not used at any time in the database?

    Kind regards

    007

    According to my understanding of your question

    To check the quota on the tablespace use query below:

    SELECT * FROM dba_ts_quotas WHERE username = "XXXX";

    to check the default tablespace use the following query:

    Select USER_USERS from dba_users where username = 'XXXX '.

    How to find storage space that is not used at any time in the database?

    Use view dba_data_files for space used for the tablespace.

    I hope this help you

    Neeraj-

    Published by: Virginia October 22, 2011 14:35

  • Under XP how to remove programs that do not show a button 'Delete' on screen ' Add/Remove '?

    Under XP how to remove programs that do not show a button 'Delete' on screen ' Add/Remove '?

    Hi cengstro,
     
    -What are the programs that you have this problem with?
     
    Visit the site of the manufacturer for the program and search for uninstall/removal tool uninstall the program.

    You can only remove a program with the add tool / remove programs if the program is written for Windows. If you don't see the program you want to remove in the currently installed programs box, view the program documentation for instructions on how to remove it.

    How to manually remove programs from the add tool / remove programs

  • Can I create a web database search that does not use Javascript?

    Can I create a web database search that does not use Javascript?

    While it would be possible to do it through custom coding, this type of web database search would not supported by Eloqua.

  • A way to show items that are not used in the sequence

    Hello world

    is there a way to display items that are not used in the sequence.

    in order not to forget the "rushes" in the Assembly?

    my best,

    Turn on the use Audio and video columns in the sandbox and then sort by those.

  • How to set SQL that contains 'in' where clause in VO?

    I don't want to set "in" would adopt a kind of programatical in VO as below. I want to use a method declariable to set in the clause using bindings varaible.

    It can be implemented?

        private String getInClauseWithParamNames(List termCodes) {
               //logic to form the in clause with multiple bind variables
               StringBuffer inClause = new StringBuffer(); 
               if(termCodes !=null){
                   for (int i = 1; i < termCodes.size() + 1; i++) { 
                       inClause.append(":termC" + (i));
                       if (i < termCodes.size()) { 
                          inClause.append(","); 
                       } 
                   }
               }
               return inClause.toString();
        }
            
        public Row[] getYardFixedSlots(List termCodes) {
            if(termCodes != null && !termCodes.isEmpty()){
                String inClause = getInClauseWithParamNames(termCodes);
                //setting the where cluase to use the generated in clause
                this.setWhereClause("YardFixedSlot.TERMINAL_C in (" + inClause + ")");
                ////clearing all existing where clause params if any 
                this.setWhereClauseParams(null);
                if(getVariableManager() !=null){
                   this.getVariableManager().clearVariables();
                }
                //setting values for all bind variables one by one in the in clause
                for (int i = 0; i < termCodes.size(); i++) { 
                    //defining the named bind variables programatically 
                    this.defineNamedWhereClauseParam("termC" + (i + 1), null, null);
                    //setting the value for each named bind variable 
                    this.setNamedWhereClauseParam("termC" + (i + 1), termCodes.get(i)); 
                }
                this.setRangeSize(-1); 
                //executing the query 
                this.executeQuery(); 
            }
            //returning the rows from query result 
            return this.getAllRowsInRange(); 
        }
    

    You can only use the link as a parameter to the in clause. You must divide the string inside the binding variable. Sample can be found at decompilation binary ADF: using bind variable for SQL statements with the paragraph

    Timo

  • y at - it a button to remove all the nuances that are not used in an file?

    Hey all,.

    I was wondering is there a button that removes all the nuances that are not used in an illustrator file?

    Any help would be great

    Look in the Actions Panel. It should be an action he who says to remove all unused items in the Panel.

  • can I install PES 11 on two laptops that are not used in the same place?

    Can I install PES 11 on two laptops that are not used in the same place or at the same time?

    Yes, your license entitles you to two simultaneous activations.

Maybe you are looking for