Encapsulating a query in a view with "parameters"

I have a complex query using analytic functions and an inline view, something like:
select * from (
select a, b, c, row_number() over (partition by x, order by y) rn
where b like 'XXX%'
where rn = 1;
(The actual query is a little more complex, but that's the idea). This query performs very well.
As the query is of some general use, I'd like to package it up. However, the 'XXX%' pattern will vary with each use.
If I try to make a view v which is the query minus the XXX% where clause, the optimiser cannot merge the where clause and the view in a query like
select * from v where b like 'XXX%'
This doesn't surprise me too much - merging like that is going to be hard (if indeed it's possible at all!) As a result, the query using the view is significantly slower.
Is there any way of making my original query reusable? For PL/SQL, I can use a function returning a REF CURSOR and taking the pattern as a parameter - but I need to use this from SQL.
I could write a pipelined function and then do select * from table(my_fn('XXX%')). However, this is in 8i, where I don't have that option. Also, for a pipelined function, I'd need to define a record type and an associated table type - what seems like quite a lot of code for what is conceptually pretty simple.
Have I missed any obvious options? I can live with the pipelined function and "no way until 9i" - but only as a general answer. For my current specific issue, that's equivalent to "you can't do this".
I thought of using SYS_CONTEXT, but if I understand correctly, I can only use that in PL/SQL, as I can't set the context outside of an authorised package. Is that right, or is there a way I could use contexts? (Hmm, I need to be able to use the query from SQ, but I could probably execute a PL/SQL procedure before running the query, to set things up - does that help?)
Thanks for any suggestions.
Paul.

SYS_CONTEXT would work, as would package global variables.
I once wrote an example about this (though with TABLE function but for your case the principle stays the same) which you may find here:
Re: TABLE FUNCTION - Using database view - send parameters to the function.
hth, michael

Similar Messages

  • How I can create view with parameters?

    I have very big query (2000 rows) and 2 parameters.
    How I can create view with parameters?

    If I use this small part of my query than I have error :
    java.lang.NullPointerException
         at oracle.javatools.db.ora.OracleSQLQueryBuilder.buildQuery(OracleSQLQueryBuilder.java:199)
         at oracle.javatools.db.ora.OracleSQLQueryBuilder.buildQuery(OracleSQLQueryBuilder.java:147)
    What does it means?
    select
    ' Payroll ' as Revenue
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and ( nvl(a.scode, 0) between 60000 and 6009000 )
    union all ---------------------------------------------------------------------------------------------------------------------------------
    select
    ' Payroll Taxes '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    (nvl(a.scode, 0) between 60100 and 60690 )
    union all -------------------------------------------------------------------------------------------------------------------------------
    select
    ' Workers Comp/Disability '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    ( nvl(a.scode, 0) between 61200 and 61260)
    union all -------------------------------------------------------------------------------------------------------------------------------
    select
    ' Pension and Hospitalization '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    ( nvl(a.scode, 0) between 61000 and 61550 )
    union all -------------------------------------------------------------------------------------------------------------------------------
    select
    ' Other Labor Costs '
    , t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
    from
    acct a, total t, property p, param par
    where
    nvl(t.hacct, 0) = nvl(a.hmy, 0)
    and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
    and nvl(t.iBook, 0) = 0
    and nvl(a.iacctType, 0) = 0 /*Regular accts*/
    and nvl(t.hppty, 0) = nvl(p.hmy, 0)
    and
    ( nvl(a.scode, 0) between 616000 and 616400 )

  • How to create a view with parameters; read the documentation but nothing!

    Hello!
    I'm new to the Oracle world but together with my coworkers we need to very quickly study Oracle to figure out whether we'll add Oracle to our list of supported databases or not.
    Question: How do I create a view with parameters?
    I've read the documentation but I could not find this! I found the sql syntax to create a view but no parameters whatsoever...
    I have found on the web some very complicated way of doing this, but doesn't Oracle support Views with parameters?
    The goal here is to return a recordset, don't forget, so,please don't speak about stored procedures unless you are going to tell me how to get a recordset out of a stored procedure! ;)
    Thanks for all your help and attention!
    Jorge C.

    You can set up a parameterized view via context as follows:
    1. Set up a procedure to set your context values:
    create or replace procedure p_set_context (p_context IN VARCHAR2,p_param_name IN VARCHAR2,p_value IN VARCHAR2)
    as
    BEGIN
    sys.dbms_session.set_context(p_context,p_param_name,p_value);
    END;
    2. Create your context using the procedure you just created
    create or replace context my_ctx using p_set_context
    3. This is the test table I'll use
    create table my_table(col1 number)
    and populate it:
    begin
    for v_index in 1..10
    loop
    insert into my_table values(v_index);
    end loop;
    end;
    and the view that will be parameterised
    create or replace view v_my_table as select col1 from my_table where col1 between sys_context('my_ctx','start_range') and sys_context('my_ctx','end_range')
    4. Now set the parameters using the procedure above.
    begin
    p_set_context('my_ctx','start_range','1');
    p_set_context('my_ctx','end_range','5');
    end;
    5. Selecting from my_table will give you 1 to 10 (no surprise there :-) )
    selectng from v_my_table will give you 1 to 5
    You can use the context to set formats etc using the same principle. A common gotcha to watch for is trying to set the context directly using DBMS_SESSION.SET_CONTEXT instead of creating a procedure. This belongs to SYS and SYS won't have the privileges to set your context so you get an insufficient privileges result leading to much headscratching and unnecessary grants (at least that's my understanding of it).
    Sorry Jorge, as you're new to Oracle I should also have pointed out for completeness sake, that you can change the parameters at any time through recalling the p_set_context, for example, following on from above, after your "select * from v_my_table" and seeing 1 to 5, you could then do
    begin
    p_set_context('my_ctx','start_range','3');
    end;
    and when you requery 'Select * from v_my_table' you will now see rows 3 to 5.
    Bit of a simplistic example, but you can see how easy it is. :-)
    Message was edited by:
    ian512

  • Is it possible to create views with parameters ?

    Hi,
    As MS-Access, is it possible to create views with parameters ?
    Ms-Access syntax : parameters [a] text; select * from table where code = [a]
    If yes, can you give samples ?
    Regards
    Pascal

    I suggest you you write a stored procedure that returns a recordset in oracle. Then execute the stored procedure and loop through the record set.
    Look in in MS Knowledgebase searching on ADO Stored Proceedures for the VB/C++/VBS .. code.
    Look in in Oracle PL/SQL guide for the Stored Proceedure code.

  • View with parameters

    Hello,
    Can we create the view with the parameters? How to do that? We need to create the sql script with parameter for super user to query, instead of create sql script then we would like to create the view then user can select only view.
    Many thanks in advance. :-)

    Hi,
    Views using SYS_CONTEXT, as Justin mentioned, are perhaps the most common way to simulate parameterized views in Oracle.
    Another method is to use a table (usually a Global Temporary Table) to hold the parameters. The view can then join to the table, use it in scalar sub-queries, IN-sub-queries, etc.
    This is the best way if you need to use the same parameterized view two (or more) times in the same query, with different parameters each time.
    Edited by: Frank Kulash on Oct 10, 2008 4:04 PM
    Sorry, I meant to reply to OP.

  • Select query in materialized view with two dblinks

    Hi All,
    We have oracle 10g On windows.
    We are trying to create materialized view. Scenario is we have base table on other database and we are creating mview on different database.
    Basa database have two schema's and i am selecting records from that two schema's using two private db links.
    But when i am tryin gto create mview its not getting created. After 15 hrs. its still showing creation command and not finished.
    Query is :-
    Is it good practice to have two db links in select query of materialized view.

    Billy  Verreynne  wrote:
    Chanchal Wankhade wrote:
    Is it good practice to have two db links in select query of materialized view.Same db link being used twice, or two different db links?
    If the former, you ideally want the local Oracle db to send the join to the remote database, and for the remote database to drive the join between those 2 tables. There is a hint (<i>driving_site</i>) that can be used - or the join query can be defined on the remote database as a view, and the local materialised view can then use that remote view.
    If you have 2 different db links and joining across these - usually a bad idea to perform distributed database joins. There are lots of limitations as to how the tables can be joined. Worse case, full table scans of both remote tables, pulling all the rows from the 2 remote database tables to the local database, and joining these on the local database.
    I have seen some severe performance issues in the past as a result of distributed joins. I'll rather use 2 materialised views for pulling both distributed tables's data locally, and then do the join on local data (using indexes, partition pruning, etc)Hi Billy,
    My scenario is i have two database database A and database B. Database A is having two schema's SCOTT AND HR. SCOTT schema have select privileges on HR schema.
    DB LINK is between Database B to Database A. name is db.link.B.A.oracle.com.
    What if i priovide while creating materialized view, the schema name before the table name in database B for this particuler table so it will pick up the table from that schema using same DB LINK(db.link.B.A.oracle.com.) that i am using to fetch records from SCOTT schema.
    Above schnario is like two base schema's and one db link using two schema.

  • Makes it possible to create view with parameters

    makes it possibel to create view with paramater, example
    create or replace view v_test(segment varchar2)
        select * from ref_user where segment = segmentThanks

    thanks..
    select count(distinct substr(a.svm_id,1,10)) jumlah " +
       " from daily_distribution_pop a, ref_toko b " +
       " where " +
       " substr(a.svm_id,1,10)=b.id and b.segment_type = 'A' and enable_flag='Y' " +
       " and a.tgl_visit between to_date('" + fromStartDate + "', 'dd/MM/yyyy') and to_date('" + fromEndDate + "', 'dd/MM/yyyy')
         and " + whereA + "= '" + whereB + "' " +
       " and substr(a.pom_id,1,2) = 'DP' and (a.qty_instore <> 0 or a.qty_delivered <> 0) ";
    {code}
    where fromStartDate,  fromEndDate, whereA, whereB  is variable parameter from asp.net.
    how to i can implement with view                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to call a url i-view with parameters

    Hello,
    I want to make a portal navigation in a absolute way. This call should open a url-iview. In this iview the main url string is placed. Further more, a url-parameter ("test") is placed with a standard value. Now, i want to call this iview (see the call below) and hand over the value of this url-parameter. But how could this be done? In the following way, it doesn`t work. The iView will be called but the parameter is not settet.
    Call:
    WDPortalNavigation.navigateAbsolute(
                    "ROLES://portal_content/de.dbag.dbag-f/de.dbag.optitechpro.connection_monitor-f/com.dbag.iViews-f/com.dbag.urltest-i",
                    WDPortalNavigationMode.SHOW_INPLACE,
                    (String) null,
                    (String) null,
                    WDPortalNavigationHistoryMode.NO_DUPLICATIONS,
                    (String) null,
                    (String) null,
                    "test=NUIBI");
    best regards
    Mathias

    hi Mathias
    Try this
    1) First right click on the iView you wish to open and click Open -> Object
    2) In the iView editor you will see:
    url parameter : The parameter identifier as recognized by the information source
    value: The value of the parameter
    type: The data type
    personalize:Define if portal end users can view the param and its assigned value and if they can personalize the iView at runtime
    display name: The display name for the parameter identifier
    3) Once you have defined the iView’s URL to the targeted Web page, you may need to configure parameters that are passed to the information source as part of the URL .
    4) The parameter name is something that shouldn’t be changed because it is recognized by the information source .
    5) The parameter value can be changed.
    6) The type specifies data type of the parameter. String: Apply this option for all data types whose property is for example, an integer or string. Mapped User and Mapped Password : Apply this option when the URL parameter requires authentication with the information source at runtime.
    7) The Personalization -specifies whether or not portal end users can view the parameter and its assigned value if they personalize the iView at runtime.
    Hidden: The end user does not see the parameter and its value. This is the default setting.
    Read/Write: The end user sees the parameter and is able to modify its value.
    Read Only: The end user sees the parameter and the fixed value assigned to it. The end user cannot modify the parameter value.
    8) The display name - specifies an intuitive display name for the parameter identifier. If you set the parameter to be viewable by end users at runtime, this name is displayed instead of the parameter identifier, which is often abbreviated and unintuitive. This attribute is available only if Read/Write or Read Only is selected in the Personalize attribute
    9) The Request method:
    Get – appends parameters to the URL when the data request is sent to the information source. The server receives the data in one long query string, which typically limits the length of parameters that can be passed.
    Post - sends parameters for the URL in the header of the data request stream (parameters are not appended to the URL). This allows for long parameters to be passed to a script and parsed one element at a time. POST is only supported when the Fetch Method property defined in the iView is set to Server-side
    Regards
    Pratyush

  • Can we create a Materialized View with Parameters?

    Experts,
    Can we create a materialized view by passing parameters to it. so that we change its value dynamically.
    If yes, plese provide me the eample also.
    Regards
    ND

    I have below mentioned query to be used in MV :
    SELECT ivr_vw.event_type, ivr_vw.event_sub_type,
    ivr_vw.channel_cd,
    ivr_vw.csg_event_id,
    ivr_vw.csg_title,
    ivr_vw.itv_title,
    ivr_vw.program_id,
    ivr_vw.price,
    ivr_vw.addt_flag,
    (SELECT FROM_TZ(TO_TIMESTAMP (TO_CHAR (to_date(ivr_vw.start_date,'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS'),
    'MM/DD/YYYY HH24:MI:SS' ), 'EST')
    AT TIME ZONE 'MST' FROM DUAL) start_date,
    (SELECT FROM_TZ(TO_TIMESTAMP (TO_CHAR (to_date(ivr_vw.end_date,'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS'),
    'MM/DD/YYYY HH24:MI:SS' ), 'EST')
    AT TIME ZONE 'MST' FROM DUAL) end_date,
    (SELECT FROM_TZ(TO_TIMESTAMP (TO_CHAR (to_date(ivr_vw.start_order_window,'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS'),
    'MM/DD/YYYY HH24:MI:SS' ), 'EST')
    AT TIME ZONE 'MST' FROM DUAL) start_order_window,
    (SELECT FROM_TZ(TO_TIMESTAMP (TO_CHAR (to_date(ivr_vw.end_order_window,'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS'),
    'MM/DD/YYYY HH24:MI:SS' ), 'EST')
    AT TIME ZONE 'MST' FROM DUAL) end_order_window,
    ivr_vw.dnis_cd, ivr_vw.packaged_event_id, ivr_vw.no_instalments,
    ivr_vw.disclaimer_flag, ivr_vw.english_voice_file_name,
    ivr_vw.spanish_voice_file_name, ivr_vw.package_flag,
    ivr_vw.is_all_day_event, ivr_vw.upsell_data, ivr_vw.dur_guaran_flag,
    ivr_vw.cp_profile_id, ivr_vw.high_def_flag
    FROM ppv_ivr_vw ivr_vw,
    (Select time_diff,
    use_daylight
    From ppv_zip_timezones ztz
    Where ztz.zip_code = 80014
    ) timeOffset
    WHERE NOT EXISTS (
    SELECT 'x'
    FROM ppv_channels_blackout_vw blk_vw
    WHERE ivr_vw.channel_cd = blk_vw.channel_cd
    AND blk_vw.zone_type_code = 'Area Code'
    AND blk_vw.zone_code = '435');
    Here, the column 'ztz.zip_code = 80014' should change dynamically as per the request of the user.
    Is it possible. If yes, what is the process of doing so.?
    Regards
    ND

  • Call graphical calc view with parameters

    Hello,
    We want to call a graphical calculation view that requires parameters via CE functions.
    Is this possible? How can we do that?
    Thanks,
    Oshrit.

    Hello,
    We still don't know, how is it possible to select from CV with parameter through CE function.
    Thanks,
    Amir

  • Invocation report (Discoverer Viewer) with parameters from an application

    Hi everyone,
    I'm proving report in Discoverer Viewer invoking them from an application, which sends parameters to him.
    I cannot obtain, that they directly execute when doing click in the URL of execution with its parameters, but that opens the screen where it requests to enter the parameters, without assigning those that they are arriving to him in the URL.
    I verified if the problem were in the name of the parameters and apparently it takes the values from such by the order in which they arrive.
    Also I verified that the values of parameters are arriving correctly from the application.
    Somebody can help me with this?
    Thank you very much
    Ana

    Hi,
    I could resolve the problem.
    The creation parameters in discoverer reports is case sensitive with the parameters that arrive from an application.
    Anyway, thank you
    Ana

  • Speed of simple query to complicated view with few data increases after 3rd execution

    Hello everyone,
    I'm developing an OLTP application where a complicated view exists that is queried often by the application through Tomcat.
    The application itself uses a framework that generates the SQLs on the fly, so no parameter binding is possible.
    What I experience is the following:
    If I execute the query from the application, it always takes about 3 seconds to complete, also for subsequent runs (Tomcat uses ojdbc6.jar)
    If I execute the same query from SQL Developer it is the same behaviour. If I execute from Toad, it's the same behaviour for the first two runs, afterwards it executes in <50ms.
    I assume that it has something to do with plan creation/caching. How can I prove it and - best - fix it?
    Right now I'm using 11.2 XE running on my laptop together with Tomcat. In production it will be on a 11.2 SE1.
    The plan itself shows little to no cost. This is expected, as the tables are almost empty and all joins are indexed as needed (the last row of 103 steps is):
    |   0 | SELECT STATEMENT                                        
    |                           
    |
    1 |  4876 |
    26  (12)| 00:00:01 |
    The statement itself is
      SELECT
        .....all view columns...
        FROM myview
       WHERE (myview.user_id = 1010)
    The statement is always generated like this, but with changing user_id for different users. The plan ID is always the same, no matter what the user_id is.
    Is it possible to have the queries fast from the beginning / 2nd run of the query?
    Is is only happening on 11.2 XE and will be gone in 11.2 SE1?
    Thank you & Best regards,
    Blama

    Hello,
    thanks for pointing me in the right direction. I read http://docs.oracle.com/cd/E18283_01/server.112/e16638/optimops.htm and start to understand the feature.
    From the examples there and in http://www.oracle.com/technetwork/articles/sql/11g-sqlplanmanagement-101938.html I'd expect different behaviour than I get. Please see this example:
    I'll use 3 SQLs in the example. These are:
    1:
    SELECT sql_id, plan_hash_value, CHILD_NUMBER, EXECUTIONS, BUFFER_GETS, IS_BIND_SENSITIVE AS "BIND_SENSI",
           IS_BIND_AWARE AS "BIND_AWARE", IS_SHAREABLE AS "BIND_SHARE"
    FROM   V$SQL x
    WHERE  SQL_TEXT LIKE 'SELECT /*mytest*/%';
    2:
    SELECT /*mytest*/ * FROM V_LEAD_MATCHED_UNDISMISSED WHERE user_id = 1010;
    3:
    SELECT /*mytest*/ * FROM V_LEAD_MATCHED_UNDISMISSED WHERE user_id = 1011;
    The test:
    SQL1: no rows returned.
    SQL2: 2 sec, 2 rows (expected).
    SQL1:
    SQL_ID        PLAN_HASH_VALUE CHILD_NUMBER EXECUTIONS BUFFER_GETS BIND_SENSI BIND_AWARE BIND_SHARE
    gz8m7d1k2ha27      3045614858            0          1         293 N          N          Y       
    SQL2: 3 secs, 2 rows.
    SQL1:
    SQL_ID        PLAN_HASH_VALUE CHILD_NUMBER EXECUTIONS BUFFER_GETS BIND_SENSI BIND_AWARE BIND_SHARE
    gz8m7d1k2ha27      3045614858            0          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            1          1         293 N          N          Y       
    SQL2: 3 secs, 2 rows.
    SQL1:
    SQL_ID        PLAN_HASH_VALUE CHILD_NUMBER EXECUTIONS BUFFER_GETS BIND_SENSI BIND_AWARE BIND_SHARE
    gz8m7d1k2ha27      3045614858            0          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            1          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            2          1         293 N          N          Y
    SQL2: 54 millisecs(!), 2 rows.
    SQL1:
    SQL_ID        PLAN_HASH_VALUE CHILD_NUMBER EXECUTIONS BUFFER_GETS BIND_SENSI BIND_AWARE BIND_SHARE
    gz8m7d1k2ha27      3045614858            0          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            1          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            2          2         377 N          N          Y
    SQL2: 65 millisecs(!), 2 rows.
    SQL1:
    SQL_ID        PLAN_HASH_VALUE CHILD_NUMBER EXECUTIONS BUFFER_GETS BIND_SENSI BIND_AWARE BIND_SHARE
    gz8m7d1k2ha27      3045614858            0          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            1          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            2          3         461 N          N          Y
    Now everytime the statement is issued, it would use the fast child_number=2.
    I change the SQL to the one with the new user_id:
    SQL3: 2 secs, 2 rows (expected).
    SQL1:
    SQL_ID        PLAN_HASH_VALUE CHILD_NUMBER EXECUTIONS BUFFER_GETS BIND_SENSI BIND_AWARE BIND_SHARE
    gz8m7d1k2ha27      3045614858            0          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            1          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            2          3         461 N          N          Y        
    0psg36f5rf8q2      3045614858            0          1         293 N          N          Y    
    SQL3: 2 secs, 2 rows.
    SQL1:
    SQL_ID        PLAN_HASH_VALUE CHILD_NUMBER EXECUTIONS BUFFER_GETS BIND_SENSI BIND_AWARE BIND_SHARE
    gz8m7d1k2ha27      3045614858            0          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            1          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            2          3         461 N          N          Y        
    0psg36f5rf8q2      3045614858            0          1         293 N          N          N        
    0psg36f5rf8q2      1139782015            1          1         293 N          N          Y
    SQL3: 2 secs, 2 rows.
    SQL1:
    SQL_ID        PLAN_HASH_VALUE CHILD_NUMBER EXECUTIONS BUFFER_GETS BIND_SENSI BIND_AWARE BIND_SHARE
    gz8m7d1k2ha27      3045614858            0          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            1          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            2          3         461 N          N          Y        
    0psg36f5rf8q2      3045614858            0          1         293 N          N          N        
    0psg36f5rf8q2      1139782015            1          1         293 N          N          N        
    0psg36f5rf8q2      1139782015            2          1         293 N          N          Y 
    SQL3: 55 millisecs(!), 2 rows.
    SQL1:
    SQL_ID        PLAN_HASH_VALUE CHILD_NUMBER EXECUTIONS BUFFER_GETS BIND_SENSI BIND_AWARE BIND_SHARE
    gz8m7d1k2ha27      3045614858            0          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            1          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            2          3         461 N          N          Y        
    0psg36f5rf8q2      3045614858            0          1         293 N          N          N        
    0psg36f5rf8q2      1139782015            1          1         293 N          N          N        
    0psg36f5rf8q2      1139782015            2          2         377 N          N          Y
    SQL3: 56 millisecs(!), 2 rows.
    SQL1:
    SQL_ID        PLAN_HASH_VALUE CHILD_NUMBER EXECUTIONS BUFFER_GETS BIND_SENSI BIND_AWARE BIND_SHARE
    gz8m7d1k2ha27      3045614858            0          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            1          1         293 N          N          N        
    gz8m7d1k2ha27      1139782015            2          3         461 N          N          Y        
    0psg36f5rf8q2      3045614858            0          1         293 N          N          N        
    0psg36f5rf8q2      1139782015            1          1         293 N          N          N        
    0psg36f5rf8q2      1139782015            2          3         461 N          N          Y
    What I notice: The plan_hash_value is the same for each of the 1st executions of a SQL. This is expected, as only the bind parameter("user_id" in the SQL text) differs.
    I wonder if the rest is also OK the way it is. In production the SQL will be called with many different user_ids. Will it always take the steps of generating these three rows in v$sql?
    Is there anything I can do to make the calls 1-3 to every of the different user_id-statements faster? I'm pretty sure that the time it takes is related to query parsing and plan building, but please correct me if I'm wrong.
    Thanks & Best regards,
    Blama

  • How to find exact query executed by reports with parameters

    Hi,
    I am running a report which errors out with below log messages.
    REP-0004: Warning: Unable to open user preference file.
    REP-0300: ORACLE error occurred.
    REP-0069: Internal error
    REP-57054: In-process job terminated:Terminated with error:
    REP-300: ORACLE error occurred.
    In toad, the query is not giving any error message.
    I want to know what exact query is being executed by oracle report server.
    How can I find exact query executed?
    Abdul Wahid

    Hi Bobby,
    I had already tried to enable trace. But when I enable trace, report builder crashes!!
    I created SR also, and oracle says that they do not support 10.1.2.0.2. I should update to 10.1.2.3.
    I installed the 10.1.2.0.2 in xp mode and tried to update with 10.1.2.3. However, the updgrade failed saying that there is no update patch required/found or something like that.
    Abdul Wahid

  • How to run a View with parameters

    Hi guys,
    I have a view which has to take the USERNAME of the current user connected to the database as a parameter:
    Create or Replace View XYZ(A1,A2,A3)
    AS Select AA1, AA2, AA3
    from X1, X2
    where ...
    and X1.id_valid in (select XX3.id_valid
                   from X3 XX3
                   where XX3.ID_VALID = X1.id_valid
                   and XX3.username = USERNAME1 )
    Where USERNAME1 is the database user connected to it!.
    Could you give me a hand please?

    Just use the USER pseudocolumn ...
    create view v as
    select *
    from all_users
    where username = user;Richard

  • Create a view with parameter

    it's posible create a view with parameters?
    i want to create a view and pass it parameters, in the same way when i create a procedure or function.
    i never have seen it, but i would like to know if that's posible
    thanks

    You cannot create a view with parameters. The only way is to use a stored proc to dynamically create the sql statement. The substitution variable approach does not work. SQL*Plus will prompt for the value of the variable at compile time (i.e. when you create the view) and use the value you provide in the view's query.
    SQL> create or replace view jws_test_v as
      2  select * from jws_test where flag = '&flg'
      3  /
    Enter value for flg: AA
    old   2: select * from jws_test where flag = '&flg'
    new   2: select * from jws_test where flag = 'AA'
    View created.
    SQL> select * from jws_test_v
      2  /
    no rows selected
    SQL> select text from user_views where view_name = 'JWS_TEST_V'
      2  /
    TEXT
    select "LEV1","LEV2","LEV3","LEV4","LEV5","LEV6","FC","FLAG","ONAFT","ONAPT","CU
    PEFT","CUPEPT" from jws_test where flag = 'AA'This makes sense, since substitution vartiables are a sqlplus construct, not a sql or Oracle construct. A view constructed in this way would not be callable from anywhere other than sqlplus.

Maybe you are looking for

  • How to identify which process belongs to particular instance of WLS running

    Hi, I have a simple question for which i couldn't find an answer. Suppose i have 6 instances of weblogic servers running on a Unix OS. I want to kill a particular instance using "kill" command. I do a "ps -ef | grep java" and find all the instances a

  • 9i Performance manager

    Hi folks, I am using Performance Managero monitor my server activities and it is very userful. But I would like to know 2 things: 1 - Where the performance statistics come from? from v$stats tables? 2 - how to start new statistics? When I start "Top

  • JDeveloper and Subversion - Cannot Connect To Repository

    Using JDeveloper 11.1.1.6. I have a Subversion repository set up on a server that I can connect to from my local machine using the appropriate URL. When I attempt to set up the repository connection in JDev, I get a "Connection Refused" error. I am u

  • How do I create keyswitches in EXS24?

    I'm trying to figure out how to set up keyswitches in EXS24. I've read & re-read the manual and can't figure out how to do it. Can anyone assist?

  • Printer profile

    How do you get the D7560 to print what is on the screen? The monitor is profiled by a Spyder2. I am using PS-CS3. I've tried using Adobe gamma 1998, and every other profile that I can find. For example - a southwestern red rock has a very orange hue.