Change where clause filter based on prompt?

Hi,
I am trying to change my where clause filter based on a prompt selected. What I want to do logically looks like this - although it doesn't work as it is not valid case statement syntax:
select *
from table t
where t.calc_result_info_key in (case when :product_prompt = 'GAS' then (310, 160, 4000)
                                 else (320, 330, 340, 350, 170, 180, 190, 200, 4010, 4020, 4030, 4040)  end)Is there any way to change filter logic like this?
Edited by: dgouin on Sep 16, 2010 9:02 AM

The good old ugly OR statement.
select *
from table t
where
      t.calc_result_info_key in (310, 160, 4000)
         and
      :product_prompt = 'GAS'
   or
      t.calc_result_info_key in (320, 330, 340, 350, 170, 180, 190, 200, 4010, 4020, 4030, 4040)
   and
      (:product_prompt != 'GAS' or :product_prompt is null)
   )

Similar Messages

  • Difference of 'Specify Fragmentation Content'  and 'where clause Filter ' ?

    What is the difference of ‘Specify Fragmentation Content’ and ‘where clause Filter ‘
    As per my understanding Both looks like limit the data ?

    'Specify Fragmentation Content’ is for Union-ing tables, e.g. one table has data for 2008 while other has 2005-2007, so 'Specify Fragmentation Content’ tells server where to go look for data.
    'Where clause Filter' is for limiting data from the table, e.g. where status = 'Funded'

  • Mutilple Filter Objects - Changing where clause and or

    Is it possible to have a query as below using filter commands.
    (obj1 = 'value11' and obj2 = 'value21')
    or
    (obj1 = 'value12' and obj2 = 'value22')
    or
    The objective is to manipulate the where clause and , or .
    Thanks in Advance
    Bhanu Mohanty

    Hi Bhanu,
    to reach what you want it's necessary to build a virtual characteristic.
    The new characteristic will be populated via coding during runtime of your query. Another possibility (as mentioned before in this forum by Siegfried Szameitat) is to create a new characteristic in your cube that contains field1 and field2 concatenated. With the first scenario, you don’t need a reloading of your cube, with second one this is necessary.
    Hope this helps.
    Bye,
    Roberto

  • How to change where clause in VO query in bean

    Hi experts
    I have to modify vo object query where clause on run time .. is it possible??
    if yes please suggest me,

    as mentioned by Timo, it is very much possible
    see this following link -
    Changing the WHERE clause or VO Query at runtime in Oracle ADF | Techartifact
    Dynamically changing query in view object in Oracle ADF | Techartifact

  • Af:query - change where clause

    Hi,
    In my form I have af:query based on a view.
    also I have a checkbox that indicates to add or remove sql statements from the 'where clause' of the view.
    for example:
    my view query is "select * from employees where employees.kod_emp>0"
    I need that in case the checkbox is checked the view will look like this:
    "select * from employees where employees.kod_emp>0 *and employees.kod_dept = :dept_id*"
    and when the checkbox is unchecked the view will return to the original query.
    how could I implement it using the same af:query component?
    Edited by: 971832 on 02:38 10/12/2012
    Edited by: 971832 on 02:39 10/12/2012

    if i getting you correctly means add setnamedwhereclause based on your condition.
    write customer method in AM
    get your viewobject in Application Module.
    vo.setNamedwhereClause("bindattrubute" , " value" );
    vo.executequery();call this method on valuechangelistner of your check box.

  • Create a view with a changing where clause

    Hi all,
    i'm developing an application with oracle forms i want to create a view in the database with a different where clause in every time , the where clause is determined due to the department id of the current user .
    thanks alot.

    SQL> create view emp_view as select empno, ename, deptno from emp;
    View created.
    SQL> select * from emp_view where deptno = 10;
         EMPNO ENAME          DEPTNO
          7782 CLARK              10
          7839 KING               10
          7934 MILLER             10
    SQL>

  • WHERE Clause performance based on order - ?  Maybe?

    Hello everyone - thanks in advance for the always helpful help. :-)
    I have a query...
    SELECT
      WOH.COMPANY_NUMBER,
      WOH.ACCOUNT_NUMBER,
      COUNT(WOH.WORK_ORDER_NUMBER) AS TROLLS
    FROM
      PENDING_WORK_ORDERS PWO
      INNER JOIN KAN_WORK_ORDER_MASTER_HISTORY WOH
        ON PWO.ACCOUNT_NUMBER = WOH.ACCOUNT_NUMBER
    WHERE
    WOH.OFFICE_ONLY_FLAG <> 'Y'
    AND WOH.WO_STATUS = 'CP'
    AND WOH.SCHEDULE_DATE BETWEEN ('1' || O_CHAR(TO_DATE(SUBSTR(PWO.DATE_ENTERED, 2, 6), 'YYMMDD') - 30 , YYMMDD'))
    AND PWO.DATE_ENTERED
    GROUP BY WOH.COMPANY_NUMBER, WOH.ACCOUNT_NUMBERThe KAN_WORK_ORDER_MASTER_HISTORY file has approx. 10,000,000 records in it. Does the order of the WHERE statement effect performance? This query now takes approx 40 minutes to run - but I was wondering if I reordered the WHERE statement (ie - Bring statements to the top that would cut the results more) - would this work?
    If not - any suggestions to speed this up? There are only a small set of these records that we really need - probably about 1% will actually match - is there any way to narrow down this set before there WHERE search is done? The SCHEDULE_DATE field is stored as a number in the format 1YYMMDD - the dates go all the way back to 2003 but we are only needing the last two months work (1071101 - 1071217).
    Am I making any sense? Sometimes these issues are very hard to explain...
    Thanks again.
    Brett

    so I have to use the TO_DATE and TO_CHAR functions quite a bit - which always seem to slow the query down considerably. There is that to consider that indexes will not get used, unless you try a function based index as also suggested.
    The real problem may be the cardinality is impossible to estimate the number of rows each operation may return, and as the volumes are large the impact will be worse.
    we are only needing the last two months work (1071101 - 1071217).There are three times more possible values between the numbers as there are days between the two dates, and the optimizer bases the most efficient plan using this information.
    SQL> select 1071101 - 1071217 from dual;
    1071101-1071217
               -116
    SQL> select to_date('071101','yymmdd') - to_date('071217','yymmdd') from dual;
    TO_DATE('071101','YYMMDD')-TO_DATE('071217','YYMMDD')
                                                      -46
    this is for a national corporation that i have absolutely no say in how it is formatted or administered....And right now it is going as fast as it has been designed to go. When someone has built and provided you with a farm tractor, you aren't going to be winning any formula 1 or nascar races.

  • A bug? BC4J ViewObject where clause change doesn't affect view contents

    Hi!
    I've found the following interesting behaviour (maybe a bug?) of BC4J ViewObject caching:
    1) make a viewobject with where clause and 1 parameter in it.
    2) set parameter binding to some value
    3) execute query
    4) then change viewobject's where clause, but leave parameter binding intact
    5) execute query again
    6) view object contents haven't changed!
    actually, changing where clause text should make view object requery data from the database instead of using cached rows...
    If to add a call to viewobject.clearCache() before second viewobject.executeQuery(), then everything works fine and view object's contents are changed.
    Does anybody have any ideas about this? Or is this a some kind of a feature, or it is already fixed in a newer version of JDev?
    Thnx!
    PS. JDeveloper version 9.0.3.4 (build 1247).

    delete message

  • Dynamic where clause change

    Hi,
    I have code as below
    Scenario1
    FOR i in (Select .................... from table1 Where id in(select id from Sample_table where status='Submit'))
    Loop
    End loop;
    Scenario2
    FOR i in (Select .................... from table1 Where id in(select id from Sample_table where status='Saved'))
    Loop
    End loop;
    Scenario3
    FOR i in (Select .................... from table1 Where id in(select id from Sample_table where status='Inprogress'))
    Loop
    End loop;Query is same here but only chage is where clause
    Total length of this query is exceeding varchar2 length. so i cant use variable to hold this query and append where clause dynamically.
    Do we have any other method to change where clause dynamically?

    >
    We have around 200 columns to select from multiple tables...Here I gave sample code...
    so its exceeding length
    >
    So 200 columns at 30 bytes per column name is only 6000 bytes. That means the rest of the query is using over 26000 bytes: 260 lines of query if each line was 100 bytes long.
    You need to rethink what you are doing. So far your queries are too big, your row-by-row processing is a terrible way to process data and repeating that process multiple times just aggravates the performance even more.
    I can't imagine there is ANY justification for doing things that way.
    Even if you HAD to do things that way you couldn't exceed the CLOB length so why aren't you using a CLOB variable?
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/openfor_statement.htm
    >
    OPEN-FOR StatementThe OPEN-FOR statement executes the SELECT statement associated with a cursor variable. It allocates database resources to process the statement, identifies the result set (the rows that meet the conditions), and positions the cursor variable before the first row in the result set.
    With the optional USING clause, the OPEN-FOR statement processes a dynamic SELECT statement that returns multiple rows: it associates a cursor variable with the SELECT statement, executes the statement, identifies the result set, positions the cursor before the first row in the result set, and zeroes the rows-processed count kept by %ROWCOUNT.
    dynamic_string
    A string literal, string variable, or string expression that represents any SQL statement. It must be of type CHAR, VARCHAR2, or CLOB.

  • Dimension Mapping in 11g. Can Where clause be used to filter source table?

    Hi,
    Is it possible to use a where clause filter when mapping a dimension to source table in AWM 11g
    My understanding of the user guide is that filters can only be used in cube mapping?
    I am using AWM 11.2.0.1.0A on db 11g R2.
    I presume I could use a database view on the source table to filter down to the records for the dimension, however, I understand this would then prevent me refreshing any cube using this dimension using materialized view refresh?
    Thanks

    Yes, you can apply a where clause on a dimension map, but it is not exposed through AWM. You would need to add an attribute to the XML of the form
    WhereClause='<source table condition>'For example, you could add this to a HierarchyLevelMap.
    <HierarchyLevelMap
      WhereClause="CUSTOMER_DIM.SHIP_TO_ID = 123"
      KeyExpression="CUSTOMER_DIM.SHIP_TO_ID"
      Query="CUSTOMER_DIM">
    </HierarchyLevelMap>Make sure you add it to all relevant levels in a hierarchy. E.g. all levels that share the same source table. This is compatible with MV refresh. You can also map it to a view containing the where clause, and that, too, should work with MV refresh.

  • Where clause in BMM (logical table Source) is not working

    Hello Folks ,
    I felt I ask here before I ask Siebel(oops Oracle!) support, by which I could save significant time NOT restart box multiple times , change log level , upload RPD , making multiple screen shots etc.. etc..
    Here is an example the scenario
    I have a custom field in the activity called the Activity source with two digit abbreviation
    TX – Text message
    LT – Letter
    EM – Email so forth
    The LOV table W_LOV_D has the type as CUST_SRC_ACT
    Whoever implemented analytics they did an alias table for W_LOV_D and did a physical join between W_ACTICITY_F to W_LOV_D through field VAL
    W_ACTICITY_F.X_ACT_SRC--> W_LOV_D.VAL and they did not do a where clause in BMM to retrieve only W_LOV_D.TYPE =’CUST_SRC_ACT’
    So in fact the query pulls TX for CUST_SRC_ACT as well as TX for State abbreviation
    I went ahead and added the where clause filter
    "Siebel Data Warehouse".Catalog.dbo."Dim_W_LOV_D_Acty_Src".TYPE = 'CUST_SRC_ACT'
    I saved the repository and started the server (I was doing offline) spooled the SQL and the results are the same. Looks like the filter is not being applied.
    I did reload the server meta data etc..
    Would anyone knows what is going on with the filter (or what I am doing wrong)?
    Thanks in advance,
    AP

    hi Ap,
    Pull only Dim_W_LOV_D_Acty_Src column into answers and check whether u r able to see CUST_SRC_ACT or not .Of course, you need to check sql query too
    Thanks,
    Saichand.v

  • Dynamic where clause in Database Adapter, or workaround?

    Hello friends,
    Is there any way to change where clause in Database Adapter (DA) dynamically.
    For e.g. i do have Database Adapter with sql statement: select col1,col2 from my_table. Originally i have many parameters which are not mandatory so instead of creating where clause in DA like:
    select col1, col2 from my_table where+
    *((#p_col_1 is not null and #p_col_1=col1) or #p_col_1 is null)*
    and ...
    and  ((#p_col_n is not null and #p_col_n=col_n) or #p_col_n is null)
    i would like to create a where clause dynamically depend on what parameters are not empty or receive where clause as parameter. Is it possible? Are there any others workarounds you can suggest?
    will appreciate any thoughts...

    Thanks Deepa for the links, their where quite helpful. And i must admit this partially answers my question (at least example i provided).
    However - how about if i'd like to use LIKE clauses instead of =, or IN or NOT IN? e.g:
    select col1, col2 from my_table where+
    ((#p_col_1 is not null and #p_col_1 LIKE col1) or #p_col_1 is null)
    and ...
    and ((#p_col_n is not null and col_n IN #p_col_n) or #p_col_n is null)
    Is it possible?
    thanks in advance

  • Urgant :where clause

    How we can use set_block_property built in to change where clause on pre-query trigger .I tried the following but it didn't work:
    set_block_property('DEPT',WHERE_CLAUSE,'DNAME LIKE ''C%''');
    Any help would by appreciated .

    set_block_property('DEPT',DEFAULT_WHERE,'Where DNAME LIKE ''C%''');

  • Query designer removing parts of where clause in VS 2012

    I'm new to reporting services and I'm finding the query designer very frustrating.  First off,  I have read here and
    am having a problem where the tool automatically wipes out parameters I have changed/added in the query designer.  I read this 5 years ago, yet it seems that this problem still exists.  I've tried changing the XML as suggested by some with mixed
    results.  Now I am having a problem when I changed the WHERE clause it keeps disappearing if I try and make any other change.  Does anyone have advice on working with this tool?  Should one keep a running copy of the query and keep pasting it
    back in whenever a change is needed?  Is this behavior not expected?  Is anything different with SSRS 2014?
    Thanks

    Hi billywinter,
    According to your description, parameters are wiping out automatically when you change something in query designer.
    In Reporting Service, if we use where clause to add parameters in query designer, Define Query Parameters will pop-up when running the query. Please refer to screenshot below:
    Regarding the issue, we couldn’t understand it clearly, and we would like to confirm something from you below:
    1. Does parameters disappear in your query? Or when you preview the report, the selected box of parameters doesn’t display?
    2. How about the query in query designer when parameters disappear?
    3. What’s the modification have you performed for where clause? And what’s the result after this modification?
    4. What the query type you are using, MDX query, stored procedure or another query type?
    Please provide more information about the issue then we can understand the issue clearly. If possible, please provide some screenshots about the query in query designer, and the results of parameters before and after changing where clause.
    In addition, we have found a feedback which descripts an issue about overwriting parameter in MDX query designer, and this issue is resolved by design. Is this issue same as yours? Please refer to this feedback:
    MDX Query Designer Overwrites Parameter Queries.
    Best regards,
    Qiuyun Yu

  • Prompted value corrupts SQL WHERE clause - bug?

    Using 10.1.3.4...
    I implemented a simple pivot based request that navigates to a second request when the user drill down on one of the fields. This field is set to "value is prompted" in my second request. (I chose navigate method above drill (dimensions) for a few reasons not really important to this posting, mainly to do with format of requests at different levels)
    All good and the drill down works well, parameters are passed correctly, except then I noticed that totals in my second request doesn't accurately tie back to my first request. After some research I found a very odd reason for this, my WHERE clause is getting corrupted - which almost looks like a bug in OBIEE and were wondering if anybody else has seen this behaviour from OBIEE and know a work around (before I try the Oracle support channels)
    From Answers the request SQL is (I'll highlight the lines getting messed up):
    SET VARIABLE DISABLE_CACHE_HIT = 1;
    SELECT
    BUSINESS_UNIT.Segment saw_0, BUSINESS_UNIT."Business Unit" saw_1, OPPORTUNITY.CLOSEPROBABILITY saw_2, OPPORTUNITY.CLOSEPROBABILITY saw_3, YEAR(OPPORTUNITY.ESTIMATEDCLOSE) saw_4, OPPORTUNITY_ADDON.TCV_IN_USD/1000000 saw_5, OPPORTUNITY_ADDON.WEIGHTED_TCV_IN_USD/1000000 saw_6, CASE OPPORTUNITY.CLOSEPROBABILITY WHEN 100 THEN OPPORTUNITY_ADDON.TCV_IN_USD/1000000 ELSE 0 END saw_7 FROM "Sales"
    WHERE (OPPORTUNITY.STAGE NOT IN ('Lost', 'On Hold')) AND (YEAR(OPPORTUNITY.ESTIMATEDCLOSE) &gt;= YEAR(CURRENT_DATE)) AND
    ((({color:#ff0000}OPPORTUNITY.CLOSEPROBABILITY &gt; 25) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) &lt;= 4)) OR ((OPPORTUNITY.CLOSEPROBABILITY &gt;= 10) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) &gt; 4{color})))
    ORDER BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6, saw_7
    Which results in the following SQL request (from NQQuery.log)... The prompted value (BUSINESS_UNIT.Segment) is added correctly to the WHERE clause, but see how the remainder get's changed:
    SQL Request:
    SET VARIABLE QUERY_SRC_CD='Report',SAW_DASHBOARD='/shared/01 - Financials/_portal/4. Pipeline',SAW_DASHBOARD_PG='Pipeline',SAW_SRC_PATH='/shared/01 - Financials/4. Pipeline/Pipeline - Current - T2',DISABLE_CACHE_HIT = 1;
    SELECT
    BUSINESS_UNIT.Segment saw_0, BUSINESS_UNIT."Business Unit" saw_1, OPPORTUNITY.CLOSEPROBABILITY saw_2, OPPORTUNITY.CLOSEPROBABILITY saw_3, YEAR(OPPORTUNITY.ESTIMATEDCLOSE) saw_4, OPPORTUNITY_ADDON.TCV_IN_USD/1000000 saw_5, OPPORTUNITY_ADDON.WEIGHTED_TCV_IN_USD/1000000 saw_6, CASE OPPORTUNITY.CLOSEPROBABILITY WHEN 100 THEN OPPORTUNITY_ADDON.TCV_IN_USD/1000000 ELSE 0 END saw_7 FROM "Sales"
    WHERE (BUSINESS_UNIT.Segment = 'Enterprise') AND (OPPORTUNITY.STAGE NOT IN ('Lost', 'On Hold')) AND (YEAR(OPPORTUNITY.ESTIMATEDCLOSE) &gt;= YEAR(CURRENT_DATE)) AND
    ((({color:#ff0000}OPPORTUNITY.CLOSEPROBABILITY &gt;= 10) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) &gt; 4)) OR ((OPPORTUNITY.CLOSEPROBABILITY &gt;= 10) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) &gt; 4{color})))
    ORDER BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6, saw_7
    Which definitely explains why my totals do not add up when drilling down. Interestingly, if I run my second request without the prompt from Answers, the SQL request works like a charm:
    SET VARIABLE QUERY_SRC_CD='Report',SAW_SRC_PATH='/shared/01 - Financials/4. Pipeline/Pipeline - Current - T2',DISABLE_CACHE_HIT = 1;
    SELECT BUSINESS_UNIT.Segment saw_0, BUSINESS_UNIT."Business Unit" saw_1, OPPORTUNITY.CLOSEPROBABILITY saw_2, OPPORTUNITY.CLOSEPROBABILITY saw_3, YEAR(OPPORTUNITY.ESTIMATEDCLOSE) saw_4, OPPORTUNITY_ADDON.TCV_IN_USD/1000000 saw_5, OPPORTUNITY_ADDON.WEIGHTED_TCV_IN_USD/1000000 saw_6, CASE OPPORTUNITY.CLOSEPROBABILITY WHEN 100 THEN OPPORTUNITY_ADDON.TCV_IN_USD/1000000 ELSE 0 END saw_7 FROM "Sales"
    WHERE (OPPORTUNITY.STAGE NOT IN ('Lost', 'On Hold')) AND (YEAR(OPPORTUNITY.ESTIMATEDCLOSE) &gt;= YEAR(CURRENT_DATE)) AND
    ((({color:#ff0000}OPPORTUNITY.CLOSEPROBABILITY &gt; 25) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) &lt;= 4)) OR ((OPPORTUNITY.CLOSEPROBABILITY &gt;= 10) AND (TIMESTAMPDIFF(SQL_TSI_MONTH, CURRENT_DATE,OPPORTUNITY.ESTIMATEDCLOSE) &gt; 4{color})))
    ORDER BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6, saw_7
    Anybody had the same problem before?

    Here's the excerpt (it's relative to crashing, but I think it should also address the bug):
    # PRESENTATION SERVER CRASH AFTER UPGRADING TO 10.1.3.4 (Doc ID 756541.1)
    crash when they run the reports containing Pivot Table. This has been a known issue with version ... subsequently upgraded to version
    Doc Type:ALERTModified:2/10/2009

Maybe you are looking for

  • Can you use PC-1066 memory in 2011 Mac Mini?

    I have a Mid-2010 Macbook Pro 15" with the standard 4Gb of PC-1066 and I'm looking into buying the 2011 Mac Mini base model. Now, if I purchase 8Gb of PC-1066 for my MBP, is the Mini compatible with the PC-1066 memory? I know both the MBP and Mini us

  • Using two cursors, one for updating salary values in the emp table

    Using COPIES of the employee and department tables provided by Oracle or using similar taples that provide employee, salary, job and dept in one table and dept number and department name in another table, write the following program. Use the dept tab

  • Mapping one node to many nodes

    How do you map one node in a controller context to many other nodes in another controller context? Here's the situation I'd be using this. I have an Adaptive RFC model from which I created a Custom Controller. I then used the wizard to map to the mod

  • How do I eject a disc fm Mac ?

    How do eject a disc fm mac pro ?

  • Can't import ESP mode Video into iMovie...

    I can't import video recorded in ESP mode into iMovie or Final Cut. Is there some trick to it, or am I kinda screwed?? PLease help me if you can..