Simple use of variables in query

Hi,
i've just started using PL/SQL and as a long time user of TSQL the syntax is a bit confusing for me. I'm trying to test a simple query - using a variable to select some rows from a table. Lest assume that we have a table with data from different days and we want to view data from specific day.
I could use:
SELECT * FROM TABLE
where TRADE_DATE = '2010-10-23'
but what i would like to do is to pass the date value as a variable, in TSQL i'd just write:
declare @trade_date datetime
set @trade_date = '2010-10-23'
SELECT * FROM TABLE
where TRADE_DATE = @trade_date
Could someone help me and write the last query using PL/SQL syntax?
Also - it there some kind of a tutorial for people like me? comparison of simple queries written in both languages? tried to google it but didn't have luck.

There are a couple of differences besides variable syntax. The variable would look like this in PL/SQL:
declare
    v_trade_date date := DATE '2010-10-23';
begin
    select * into ?????  -- see below
    from   table
    where  trade_date = v_trade_date;
end;However the next difference is that PL/SQL does not implicitly return result sets to the client application, so you either have to select <b>into</b> a PL/SQL variable, or process the values in a loop, or explicitly return a ref cursor (or just do the processing in SQL statements within the procedure, without returning anything). I don't know much about T-SQL but I have the impression that in Oracle there is a stronger distinction between SQL (the interpreted query language) and PL/SQL (the compiled programming language) than the equivalents in SQL Server. Saubhik's example above is not PL/SQL (which you asked about) but plain SQL.
Using the example of SQL*Plus, you might use a ref cursor like this:
var r refcursor;
declare
    v_trade_date date := DATE '2010-10-23';
begin
    open :r for
    select *
    from   test_table
    where  trade_date = v_trade_date;
end;
print :ror
var r refcursor;
create or replace procedure p (p_out_results out sys_refcursor)
as
    v_trade_date date := DATE '2010-10-23';
begin
    open p_out_results for
    select *
    from   test_table
    where  trade_date = v_trade_date;
end p;
set autoprint on
exec p(:r)Edited by: William Robertson on Oct 24, 2010 5:31 PM

Similar Messages

  • Using Text Variable for Query Description

    hi all,
    I am currently trying to include this text variable in the query properties of the query.
    This text variable should be able to grab the 0CALMONTH as filter to be included into the query properties. but currrently  cannot grab the particular information from the query properties.

    Hi
    If I got your Question properly , You are trying to use Replacement Path Variable .. If it is so
    /people/kamaljeet.kharbanda/blog/2006/12/28/bex-characteristic-variable-with-replacement-path
    http://www.sd-solutions.com/documents/SDS_BW_Replacement%20Path%20Variables.html
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/009819ab-c96e-2910-bbb2-c85f7bdec04a
    Hope it helps

  • How to use bind variables in "query result" "validation rule"

    I have created a validation rule on my entity object. rules=compareValidator attribute=InvoiceNumber operator=NotEquals queryResult=SELECT ...
    In this query, I would like to reference entity attributes from the current instance of the entity when the value fires, for example SELECT invoice_number where invoice_id != :invoiceId
    How can I reference a bind variable inside the query result compare validator validation rule?
    THanks,
    Jerry.

    bump

  • Name of column using text variable in Query Designer

    Hello!
    I have 3 columns with amounts, 1 characteristic value variable and 1 text variable.
    For example, names of this columns - 2005 year, 2006 year, 2005/2006.
    I fill names using only one text variable and I can call first 2 column. I use set offset of variables for second column.
    How can I call third column ''2005/2006"?

    Hi,
    u need a second Text varaible and u need to correct your existing text variable.
    Prerequisite: u need for your key figures the same KF-variable
    1. Edit your existing text variable  lets say its called &Text1&
    2. Select your Text variable and go to tab "replacement path"
    3. Choose a) InfoObject b) Choose key
    4. In section "use value range" choose from  value
    5. Create a new text variable lets call it &Text2&
    6. make exact the same settings as for your first text variable butchoose for "value range" to value
    Now u use this text variables for your KF:
    KF 1 -> &Text1&
    KF 2 -> &Text1&
    KF 3 -> &Text1& / &Text2&
    This should make it!!
    Regards
    Tobias

  • ORA-01006 Using Bind Variables In A Dynamic SQL Contains Query

    I have the following dynamic SQL query :-
    declare
    TYPE typ_sql IS REF CURSOR;
    ltyp_sql typ_sql;
    lv_sql VARCHAR2(100);
    begin
    lv_sql := 'SELECT arx_id FROM arx WHERE CONTAINS ';
    lv_sql := lv_sql || (arx_full,''(:b1) WITHIN ui'') > 0';
    open ltyp_sql FOR v_sql USING ln_id;
    fetch ......
    close ......
    end;
    When the code tries to open the cursor it gives the above error. I presume it is the way Oracle is expanding the bind variable but I cannot find anything in the docs to say why this is happening or whether you can do this or not using bind variables ( CONTAINS query ). Any help would be appreciated, thanks,
    Stuart.

    lv_sql || '(arx_full, :b1 || '' within ui'') > 0';

  • Can we create range variable for Query Key Date

    Hello Gurus,
    Can we create a range variable for Query Key Date ? when I tried to give a range of values for Query Key Date, I am unable to find Range Values option. I found only Single Values.
    so, Please let me know if we can use Range variables for Query Key Date ??
    Thanks in advance,
    Regards,
    Aarthi

    Hi Aarthi,
    This is relevant for the time dependant master data that is being pulled in thw query. Like if you are using a nav attr in the query and this nav attr is time dependant, then which record (from the char master data) is to be pulled into the report, depends upon the key date that you specify.
    The default key date value is the date on which the query is executed, that is <Today>.
    Hope this helps...

  • Query don't use the right index when using bind variables

    Hi people !
    I need some help because I have an issue with a query that don t use the right Indexes as it should
    First of all, I have mainly three tables :
    ORDER : Table that contains description for each Order (approximately 1 000 000 Records)
    ORDER_MVTS : Table that contains the tasks made (called movements) to set up each Orders
    with quantity of packages prepared for each product (approximately 10 000 000 Records)
    PRODUCT : Tables that contains the products (approximately 50 000 Records)
    When I launch the query with hard coded values, it brings back response very fast
    because it uses the right index (ORDER_DHR_VALID) which represent the date and hour of the order
    (with format 'DD/MM/YYYY HH24:MI:SS'). The selectivity for this index is good.
    NB 1: I have to use the trick " >= Trunc(date) and < trunc(date) +1 " to filter on a simple date because
    the index contains hour and minutes (I know it wasn't probably a bright idea at conception time).
    NB 2: The index on ORDER_MVTS.PRODUCT_CODE is'nt discriminating enough because there is'nt enough different products.
    It's the same for index on CUSTOMER_CODE and on MVT_TYPE so only the index on ORDER.DHR_VALID is good.
    Here is the correct explain plan when I execute the query with hard coded values :
    SELECT SUM(ORDER_MVTS.NB_PACKAGE)
    FROM ORDER_MVTS, PRODUCT, ORDER
    WHERE ORDER.DHR_VALID >= TRUNC(to_date('14/11/2008 10:04:56','DD/MM/YYYY HH24:MI:SS'))
    AND ORDER.DHR_VALID < TRUNC(to_date('14/11/2008 10:04:56','DD/MM/YYYY HH24:MI:SS')) + 1
    AND ORDER_MVTS.MVT_TYPE = 'DELIVERY'
    AND PRODUCT.CODE = ORDER_MVTS.PRODUCT_CODE
    AND ORDER_MVTS.ORDER_CODE = ORDER.CODE
    AND ORDER.CUSTOMER_CODE = 'ADIDAS'
    AND PRODUCT.CODE = 1234
    Rows Row Source Operation
    1 SORT AGGREGATE
    2 NESTED LOOPS
    4 NESTED LOOPS
    2 INDEX UNIQUE SCAN (object id 378548) --> PRODUCT_PK
    4 TABLE ACCESS BY INDEX ROWID ORDER
    777 INDEX RANGE SCAN (object id 378119) --> ORDER_DHR_VALID
    2 TABLE ACCESS BY INDEX ROWID ORDER_MVTS
    30 INDEX RANGE SCAN (object id 377784) --> ORDER_MVTS_ORDER_FK
    Now the problem is when the query is used in a Cursor with bind variables.
    It seems like Oracle don't use index on ORDER.DHR_VALID because he can't figure out that he have
    to actually filter on a short period of time (only one day).
    So Oracle uses the index on ORDER_MVTS.PRODUCT_CODE which is'nt a bright idea (it takes 10 secondes instead of just one)
    Here is the bad explain plan :
    Rows Row Source Operation
    1 SORT AGGREGATE
    2 NESTED LOOPS
    722 NESTED LOOPS
    2 INDEX UNIQUE SCAN (object id 378548) --> PRODUCT_PK
    722 TABLE ACCESS BY INDEX ROWID ORDER_MVTS
    1790 INDEX RANGE SCAN (object id 377777) --> ORDER_MVTS_PRODUCT_FK
    2 TABLE ACCESS BY INDEX ROWID ORDER
    1442 INDEX UNIQUE SCAN (object id 378439) --> ORDER_PK
    Now I have found two solutions to this problem :
    1) using a Hint to force the use of index on ORDER.DHR_VALID (with /*+ INDEX(ORDER ORDER_DHR_VALID) */ )
    2) Using Dynamic SQL and keeping the date hard coded (but not the other values except mvt_type)
    For example :
    QUERY :=
    'SELECT SUM(ORDER_MVTS.NB_PACKAGE)
    FROM ORDER_MVTS, PRODUCT, ORDER
    WHERE ORDER.DHR_VALID >= TRUNC(TO_DATE('''||To_char(P_DTE_VAL,'DD/MM/YYYY')||''',''DD/MM/YYYY'')) '||
    AND ORDER.DHR_VALID < TRUNC(TO_DATE('''||To_char(P_DTE_VAL,'DD/MM/YYYY')||''',''DD/MM/YYYY'')) + 1 '||
    AND ORDER_MVTS.MVT_TYPE = 'DELIVERY'
    AND PRODUCT.CODE = ORDER_MVTS.PRODUCT_CODE
    AND ORDER_MVTS.ORDER_CODE = ORDER.CODE
    AND ORDER.CUSTOMER_CODE = :CUSTOMER
    AND PRODUCT.CODE = :CODE ';
    These two solutions work but Number 1 is bad in theory because it uses a Hint
    and Number 2 may be difficult to code.
    So my question is : Does someone knows another solution to force the use of index ORDER_DHR_VALID that can be simple and reliable.
    Thank you very much for support
    Edited by: remaï on Apr 1, 2009 4:08 PM

    What version of oracle you have? CBO work is different in 9i and 10g.
    Usually cost based optimizer do not want to use index for >< condition with binding variables because optimizer can not use statistic to determine selectivity, and by default selectivity of <> operators is low.
    (As I remember '>' selectivity by default is 5%, you have two conditions > and <, therefore resulting selectivity will be 0.05*0.05=0.0025 as two independent events, but selectivity of other conditions
    ORDER_MVTS.MVT_TYPE = 'DELIVERY' or ORDER.CUSTOMER_CODE = 'ADIDAS' looks much better for CBO)
    The best solution I see is do not use binding variables. Actually your query looks as searching query, which executes not so often, therefore you will not have perfomance win along of skipping execution plan creation.
    Edited by: JustasVred on Apr 1, 2009 10:10 AM

  • Declare, Set, and Use a variable in a SQL Developer Query

    I come from the SQL Server world and am trying to do something very simple: Declare, set, and use a variable in a query. For example:
    Declare @lastPeriod date;
    Set @lastPeriod = (select max(payperiod) from table 1 where payperiod < current_date);
    Select field 1,
    Field2
    From table2
    Where payperiod = @lastPeriod
    The variable is going to be used in more areas in the query which is why I am simply not using a Sub-query in the where clause. I appreciate any assistance.

    This forum is for issues with the SQL Developer tool. You'd get more response in the SQL And PL/SQL forum.
    That said, read up on bind variables and substitution variables.
    Whenever you can you should use Bind variables (e.g. *:lastPeriod* ), as they increase performance. In sqldev, there's no need to declare as you will be prompted to enter them on execution (F9), but you do if you execute as script (F5) (e.g. VARIABLE lastPeriod VARCHAR2(30);).
    Alternatively, Substitution variables (e.g. *&lastPeriod* ) will literally be substituted in your statement before the database parses it. In sqldev, there's no need to declare as you will be prompted to enter them on execution (either F9 or F5), but you can (DEF lastPeriod='TEST'; ).
    Have fun,
    K.

  • Can we use session variables in BI publisher's Data Model SQL Query?

    Hi Experts,
    We need to implement Data level security in BI Publisher 11g.
    In OBIEE we do so by using session variables, so just wanted to ask if we can use the same session variables in BI Publisher as well
    ie can we include the where clause in the Data Models SQL Query like
    Where ORG_ID = @{biServer.variables['NQ_SESSION.INV_ORG']}
    Let me know your views on this.
    PS: We are implementing EBS r12 security in BI Publisher.
    Thanks

    Read this -> OBIEE 11g: Error: "[nQSError: 23006] The session variable, NQ_SESSION.LAN_INT, has no value definition." when Creating a SQL Query using the session variable NQ_SESSION.LAN_INT in BI Publisher [ID 1511676.1]
    Follow the ER - BUG:13607750 - NEED TO BE ABLE TO SET A SESSION VARIABLE IN OBIEE AND USE IT IN BI PUBLISHER
    HTH,
    SVS

  • BUG ? :  ADF creating extra VO instance using bind variables in a LOV query

    ADF 11.1.1.1.0
    After "playing around" with bind variables Setting bind variables in view objects for LOV I've come across something strange that I've reproduce using the HR schema and tables Employees and Departments. Its a bit long but here goes :
    Using the HR schema tables departments and employeesI'm trying to create a LOV (selectOneChoice) for the
    employee department, the LOV having a bind variable that limits the values returned in this case returning only DepartmentId = 50
    I've create a VO lovDepartment (not based on an EO) with the following query :
    SELECT Departments.DEPARTMENT_ID,
           Departments.DEPARTMENT_NAME,
           Departments.MANAGER_ID,
           Departments.LOCATION_ID
    FROM DEPARTMENTS Departments
    where DEPARTMENT_ID  = :pDeptIdA LOV has been defined on the DepartmentId attribute of the EmployeesView.
    The lovDepartmentImpl overrides the executeQueryForCollection to set the bind variable value.
        @Override
        protected void executeQueryForCollection(Object object, Object[] object2,
                                                 int i) {
            setNamedWhereClauseParam("pDeptId", "50");       
            super.executeQueryForCollection(object, object2, i);
        }When using an ADF form to create a new employee the DepartmentId lov is empty.
    Enabling SQL tracing shows the following :
    [370] _LOCAL_VIEW_USAGE_model_EmployeesView_lovDepartment1_0 ViewRowSetImpl.doSetWhereClause(-1, pDeptId, null)
    [371] _LOCAL_VIEW_USAGE_model_EmployeesView_lovDepartment1_0 ViewRowSetImpl.execute caused params to be "un"changed
    [372] Column count: 4
    [373] _LOCAL_VIEW_USAGE_model_EmployeesView_lovDepartment1_0 ViewRowSetImpl.doSetWhereClause(-1, pDeptId, null)
    [374] _LOCAL_VIEW_USAGE_model_EmployeesView_lovDepartment1 ViewRowSetImpl.setNamedWhereClauseParam(pDeptId, 50)
    [375] ViewObject: _LOCAL_VIEW_USAGE_model_EmployeesView_lovDepartment1 Created new QUERY statement
    [376] _LOCAL_VIEW_USAGE_model_EmployeesView_lovDepartment1>#q computed SQLStmtBufLen: 235, actual=195, storing=225
    [377] SELECT Departments.DEPARTMENT_ID,
           Departments.DEPARTMENT_NAME,
           Departments.MANAGER_ID,
           Departments.LOCATION_ID
    FROM DEPARTMENTS Departments
    where DEPARTMENT_ID  = :pDeptId
    [378] Bind params for ViewObject: _LOCAL_VIEW_USAGE_model_EmployeesView_lovDepartment1
    [379] For RowSet : _LOCAL_VIEW_USAGE_model_EmployeesView_lovDepartment1_0
    [380] Binding null of type 12 for "pDeptId"
    [381] No Resource Bundle found but null value id:LOV_DepartmentId_LOVUIHints_NullValueId is defined in an ListBinding Definition.It would seem that 2 lovDepartment instances are used one at line 370 LOCALVIEW_USAGE_model_EmployeesView_lovDepartment1_0
    and one at line 374 LOCALVIEW_USAGE_model_EmployeesView_lovDepartment1
    The one at line 374 LOCALVIEW_USAGE_model_EmployeesView_lovDepartment1 gets the variable bound at line 374
    however LOCALVIEW_USAGE_model_EmployeesView_lovDepartment1_0 gets a null value and would explain the empty LOV
    Can anybody explain what is happening here ? (and how to use bind variables in LOV queries)
    Regards
    Paul
    (bump)
    Edited by: Paul (MITsa) on Jul 14, 2009 10:46 AM
    I've now tried all types of LOV from ChoiceList to Radio groupe by testing the application module - none of them work.....
    Edited by: Paul (MITsa) on 14-Jul-2009 22:52

    when you rinvoke executeQueryForCollection the bind variables are allready set and they exist in Object[] object2 method parameters.
    in order to change them you need something like:
    private void changeGenericBindVariable(Object[] params, String paramName, Object paramValue) {
    for (int i = 0; i < params.length; i++) {
    if (paramName.equals(((Object[])params)[0].toString()))
    ((Object[])params[i])[1] = paramValue;
    * executeQueryForCollection - overridden for custom java data source support.
    protected void executeQueryForCollection(Object qc, Object[] params,
    int noUserParams) {
    changeGenericBindVariable(params, "pDeptId", "50")
    super.executeQueryForCollection(object, object2, i);
    But its better to set bind variables before you executeQueryForCollection. like when you invoke LOV.
    For cascading LOVs and the problems i have check:
    [http://adfbugs.blogspot.com/2009/07/jdeveloper-11-r1-cascading-lov-bugs.html]

  • Using environment variables in a wmi query

    Hello
    I'm trying to use WMI Queries on Group Policy Preferences to targeting computers on my network.
    I have a file named testfile.txt in Windows directory and I check its last modified date to replace the policy files if the date is older of than current file.
    I set this query : Select * from CIM_DataFile where Name='C:\\Windows\\testfile.txt' and LastModified<'20140910145110.821214+180'.
    The replace action occurs on all machines where windows directory is 'C:\Windows\'. But there are machines on network where windows is installed on directory 'C:\Windows7'.
    So I was thinking to use %WindowsDir% environment variable in the WMI query to ckeck testfile.txt date on the correct directory where windows is installed.
    I've tried different ways to use this environment variable in WMI query with no success (For example: Select * from CIM_DataFile where Name='%WindowsDir%\\testfile.txt' and LastModified<'20140910145110.821214+180').
    Can someone help me with the correct syntax?
    Thanks.

    > I set this query : Select * from CIM_DataFile where
    > Name='C:\\Windows\\testfile.txt' and
    > LastModified<'20140910145110.821214+180'.
    >
    > The replace action occurs on all machines where windows directory is
    > 'C:\Windows\'. But there are machines on network where windows is
    > installed on directory 'C:\Windows7'.
    >
    > So I was thinking to use %WindowsDir% environment variable in the WMI
    > query to ckeck testfile.txt date on the correct directory where windows
    > is installed.
    Short answer: You cannot use environment variables in WMI filters.
    But you can modify your query:
    Select * from CIM_DataFile where (Name = 'C:\\Windows\\testfile.txt' or
    Name = 'C:\\Windows7\\testfile.txt' ) and
    LastModified<'20140910145110.821214+180'
    Event this one should work:
    Select * from CIM_DataFile where Name like 'C:\\Windows%\\testfile.txt'
    and LastModified<'20140910145110.821214+180'
    BTW: The variable should be %windir% anyway, not %windowsdir% :)
    Martin
    Mal ein
    GUTES Buch über GPOs lesen?
    NO THEY ARE NOT EVIL, if you know what you are doing:
    Good or bad GPOs?
    And if IT bothers me - coke bottle design refreshment :))

  • Query taking too long when using bind variable

    Hi All,
    There is a query in our prod DB which runs very slow (approx 2 hours) when it uses Bind Variables (using JDBC thin client), and when i try passing the variable using TOAD/SQL developer it runs fine.
    Explain Plan for running Query
    SELECT STATEMENT ALL_ROWSCost: 146 Bytes: 379 Cardinality: 1                                                   
         21 SORT ORDER BY Cost: 146 Bytes: 379 Cardinality: 1                                              
              20 NESTED LOOPS Cost: 145 Bytes: 379 Cardinality: 1                                         
                   17 HASH JOIN Cost: 22 Bytes: 42,558 Cardinality: 123                                    
                        15 MERGE JOIN CARTESIAN Cost: 15 Bytes: 8,910 Cardinality: 27                               
                             12 FILTER                          
                                  11 NESTED LOOPS OUTER Cost: 9 Bytes: 316 Cardinality: 1                     
                                       8 NESTED LOOPS OUTER Cost: 8 Bytes: 290 Cardinality: 1                
                                            5 NESTED LOOPS Cost: 6 Bytes: 256 Cardinality: 1           
                                                 2 TABLE ACCESS BY GLOBAL INDEX ROWID TABLE GDP.GDP_FX_DEALS_INCREMENTOR Cost: 4 Bytes: 28 Cardinality: 1 Partition #: 9 Partition access computed by row location     
                                                      1 INDEX RANGE SCAN INDEX GDP.GDP_FX_DEALS_INC_IDX_01 Cost: 3 Cardinality: 1
                                                 4 TABLE ACCESS BY INDEX ROWID TABLE GDP.GDP_FX_DEALS Cost: 2 Bytes: 228 Cardinality: 1      
                                                      3 INDEX UNIQUE SCAN INDEX (UNIQUE) GDP.GDP_FX_DEALS_KEY Cost: 1 Cardinality: 1
                                            7 TABLE ACCESS BY INDEX ROWID TABLE GDP.GDP_FX_DEALS Cost: 2 Bytes: 34 Cardinality: 1           
                                                 6 INDEX UNIQUE SCAN INDEX (UNIQUE) GDP.GDP_FX_DEALS_KEY Cost: 1 Cardinality: 1      
                                       10 TABLE ACCESS BY INDEX ROWID TABLE GDP.GDP_COUNTERPARTIES Cost: 1 Bytes: 26 Cardinality: 1                
                                            9 INDEX UNIQUE SCAN INDEX (UNIQUE) GDP.PK_CPTY Cost: 0 Cardinality: 1           
                             14 BUFFER SORT Cost: 14 Bytes: 448 Cardinality: 32                          
                                  13 TABLE ACCESS FULL TABLE GDP.GDP_CITIES Cost: 6 Bytes: 448 Cardinality: 32                     
                        16 TABLE ACCESS FULL TABLE GDP.GDP_AREAS Cost: 6 Bytes: 2,304 Cardinality: 144                               
                   19 TABLE ACCESS BY INDEX ROWID TABLE GDP.GDP_PORTFOLIOS Cost: 1 Bytes: 33 Cardinality: 1                                    
                        18 INDEX UNIQUE SCAN INDEX (UNIQUE) GDP.PORTFOLIOS_KEY Cost: 0 Cardinality: 1                               
    Explain Plan for Slow Query
    Plan
    SELECT STATEMENT ALL_ROWSCost: 11,526,226 Bytes: 119,281,912 Cardinality: 314,728                                                   
         21 SORT ORDER BY Cost: 11,526,226 Bytes: 119,281,912 Cardinality: 314,728                                              
              20 HASH JOIN Cost: 11,510,350 Bytes: 119,281,912 Cardinality: 314,728                                         
                   2 TABLE ACCESS BY INDEX ROWID TABLE GDP.GDP_PORTFOLIOS Cost: 1,741 Bytes: 177,540 Cardinality: 5,380                                    
                        1 INDEX FULL SCAN INDEX (UNIQUE) GDP.PORTFOLIOS_KEY Cost: 14 Cardinality: 5,380                               
                   19 HASH JOIN Cost: 11,507,479 Bytes: 87,932,495,360 Cardinality: 254,140,160                                    
                        3 TABLE ACCESS FULL TABLE GDP.GDP_AREAS Cost: 6 Bytes: 2,304 Cardinality: 144                               
                        18 MERGE JOIN CARTESIAN Cost: 11,506,343 Bytes: 18,602,733,930 Cardinality: 56,371,921                               
                             15 FILTER                          
                                  14 HASH JOIN RIGHT OUTER Cost: 3,930,405 Bytes: 556,672,868 Cardinality: 1,761,623                     
                                       5 TABLE ACCESS BY INDEX ROWID TABLE GDP.GDP_COUNTERPARTIES Cost: 6,763 Bytes: 892,580 Cardinality: 34,330                
                                            4 INDEX FULL SCAN INDEX (UNIQUE) GDP.PK_CPTY Cost: 63 Cardinality: 34,330           
                                       13 HASH JOIN OUTER Cost: 3,923,634 Bytes: 510,870,670 Cardinality: 1,761,623                
                                            10 HASH JOIN Cost: 2,096,894 Bytes: 450,975,488 Cardinality: 1,761,623           
                                                 7 TABLE ACCESS BY GLOBAL INDEX ROWID TABLE GDP.GDP_FX_DEALS_INCREMENTOR Cost: 2,763 Bytes: 52,083,248 Cardinality: 1,860,116 Partition #: 14 Partition access computed by row location     
                                                      6 INDEX RANGE SCAN INDEX GDP.GDP_FX_DEALS_INC_IDX_01 Cost: 480 Cardinality: 334,821
                                                 9 TABLE ACCESS BY INDEX ROWID TABLE GDP.GDP_FX_DEALS Cost: 1,734,205 Bytes: 8,320,076,820 Cardinality: 36,491,565      
                                                      8 INDEX FULL SCAN INDEX (UNIQUE) GDP.GDP_FX_DEALS_KEY Cost: 104,335 Cardinality: 39,200,838
                                            12 TABLE ACCESS BY INDEX ROWID TABLE GDP.GDP_FX_DEALS Cost: 1,733,836 Bytes: 1,331,145,696 Cardinality: 39,151,344           
                                                 11 INDEX FULL SCAN INDEX (UNIQUE) GDP.GDP_FX_DEALS_KEY Cost: 104,335 Cardinality: 39,200,838      
                             17 BUFFER SORT Cost: 11,499,580 Bytes: 448 Cardinality: 32                          
                                  16 TABLE ACCESS FULL TABLE GDP.GDP_CITIES Cost: 4 Bytes: 448 Cardinality: 32                     
    How can I avoid that.
    Thanks

    Hello
    Could you reformat your execution plans because they aren't particularly readable. The forums allow you to preserve the formatting of code or output by putting the symbol {noformat}{noformat} before and after the section of text you want to preserve formatting for. 
    If you write
    {noformat}select * from v$version
    {noformat}
    it will be displayed asselect * from v$version
    So can you run this above statement and post the output here so we know the full oracle version you are working with?  And finally, it would be really helpful to see the query you are running.  When you say it runs fine in Toad, is that when you replace the bind variables with the values or are you also using bind variables in Toad?
    Cheers
    David                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Using Bind Variables in Parameter Form's Query

    I want to use bind variables in the query of Parameter form. But
    it does not allows. What is the other way out. The structure of
    my Parameter form is as under:
    State:
    Customer:
    Now I want that I want to list only those customer in the
    Customer LOV which belongs to the selected state.
    Thanks.
    Muhammad Nadeem

    Can we just link to an oracle form using a url still as we can with reports? I've built a report that requires the user to select from a dynamic list as well, and I know how to do this through forms, but can I simply call the form from a webpage?

  • Query BI7: problem in using the variables of referenced caracteristics.

    Dear Experts,
    I have posted a question in "BI General" yesterday. Untill now, I haven't got any reply. So i decide to post it under this subject. And I hope somebody can help me.
    A query was created on the basis of an Infoset, in which there are many caracteristics created with reference to some existed caracteristics.
    However, in the new query, I was not able to use those variables which are already created and attached to the existed caracteristics. What's more, some variables are declared in the SAP exit, and they are compulsory in the new query.
    Given a very short delay in the project, it seems to me impossible to create all the variables for my new query.
    Is there anybody who has a solution or an idea for this problem?
    Thanks in advance!!!

    I was not able to use those variables which are already created and attached to the existed caracteristics.
    Ya,you cannot use the same variable to two(or more) infoobjects (though they use same reference) but what I observed in was eventhoug you get Error messaga when you do check in query designer.If you ignore and just execute the query it simply works.Just give it a try.
    Else you need to create new variables similar to existing one and use it.

  • How do I...Mimic Replacement Path with Query using Customer Variable Exits?

    Hello SDN:
    We are on BW 3.5 SP16.
    We are currently using a replacement path Query(RP) with variables
    to populate a variable in another Query(T).
    The problem we are having is with performance.
    The entry of variables in replacement path Query(RP) is optional (This is necessary there cannot be required values)
    When results from Replacement Path Query are small performance is fine. (e.g. 10 seconds)
    When results from Replacement path query are large performance suffers. (e.g. 1+ minutes)
    Users are free to leave the replacement path variables empty resulting in a large set of data to be replaced. This is the worst performance case.
    We would like to discover a way to conditionally execute the replacement path query. That is if users do not enter values for the replacement Query(RP) variables do not execute the replacement path query(RP).
    Does anyone know if this is possible within reason and in customer exit space?
    We have reviewed the situation from all angles and the requirement for the replacement path FUNCTIONALITY and the freedom for the user to leave variable values blank remains.
    I've been searching and reading SDN and SAP notes for about a week and do not find threads which address this situation.
    We are also exploring Customer variable exits to mimic replacement path functionality
    (different topic subject="How do I...Mimic Replacement Path with Query using Customer Variable Exits?")
    Any help will be appreciated
    Many thanks
    David Schuh

    My appologies-I posted this message with the wrong subject. I will repost it with appropriate subject.
    dave schuh

Maybe you are looking for