Using Bind Variable in a SELECT statement

Hello

I am trying to build my SQL query running using bind variables and in Oracle® Fusion Middleware Fusion developer Guide for Oracle Application Development Framework 11 g Release 1 (11.1.1) it is said that ' after you define bind variables, the next step is to reference them in the SQL statement. While SQL syntax allows you to bind variables to appear in the SELECT list and in the WHERE clause, you'll generally use them in this context, as part of your WHERE clause. ».

However, when I try to use bind variables in my SELECT list because I had set a type to the string of the variable variable is inserted with quotes each side for example SELECT TestTable FROM 'Service '. Is it possible to use bind variables to insert a value in my list of selection without the quotes around it?

Thanks in advance,
Tom

Hi Robinst,

I think you want to set up column name of the table that is not possible using bind variables. With the help of the bind variables you can send a value to the SQL. The String value is therefore always with inverted commas.

Kind regards

Branislav

Tags: Java

Similar Questions

  • using variable in the select statement (php)

    I have trouble using a variable in a select statement.

    The following query to manually (using a static date) works very well:

    $query_Recordset1 = "SELECT * from academyClasses WHERE the classDate > ' 2006-06-01' ';"

    However, if I use the following:

    $dateVar = date('Y-m-d');

    @mysql_select_db ($database_mw, $mw);
    $query_Recordset1 = "SELECT * from academyClasses WHERE the classDate > $dateVar";

    All records are returned, which means that the $dateVar variable is not recognized. I compared the values of $dateVar <? PHP echo $datetime;? > against the real value of my date field <? PHP echo $row_Recordset1 ["classDate"];? > in my results to the table and it seems that the values are indeed accurate regarding a date 2006-06-04 for example.

    My date field 'classDate' is of type 'date' in the mysql database. I use Dreamweaver MX 2004 with Mac OSX 10.3.9.

    I'm sure it's just a syntax problem, at least, I hope it is.

    Any help is greatly appreciated.



    It worked:

    $query_Recordset1 = "SELECT * from academyClasses WHERE the classDate > = CURRENT_DATE;

    Thank you
    MW

  • Estimate of poor cardinality using Bind Variables

    Hi I'm using the 11.2.0.4.0 Oracle version. I have a query that is underway for the plan of the poor execution by the estimate of poor cardinality for two tables (I've extracted and published this part only) as I mentioned below, the individual conditions for which the estimate goes bad and moving entire query execution path.

    These are for two tables and currently we use BIND variable for them in our code, and I notice, its best estimate gives with literals. I need to know how to handle this scenario that I need this query to execute for all types of volumes. Is there something I can do without changing the code, as it works well for most of the execution? In the current scenario of the main query that uses those below tables providing a plan (index + nested loop) that works very well for small volume, but running for 10 hr + for large volume as ideally its going to the same regime.
    And Yes, most time that this request will be hit for small volume, but killing some appearance of large volume presents the performance of the queries.


    Here are the values of the variable binding.

    B1 VARIABLE VARCHAR2 (32);
    B2 VARIABLE VARCHAR2 (32);
    B3 VARIABLE NUMBER;
    B4 VARIABLE VARCHAR2 (32);
    B7 VARIABLE VARCHAR2 (32);
    B5 VARIABLE NUMBER;
    B6 VARIABLE NUMBER;

    EXEC: B1: = 'NONE ';
    EXEC: B2: = NULL;
    EXEC: B3: = 0;
    EXEC: B4: = NULL;
    EXEC: B7: = NULL;
    EXEC: B5: = 0;
    EXEC: B6: = 0;

    ---- For  TABLE1-------
     -- Published Actual VS Etimated cardinality
     
     
    -- With bind values
    select * from TABLE1 SF
    WHERE (   (SF.C1_IDCODE = :B4) OR (NVL (:B4, 'NONE') = 'NONE'))
        AND ( (SF.C2_ID = :B3) OR (NVL (:B3, 0) = 0));
    Plan hash value: 2590266031
    -----------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                 | Name                | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |  OMem |  1Mem | Used-Mem |
    -----------------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT          |                     |      1 |        |  28835 |00:00:00.08 |    2748 |     46 |       |       |          |
    |*  1 |  TABLE ACCESS STORAGE FULL| TABLE1              |      1 |     11 |  28835 |00:00:00.08 |    2748 |     46 |  1025K|  1025K|          |
    -----------------------------------------------------------------------------------------------------------------------------------------------
    Predicate Information (identified by operation id):
    ---------------------------------------------------
       1 - storage((("SF"."C1_IDCODE"=:B4 OR NVL(:B4,'NONE')='NONE') AND ("SF"."C2_ID"=:B3 OR NVL(:B3,0)=0)))
           filter((("SF"."C1_IDCODE"=:B4 OR NVL(:B4,'NONE')='NONE') AND ("SF"."C2_ID"=:B3 OR NVL(:B3,0)=0))) 
     
    -- With literals 
    select * from TABLE1 SF
     WHERE  (   (SF.C1_IDCODE = null) OR (NVL (null, 'NONE') = 'NONE'))
          AND ( (SF.C2_ID = 0) OR (NVL (0, 0) = 0));
       Plan hash value: 2590266031
    --------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                 | Name                | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
    --------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT          |                     |      1 |        |  28835 |00:00:00.03 |    2748 |       |       |          |
    |   1 |  TABLE ACCESS STORAGE FULL| TABLE1              |      1 |  28835 |  28835 |00:00:00.03 |    2748 |  1025K|  1025K|          |
    --------------------------------------------------------------------------------------------------------------------------------------
    
    --------For TABLE2 ----------------------- 
    -- Published Autotrace plan, as it was taking long time for completion, and actual cardinality is 45M, but its estimating 49 With bind value---
    
    --withbind value
    select * from TABLE2 MTF
    WHERE (   (MTF.C6_CODE = TRIM (:B2)) OR (NVL (:B2, 'NONE') = 'NONE'))
      AND (   (MTF.C3_CODE = :B1)  OR (NVL (:B1, 'NONE') = 'NONE'))
      AND (   (MTF.C4_CODE = :B7)  OR (:B7 IS NULL))
      AND (   (MTF.C5_AMT <= :B6)  OR (NVL (:B6, 0) = 0))
      AND (   (MTF.C5_AMT >= :B5)  OR (NVL (:B5, 0) = 0));
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 1536592532
    -----------------------------------------------------------------------------------------------------------
    | Id  | Operation                  | Name         | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    -----------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT           |              |    49 | 10437 |   358K  (1)| 01:11:43 |       |    |
    |   1 |  PARTITION RANGE ALL       |              |    49 | 10437 |   358K  (1)| 01:11:43 |     1 |  2 |
    |*  2 |   TABLE ACCESS STORAGE FULL| TABLE2       |    49 | 10437 |   358K  (1)| 01:11:43 |     1 |  2 |
    -----------------------------------------------------------------------------------------------------------
    Predicate Information (identified by operation id):
    ---------------------------------------------------
       2 - storage(("MTF"."C4_CODE"=:B7 OR :B7 IS NULL) AND ("MTF"."C3_CODE"=:B1 OR
                  NVL(:B1,'NONE')='NONE') AND ("MTF"."C5_AMT"<=TO_NUMBER(:B6) OR NVL(:B6,0)=0) AND
                  ("MTF"."C5_AMT">=TO_NUMBER(:B5) OR NVL(:B5,0)=0) AND ("MTF"."C6_CODE"=TRIM(:B2) OR
                  NVL(:B2,'NONE')='NONE'))
           filter(("MTF"."C4_CODE"=:B7 OR :B7 IS NULL) AND ("MTF"."C3_CODE"=:B1 OR
                  NVL(:B1,'NONE')='NONE') AND ("MTF"."C5_AMT"<=TO_NUMBER(:B6) OR NVL(:B6,0)=0) AND
                  ("MTF"."C5_AMT">=TO_NUMBER(:B5) OR NVL(:B5,0)=0) AND ("MTF"."C6_CODE"=TRIM(:B2) OR
                  NVL(:B2,'NONE')='NONE'))
      
    -- with literal
    select * from TABLE2 MTF
    WHERE (   (MTF.C6_CODE = TRIM (null)) OR (NVL (null, 'NONE') = 'NONE'))
     AND (   (MTF.C3_CODE = 'NONE') OR (NVL ('NONE', 'NONE') = 'NONE'))
      AND (   (MTF.C4_CODE = null)  OR (null IS NULL))
       AND (   (MTF.C5_AMT <= 0)  OR (NVL (0, 0) = 0))
      AND (   (MTF.C5_AMT >= 0)  OR (NVL (0, 0) = 0));
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 1536592532
    -----------------------------------------------------------------------------------------------------------
    | Id  | Operation                  | Name         | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    -----------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT           |              |    45M|  9151M|   358K  (1)| 01:11:41 |       |    |
    |   1 |  PARTITION RANGE ALL       |              |    45M|  9151M|   358K  (1)| 01:11:41 |     1 |  2 |
    |   2 |   TABLE ACCESS STORAGE FULL| TABLE2 |    45M|  9151M|   358K  (1)| 01:11:41 |     1 |  2 |
    -----------------------------------------------------------------------------------------------------------
    
    select column_name,num_nulls,num_distinct,density
    from dba_tab_col_statistics where table_name='TABLE2'
    and column_name in ('C3_CODE','C4_CODE','C5_AMT','C6_CODE');
    C3_CODE 0 65 0.0153846153846154
    C4_CODE 0 2 0.5
    C5_AMT 0 21544 4.64166357222429E-5
    C6_CODE 1889955 71 0.0140845070422535
    
    

    933257 wrote:

    ((SF. C1_IDCODE =: B4) OR (NVL (: B4, 'NONE') = 'NONE'))

    In fact for literals, I did not find any section of the predicate after running the sql code with activation "set autotrace traceonly explain."

    The main problem is with another large query whose cardinality is underestimated due to the presence of these table (table1, table2) with the above mentioned clause, and the query is for the analysis of index + nested with values of Bind loops and take 10 hr +, whereas with literals, its completion in ~ 8minutes with FTS + Hash Join.

    Your real problem is that you try to have just a single SQL query handle all POSSIBLE thanks to the use of embedded FILTERS ' either / or ' filters in the WHERE clause.  You want only a select this OPTION to run whatever filters have been selected at run time by the user or the application using it.  And it would never work.  You really need to SELECT different queries for different combinations of filter conditions.

    Why?  Think for a minute.  How Oracle works internally?  A SQL SELECT query gets analyzed and an execution plan is produced which is stored in the library cache and gets REUSED on all subsequent executions of this query - except in certain cases where there may exist several plans run through several cursors of the child.  So with only SELECT a query you only AN execution plan in the library cache, to be used by all THE executions of this query, regardless of the value of your run-time binding variables.

    Lets put another way - each library cache execution plan is associated with a SQL statement.  If you want a DIFFERENT execution plan then you need run a DIFFERENT SQL statement.  That's how you get a different execution plan - by running a different SQL statement.  Running the SAME SQL query generally you will get the SAME execution plan every time.

    In addition, because of the "either / or" filters that you use you will end up generally with a full Table Scan on each of the referenced tables.  Why?  Given that the optimizer must produce an implementation plan that manages all possible contingencies for all values of possible bind variables in the SELECT.  If the optimizer should choose to use any index based on one of these "either / or" filters then it would only help performance when real value was provided, but it would be really bad if a NULL value was supplied.  If the optimizer ends up ignoring the index because they are not always optimal for all possible input values and instead chose a plan that is "good enough" for all input values possible.  That means that it will use a scanning Table full.

    I hope you can see that it is precisely what is happening for you with your query.  You select this OPTION to manage the different combinations of filter, which leads to the execution plan only one, which leads to scans full Table on the referenced tables in these ' either / or ' filters.

    The solution?  Build queries SELECT DIFFERENT when input values are NULL.  How you do that?  Read this article to ask Tom that tells you:

    http://www.Oracle.com/technetwork/issue-archive/2009/09-Jul/o49asktom-090487.html

    To sum up - when you have real value for a bind variable 'bind_var1' add the following filter to your CHOICE:

    AND column_name1 =: bind_var1

    When the binding variable is NULL, add the filter according to your CHOICE:

    AND (1 = 1 OR: bind_var1 IS NULL)

    Now, you'll have 2 queries SELECT must be performed, which have exactly the same number of variables in the same order bind, which is important.  When you then run one of these variations, Oracle can analyze and optimize each one SEPARATELY, with a single execution by the SELECT query plan.

    When you provide a real value, the filter is a normal 'column = value' that the optimizer can use all indexes on this column, because NULL values are not referenced.

    When there is no real value, the optimizer will analyze the '1 = 1 GOLD' and realize that "1 = 1" is set to TRUE and GOLD, it is quite TRUE regardless because the binding variable is null or not.  This means that the optimizer will actually REMOVE this filter, because it filters nothing because it is always TRUE.  You will end up with an operating plan based on the other filters in the query, which is what you want because you have no filter on this column.

    What is it - producing distinct SELECT queries to determine if you have a real value to filter or not you end up with DIFFERENT execution plans for each of them, and each of them is OPTIMAL for this particular set of filters.  Now you get good performance for each variation of the performance of the SELECTION, rather than sometimes good and sometimes very bad when using SELECT only one.  It is impossible to try to get multiple shots of execution 'optimal' out of a SELECT query.  That's why you get mediocre performance under different bound the values of the variables.

    John Brady

  • Problem using bind variables in shared components report queries

    Greetings,

    I use APEX 4.0.1.00.03 and BI Publisher 10.1.3.4.1.

    In the APEX, I try to create a report query that uses bind variables in the where clause. I have a page that contains a button and a text element (P1_ID). The button is used to call the report. I went the shared components and created a new report query. Here is the text of the code.
    select violation_date
    , violation_type
    , nvl(:P1_ID,'zzz')
    from edd_procard_violations
    where upper(card_holder_id) = upper(:P1_ID)
    I also have Session State to enabled and have added the P1_ID in the area of 'State of Session' under the query.

    When I change the query, and click on the 'Set Bind Variables' button, I get a field where I can enter a value for: P1_ID I enter a value that should return lines, but when I click on the button "Test query", I get no rows returned. If I comment on where clause and test the query, even once, I get all rows in the table. You'll notice in my query I have included nvl(:P1_ID,'zzz'). When I run the query, without where clause, the returned value is always "zzz" indicating that: P1_ID is null.

    No idea what I am doing wrong?

    Thank you very much.
    Larry

    Hello Larry,.

    Looks like the wizard to create a report query in the shared components has a bug related to bind variables. I was able to reproduce your problem. Just create the query using the link variable, check the box to include session state, add the item and create the query. When you use the report query to download the report, where the your clause will work fine.

    Thank you
    Machaan

  • Procedure of the ODI - Bind Variables in the conditional statements

    In an ODI procedure, is it possible to add a conditional statement around bind variable?  For example, if I use OdiOutFile as the command on the target and Oracle as the command on the Source, I can use bind variables to fill the data in this table (we are in fact using OdiInvokeWebService and passing a XML structure very complex, but it's easier for testing):

    OdiOutFile-FILE = C: / TEST. TXT

    < person >

    < first > #FIRSTNAME < / first >

    < Middle > #MIDDLENAME < / Middle >

    < last > #LASTNAME < / last >

    < / person >

    It is a way to add a conditional statement using one of these bind variables?  For example, if I wanted to test #MIDDLENAME null and null value, produced this portion of XML, such as:

    OdiOutFile-FILE = C: / TEST. TXT

    < person >

    < first > #FIRSTNAME < / first >

    < % if (#MIDDLENAME! = null) {% >}

    < Middle > #MIDDLENAME < / Middle >

    < %} % >

    < last > #LASTNAME < / last >

    < / person >

    This type of scriptlet syntax seems to work fine, as long as the binding variable is not in the mix (if I put "true is true" or "true == false" in the case, it shows or does not show this line in the XML file, as expected).  I use ODI 11.1.1.7.0

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

    Post edited by: KevinPratt

    Thanks for the reply!  As suggested, in what follows, I changed the command and it works as you want

    OdiOutFile-FILE = C: / TEST. TXT-APPEND

    < person >

    < first > #FIRSTNAME < / first >

    < @ if (!) (("#MIDDLENAME".equals(""))) {@ >}

    < Middle > #MIDDLENAME < / Middle >

    {< @} @ >

    < last > #LASTNAME < / last >

    < / person >

    Using the syntax <@ ...="" @="">serve your purpose. Also, I think you might want to include the variable binding in the quotation to avoid syntax errors.

  • Correct way to use Bind variables when you use an interface to MS SQL Server

    Hey,.
    I have some difficulty to find how to use bind variables in a view, when you use an interface to MS SQL Server. For some reason when I use an ApplicationModule who has a library of MS SQL Server JDBC loaded and I try to click on OK when you change the following query:

    SELECT kit_status, component_id
    OF numbered_inv
    WHERE trialname =: 1

    I get an error stating that ' SQL Query Error Message incorrect syntax near ':'. JDeveloper is compatible with SQL server for bind variable as this query works fine if I replace the: 1 with a Word to say "Test test".

    Thanks in advance

    Edited by: NullCheck December 15, 2010 14:06

    Use positional JDBC Style Binding to bind variables
    Try to use? Instead of:
    As shown here:
    http://www.Oracle.com/technetwork/developer-tools/jdev/multidatabaseapp-085183.html

  • PL/SQL using bind variable to delete records

    Hello

    I'm currently implementing PL/SQL using bind variables to remove records from the "item_progress" table in the simple join query where I'm passing itemName, itemLoc and orderLoc in the delete query in pl/sql block.

    Please suggest, it should be easy for oracle experts...

    (a) I need first records in the item_progress table by using the join query and then update of status in the renew_item table.
    (b) it works fine if I use the simple removal with a condition that is ("DELETE from item_progress where itemname =: 1' using itemname1").

    (c) but it gives an error when I run it using delete with join:
    ---------------------------------------
    * Invalid relational operator ORA-00920:
    ORA-06512: at "SE", line 14 (it's the deletion with the join... "DELETE FROM item_progress WHERE item_id IN (SELECT ip.item_id'...)" ....'
    ORA-06512: at line 10
    Process exited.*
    ---------------------------------------

    create or replace PROCEDURE PUT (itemName IN VARCHAR2,
    itemLoc IN VARCHAR2,
    orderLoc IN VARCHAR2) is
    itemName1 varchar2 (30);
    itemLoc1 varchar2 (30);
    orderLoc1 varchar2 (30);
    BEGIN
    orderLoc1: = ' C: test/local /';
    itemLoc1: = ' / / L123/R;
    itemName1: = 'AAA ';

    immediate execution

    "DELETE FROM item_progress WHERE item_id IN (SELECT ip.item_id FROM ip, item_order io item_progress WHERE io.orderlocation: = 1 AND ip.order_id io.order_id UNION SELECT item_id FROM item_progress WHERE ITEMLOCATION =: = 2) AND itemname: = 3' using orderloc1, itemloc1, itemname1;"

    -"DELETE from item_progress where itemname =: 1' using itemname1; -IT WORKS FINE
    -Once the above query is updated to success, the status in another table
    -Renew_item update the Status value = "RENEWED" where ITEMNAME =: 1, ITEMLOCATION =: 2 using itemname1, itemloc1;

    commit;
    END OPERATIONS;

    user10828299 wrote:
    Please suggest, it should be easy for oracle experts...

    You have made a typo. bind variables are preceded by two points, while you put a colon in front of the equality operator that he listens to it in the PL/SQL assignment operator. Change:

    WHERE io.orderlocation : = 1

    TO

    IO.orderlocation WHERE =:1

    Change:

    WHERE ITEMLOCATION : = 2

    TO:

    WHERE ITEMLOCATION =:2

    Change

    AND itemname : = 3

    TO:

    AND itemname =:3

    SY.

  • Report using Bind Variables

    Hey everybody,

    I have a little trouble to create a report. I need the FROM part of the code in order to use bind variables. I came up with this piece of code below, but im getting the following error:

    Failed to parse the SQL query:
    ORA-06550: line 1, column 8:
    PLS-00103: encountered the symbol "" when expecting one of the following values:

    begin function package pragma procedure subtype type use
    form
    current cursor
    The symbol "" was ignored.
    ORA-06550: line 2, column 24:

    PLS-00103: encountered the symbol "" when expecting one of the following values:

    begin function package pragma procedure subtype type use
    form
    course

    Where can I see im wrong?

    Thanks in advance,
    -N.S.N.O.

    Code
    DECLARE
    x VARCHAR2 (4000);
    BEGIN
    x : = x || "select *";
    x : = x || "from";
    x : = x || : p13_schema;
    x : = x || '.ddl_log @';
    x : = x || : p13_db_name;
    x : = x || ' _DBAAPEX. TNTEWW. COM';
    RETURN (x);
    END;

    AHA, but when you have changed the source, have you also changed the Type (from "SQL query" to "SQL Query-PL/SQL function return SQL Query")?
    And clicked on "use generic names (analysis of query runtime only) column" option below the source code?

  • Assign the values of the two variables in a select statement

    I'm trying to set two variables in a select statement in my definition of the procedure. I get the error identifier not valid "ATTRIBUTE" running the following code.
    create or replace procedure tbl_auth (
    Email in varchar2,
    UserLevel out number)
    as
      v_Email varchar2(100) := lower(Email);
      v_login_chk number := 0;
    begin
     select UserLevel into p_UserLevel,
            v_login_chk into v_login_chk
     from tbl_User
     where eMail=v_Email  
    
    exception
     when no_data_found then
      UserLevel := 0;
    end tbl_auth;
    Can I not connect two different values to two different variables in the same select?

    Thank you

    Published by: jerry8989 on August 22, 2011 07:06

    Published by: jerry8989 on August 22, 2011 07:06

    change as follows:

     select UserLevel, v_login_chk into p_UserLevel,
            v_login_chk
    

    IN ONE ALONE is enough.

    BTW, don't you have "login Check" column in the "tbl_user"? If you do, your selection should be like this:

    ...
    select UserLevel, loginChk into /* check the column name in your table */
             p_UserLevel, v_login_chk
     from tbl_User
    ...
    
  • Set the Variable in the select statement

    Hello

    Can we define a variable in the select statement.

    Example:

    Select firstname, lastname
    employees;

    in this simple select statement we can define x as number?
    select fname,lname
    from employees
    where rownum <= 30;
    
  • Why I can't use the procedure in the select statement

    Why I can't use the procedure in the select statement

    And you may not usa a SQL function if it has out parameters

    SQL> create function myfun(p1 in out number) return number is
      2  begin
      3  p1:=1;
      4  return 2;
      5  end;
      6  /
    
    SQL> select myfun(5) from dual;
    select myfun(5) from dual
           *
    ERRORE alla riga 1:
    ORA-06572: Function MYFUN has out arguments
    

    In fact, the problem is that an output parameter is passed 'ref' and not 'val '...

    Max

  • 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

  • printing problem in pdf and csv using bind variables

    Hello

    I created a simple sql statement using a query and bind variables. I noticed when I remove the bind variables and hardcode the values that the CSV/PDF links work. When I handed the return variables in the query, the WB shows "no data found" and pdf shows only the column header.

    If anyone can help me, I would be very happy!


    Thank you
    Ayed P.

    Hello

    How are set the bind variable? If there are topics evaluated by default on the elements of the page, so is not necessarily enough to ensure that the exports are their values. To set values, I tend to use calculations, conditional that the element is null, what works "Before Header". In this way, the value is stored in the session and is available for export. I think the defaults to be those that are defined when the page is submitted and are not available until now.

    Andy

  • Using a variable as a SELECT field

    I try to get shipping to a different weight and postal codes. I query a table to get a zip code provided by the user area. This works. Then, I want to use this area to retrieve the shipping cost for a specific weight of another table. I put the box as a variable and use it as follows: SELECT #Zone # FROM Ground WHERE Wt = weight # #. If I use the name of the actual area instead of the variable, everything works fine. When I use the variable, however and try out of her results with the variable #Zone #, I get the original name in the field name box, not the rate that is listed under this domain name

    It is good to use a variable of the way I have? If so, how to get the result? If not, is there another way to get a field name for a query from another query? Thank you.

    You can use a variable to dynamically change the select field, but it is rarely a good idea.
    Here's how you would do in this case:


    SELECT
    #Zone # AS ShippingEstimate
    Of
    On the ground
    WHERE
    WT = #weight #.


    #weight # kilograms, to the shipping area: #Zone #, cost #MaintenanceNightmare.ShippingEstimate # Euros.



    The suggestion to normalize your database, was a good thing.

  • Can OBIEE use Bind Variables?

    I doubt that it would be used for warehouse queries, but I'm the question arises. Has anyone used in OBIEE?

    [Here is a brief summary about them. | http://www.akadia.com/services/ora_bind_variables.html]

    I checked with the support of Oracle and it's official - OBIEE does not support the bind variable.

Maybe you are looking for

  • Look at the different time to local time

    I went to the settings and changed to local time, an hour before. Now, I can't return to standard time time. I tried to cancel it and return it, but he wants to let do me.

  • wallpaper not Centrez Slatebook 14

    Is there a way to center the wallpaper on the home screen, or so that it does not move as you would on a phone?

  • Message from blackBerry Smartphones I get after you set up e-mail. Help please

    What should I do to remedy this? Dear customer of AT & T Yahoo!: We noticed that you access using mail not secure electronic settings in your email program. We want to make sure that your AT & T Yahoo! Member ID, password, and e-mail messages are tra

  • If easy to unintentionally click license, how do I undo that?

    Just started today and luckily added previews in a library when I noticed that I had clicked "license" on three of them. I can't find a way to cancel it. As they have not yet been downloaded, it seems that there should be a way to update the library.

  • Amnesia of Photoshop

    Hey there,When I choose the paint bucket tool, for example, and use it, then I close Photoshop and reopen and press G, then the gradient tool is selected again...same thing with the other tools...I remember my old version of Photoshop has been able t