Running Query Based on Condition

Hi
I want to run different query based on a condition. I am not able to execute the following query. is this the right way to run different query based on condition?
SELECT * FROM (
CASE WHEN (SELECT COUNT (*) from data1 where ID = 1 AND stype = 'A') > 0 THEN select * from data where ID = 1 AND stype = 'A'
WHEN (SELECT COUNT (*) from data1 where ID = 1 AND stype = 'B') > 0 THEN select * from data where ID = 1 AND stype = 'B'
WHEN (SELECT COUNT (*) from data1 where ID = 1 AND stype = 'C') > 0 THEN select * from data where ID = 1 AND stype = 'C'
END
) as a;
Edited by: user6016744 on 21 Apr, 2011 12:40 AM

This works for us; hope it helps.
CREATE OR REPLACE FUNCTION SCHEMA.GET_STEP_COST (loan_number_in in VARCHAR2, step_code_in in VARCHAR2 default null, ws_in in VARCHAR2 default null )
RETURN VARCHAR2 IS retval  VARCHAR2 (50);
/*passing in loan number and step code you need the cost for, will return the cost*/
BEGIN
    CASE ws_in --depending on workstation in is the table select
    WHEN 'F' THEN
        EXECUTE IMMEDIATE 'SELECT '|| step_code_in ||' FROM CLAIMS_FCL_STEPS WHERE LOAN_NUMBER = '|| loan_number_in ||'' INTO retval;
    WHEN 'R' THEN
       EXECUTE IMMEDIATE 'SELECT '|| step_code_in ||' FROM CLAIMS_RS_STEPS  WHERE LOAN_NUMBER = '|| loan_number_in ||'' INTO retval;
    WHEN 'L' THEN
       EXECUTE IMMEDIATE 'SELECT '|| step_code_in ||' FROM CLAIMS_LM_STEPS  WHERE LOAN_NUMBER = '|| loan_number_in ||'' INTO retval;   
    ELSE
        retval := 0;
    END CASE;
  RETURN retval;
END GET_STEP_COST;
/

Similar Messages

  • Run allocation based on condition matched

    Hi SAP friends,
    I need to run allocation based on condition matched, is it possible with IIF or another statement?
    the logical view is below (syntax is wrong):
    *RUNALLOCATION
    IIF(BAS(ACCOUNT_01)<>0,
    *FACTOR = USING/TOTAL
    *DIM ACCOUNT WHAT = ACCOUNT_52; WHERE=BAS(ACCOUNT_01); Using=BAS(ACCOUNT_01); TOTAL=BAS(ACCOUNT_01)
    *FACTOR = 1
    *DIM ACCOUNT WHAT = ACCOUNT_52; WHERE=ACCOUNT_10)
    *ENDALLOCATION
    thanks a lot.

    Hi Vadim,
    I am somehow getting doubled values, I have read some articles where when and REC can double values, but my case seems to be something different, do you have an idea?
    the code is below:
    *FOR %MONTH_PLUS% = 0,1,2,3,4,5,6,7,8,9,10,11,12
    *XDIM_MEMBERSET RPTCURRENCY     = LC
    *XDIM_MEMBERSET ENTRYTYPE          = INPUT
    *XDIM_MEMBERSET CLIENTSEG           = NA_CLS, GCIPZ
    *XDIM_MEMBERSET CUSTSEG              = C_INP, P_INP
    *XDIM_MEMBERSET ACCIDENTYEAR    = CAY
    *XDIM_MEMBERSET DISTCH                  = BAS(GI_TOTAL),ALL_OTHER
    *XDIM_MEMBERSET LOB                       = BAS(LOB_GI)
    *XDIM_MEMBERSET PARTNER_RU        = NA_PU
    *XDIM_MEMBERSET ZVIEW                   = MV_PROD,MV_REC
    *XDIM_MEMBERSET TIME                      = TMVL(%MONTH_PLUS%,%TIME_SET%)
    *XDIM_MEMBERSET VERSION               = %VERSION_SET%
    *XDIM_MEMBERSET RU                         = %RU_SET%
    *XDIM_MEMBERSET INSTYPE                = DIR_OWN
    *WHEN INSTYPE
    *IS DIR_OWN
    *REC(EXPRESSION=(([ACCOUNT].[IFRS_69011330_01],[VERSION].[A01],[TIME].[TMVL(%MONTH_PLUS%,$LAST_YEAR$)])==0) ? [ACCOUNT].[STAT_LOSS_52]:[ACCOUNT].[IFRS_69011330_10], ACCOUNT=IFRS_69011330_10)
    *ENDWHEN
    *NEXT
    many thanks, tomas.

  • Running query based on other query result

    Hi Again Friends.
    first of all i am very much thankful for members who sent me prompt response and been helping for last 2 days.I am again with query,maybe a lame one.
    I want to run a query based on record return from previous query.FOr instance i have query
    Select sum(marks) from studentMarks,student_id where course_Id=4 and student_Id
    IN
    (Select StudentId from Student where dept_id=3)
    the courseID and studentID are being repeated in the above table
    now I want to show Student Names with the marks Obtained and who belong to dept_id=3,i want to run other query to get Name based on StudentId resutned from previous one.
    Is there anyway to do this in oracle to save result in some resultSe and use it later?
    Thankyou

    Do you mean something like:
    Select sum(marks), S.StudentId, S.StudentName
    from StudentMarks M
    ,      Student          S
    where S.course_Id=4
    and  M.Student_id = S.StudentId
    and S.student_Id
    IN
    (Select StudentId from Student where dept_id=3)
    group by StudentId, StudentName

  • Return query based on condition

    I'm trying to create a report region that returns results based on which table the data is stored. I'm using the type SQL Query(PL/SQL function body returning SQL query). I do a select to the first set of tables if the data is not there then it will do a select on the other set of tables. Each query will work find alone. But one query will not work when I use the condition IF Else return query.
    Does anybody know how I can accomplish this?
    Here is the Query:
    declare
    v_cnt number;
    begin
    select count(*) into v_cnt from image_repo_images im, image_repo_lookup il
    where im.document_id_type = il.lookup_code
    and il.lookup_type = 'DOCUMENT_TYPE'
    and il.lookup_code = 1
    and im.document_id = :P1_FILE_DLN;
    if v_cnt > 0 then
    return 'select distinct il.meaning, im.document_id, im.system_entry_date,im.batch_type,im.document_id_type
    from image_repo_images im, image_repo_lookup il
    where im.document_id = :P1_FILE_DLN
    and im.document_id_type = il.lookup_code
    and il.lookup_type = ''DOCUMENT_TYPE''
    and il.lookup_code = 1;';
    else
    return 'select ''DLN'', dln, null e_date,null bt,null tp from income_tax_return_images where dln = :P1_FILE_DLN';
    end if;
    end;
    Looks rather straight forward to me.
    I get this error:
    report error:
    ORA-20001: Error fetching column value: ORA-01403: no data found
    Any help will be appreciated.

    Does this work for you:
    DECLARE
       v_cnt     NUMBER;
       v_query   VARCHAR2 (4000);
    BEGIN
       SELECT COUNT (*)
         INTO v_cnt
         FROM image_repo_images im, image_repo_lookup il
        WHERE im.document_id_type = il.lookup_code
          AND il.lookup_type = 'DOCUMENT_TYPE'
          AND il.lookup_code = 1
          AND im.document_id = :p1_file_dln;
       IF v_cnt > 0
       THEN
          v_query :=
                v_query
             || 'SELECT DISTINCT il.meaning, im.document_id,'
             || ' im.system_entry_date,im.batch_type,im.document_id_type'
             || ' FROM image_repo_images im, image_repo_lookup il'
             || ' WHERE im.document_id = :P1_FILE_DLN'
             || ' AND im.document_id_type = il.lookup_code'
             || ' AND il.lookup_type = ''DOCUMENT_TYPE'''
             || ' AND il.lookup_code = 1';
       ELSE
          v_query :=
                v_query
             || 'SELECT ''DLN'', dln, null e_date,null bt,null tp '
             || ' FROM income_tax_return_images WHERE dln = :P1_FILE_DLN';
       END IF;
       RETURN v_query;
    END;I think you have a semicolon too much at "...il.lookup_code = 1;"
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Manually execute report query based on condition

    Hi,
    I have 2 queries defined in report as follows:
    Q1) select ename,sal from emp where empno = :emp_no;
    Q1) select ename,sal from emp;
    Based on a specific condition I want to switch between the above 2 queries , based on which report ouput will be generated.
    Example:
    IF <condition is true >
    THEN
    Execute Q1;
    ELSE
    Execute Q2;
    END IF;
    How to do this?
    Thanks

    Also, you can use Ref Cursor query, especially for complicated conditions like :
    IF :FROM_NO IS NULL AND :TO_NO IS NULL THEN
    open temp_CHARACT for SELECT ACCT_CODE,
    ACCT_NAME,ACCT_LEVEL,GROUP_CODE,MAIN_ACCT,OPENING_BALANCE
    FROM CHARACT
    ORDER BY ACCT_CODE;     
    ELSIF :TO_NO IS NULL AND :FROM_NO IS NOT NULL THEN
    open temp_CHARACT for select ACCT_CODE,
    ACCT_NAME,ACCT_LEVEL,GROUP_CODE,MAIN_ACCT,OPENING_BALANCE
    FROM CHARACT
    WHERE ACCT_CODE=:FROM_NO
    ORDER BY ACCT_CODE;     
    ELSIF :TO_NO IS NOT NULL AND :FROM_NO IS NOT NULL THEN
              open temp_CHARACT for select ACCT_CODE, ACCT_NAME,ACCT_LEVEL,GROUP_CODE,MAIN_ACCT,OPENING_BALANCE
              FROM CHARACT
              WHERE ACCT_CODE BETWEEN :FROM_NO AND :TO_NO
              ORDER BY ACCT_CODE;               
    ELSIF :TO_NO IS NOT NULL AND :FROM_NO IS NULL THEN
    open temp_CHARACT for select ACCT_CODE, ACCT_NAME,ACCT_LEVEL,GROUP_CODE,MAIN_ACCT,OPENING_BALANCE
    FROM CHARACT
    WHERE ACCT_CODE<=:TO_NO
    ORDER BY ACCT_CODE;     
    END IF;
    Regards
    Mostafa

  • Run query based on parameter

    Hi,
    I have a report where i'm selecting values based on parameter entered by user. There are only 2 options e.g A or B.
    If A then select *
    where name = A
    or if B then select *
    where name != A basically select everything apart from A.
    Can anyone please tell me how to do this. Thanks.

    There are many ways to do this .
    easy way that i use.
    in the "where clause" of sql query statement
    SELECT decode(SUBSTR(TO_CHAR(FIELD_NAME),1,3),'EFT','IND','USA')
    FROM TABLE
    WHERE decode(SUBSTR(TO_CHAR(FIELD_NAME),1,3),'EFT','IND','USA')=
    NVL(:P_SOURCE,decode(SUBSTR(TO_CHAR(FIELD_NAME),1,3),'EFT','IND','USA')
    Then you have to add these'IND and 'USA' in parameter form( drop down list)
    note: use only required functions.

  • Need different rows from single query based on condition

    Hi,
    I have a table with 100 rows that holds employees and their roles.
    I need to write a SQL(not a PL/SQL block) as below
    1. When employee with role 'VP' logs in, the query should return all the 100 rows.
    2. When employee with role 'MGR' logs in, the query should return only those rows whose MGR is the logged in employee.
    3. When employee with role 'SALE_EXEC' logs in, it should return single rows corresponding to this SALE_EXEC.
    My requirement here is to get these outputs from a single query.
    Can anyone please help me with this.
    Thanks,
    Vivek.

    use vpd
    New Policy Groups
    When adding the policy to a table, view, or synonym, you can use the DBMS_RLS.ADD_GROUPED_POLICY interface to specify the group to which the policy belongs. To specify which policies will be effective, you add a driving context using the DBMS_RLS.ADD_POLICY_CONTEXT interface. If the driving context returns an unknown policy group, then an error is returned.
    If the driving context is not defined, then all policies are executed. Likewise, if the driving context is NULL, then policies from all policy groups are enforced. In this way, an application accessing the data cannot bypass the security setup module (which sets up application context) to avoid any applicable policies.
    You can apply multiple driving contexts to the same table, view, or synonym, and each of them will be processed individually. In this way, you can configure multiple active sets of policies to be enforced.
    Consider, for example, a hosting company that hosts Benefits and Financial applications, which share some database objects. Both applications are striped for hosting using a SUBSCRIBER policy in the SYS_DEFAULT policy group. Data access is partitioned first by subscriber ID, then by whether the user is accessing the Benefits or Financial applications (determined by a driving context). Suppose that Company A, which uses the hosting services, wants to apply a custom policy which relates only to its own data access. You could add an additional driving context (such as COMPANY A SPECIAL) to ensure that the additional, special policy group is applied for data access for Company A only. You would not apply this under the SUBSCRIBER policy, because the policy relates only to Company A, and it is more efficient to segregate the basic hosting policy from other policies.
    How to Implement Policy Groups
    To create policy groups, the administrator must do two things:
    Set up a driving context to identify the effective policy group.
    Add policies to policy groups as required.
    The following example shows how to perform these tasks.
    Note:
    You need to set up the following data structures for the examples in this section to work:
    DROP USER finance CASCADE;
    CREATE USER finance IDENTIFIED BY welcome2;
    GRANT RESOURCE TO apps;
    DROP TABLE apps.benefit;
    CREATE TABLE apps.benefit (c NUMBER);
    Step 1: Set Up a Driving Context
    Begin by creating a namespace for the driving context. For example:
    CREATE CONTEXT appsctx USING apps.apps_security_init;
    Create the package that administers the driving context. For example:
    CREATE OR REPLACE PACKAGE apps.apps_security_init IS
    PROCEDURE setctx (policy_group VARCHAR2);
    END;
    CREATE OR REPLACE PACKAGE BODY apps.apps_security_init AS
    PROCEDURE setctx ( policy_group varchar2 ) IS
    BEGIN
    REM Do some checking to determine the current application.
    REM You can check the proxy if using the proxy authentication feature.
    REM Then set the context to indicate the current application.
    DBMS_SESSION.SET_CONTEXT('APPSCTX','ACTIVE_APPS', policy_group);
    END;
    END;
    Define the driving context for the table APPS.BENEFIT.
    BEGIN
    DBMS_RLS.ADD_POLICY_CONTEXT('apps','benefit','APPSCTX','ACTIVE_APPS');
    END;
    Step 2: Add a Policy to the Default Policy Group.
    Create a security function to return a predicate to divide the data by company.
    CREATE OR REPLACE FUNCTION by_company (sch varchar2, tab varchar2)
    RETURN VARCHAR2 AS
    BEGIN
    RETURN 'COMPANY = SYS_CONTEXT(''ID'',''MY_COMPANY'')';
    END;
    Because policies in SYS_DEFAULT are always executed (except for SYS, or users with the EXEMPT ACCESS POLICY system privilege), this security policy (named SECURITY_BY_COMPANY), will always be enforced regardless of the application running. This achieves the universal security requirement on the table: namely, that each company should see its own data regardless of the application that is running. The function APPS.APPS_SECURITY_INIT.BY_COMPANY returns the predicate to make sure that users can only see data related to their own company:
    BEGIN
    DBMS_RLS.ADD_GROUPED_POLICY('apps','benefit','SYS_DEFAULT',
    'security_by_company',
    'apps','by_company');
    END;
    Step 3: Add a Policy to the HR Policy Group
    First, create the HR group:
    CREATE OR REPLACE FUNCTION hr.security_policy
    RETURN VARCHAR2
    AS
    BEGIN
    RETURN 'SYS_CONTEXT(''ID'',''TITLE'') = ''MANAGER'' ';
    END;
    The following creates the policy group and adds a policy named HR_SECURITY to the HR policy group. The function HR.SECURITY_POLICY returns the predicate to enforce security on the APPS.BENEFIT table:
    BEGIN
    DBMS_RLS.CREATE_POLICY_GROUP('apps','benefit','HR');
    DBMS_RLS.ADD_GROUPED_POLICY('apps','benefit','HR',
    'hr_security','hr','security_policy');
    END;
    Step 4: Add a Policy to the FINANCE Policy Group
    Create the FINANCE policy:
    CREATE OR REPLACE FUNCTION finance.security_policy
    RETURN VARCHAR2
    AS
    BEGIN
    RETURN ('SYS_CONTEXT(''ID'',''DEPT'') = ''FINANCE'' ');
    END;
    Create a policy group named FINANCE and add the FINANCE policy to the FINANCE group:
    BEGIN
    DBMS_RLS.CREATE_POLICY_GROUP('apps','benefit','FINANCE');
    DBMS_RLS.ADD_GROUPED_POLICY('apps','benefit','FINANCE',
    'finance_security','finance', 'security_policy');
    END;
    As a result, when the database is accessed, the application initializes the driving context after authentication. For example, with the HR application:
    execute apps.security_init.setctx('HR');
    Validating the Application Used to Connect to the Database
    The package implementing the driving context must correctly validate the application that is being used to connect to the database. Although the database always checks the call stack to ensure that the package implementing the driving context sets context attributes, inadequate validation can still occur within the package.
    For example, in applications where database users or enterprise users are known to the database, the user needs the EXECUTE privilege on the package that sets the driving context. Consider a user who knows that:
    The BENEFITS application allows more liberal access than the HR application
    The setctx procedure (which sets the correct policy group within the driving context) does not perform any validation to determine which application is actually connecting. That is, the procedure does not check either the IP address of the incoming connection (for a three-tier system) or the proxy_user attribute of the user session.
    Such a user could pass to the driving context package an argument setting the context to the more liberal BENEFITS policy group, and then access the HR application instead. Because the setctx does no further validation of the application, this user bypasses the normally more restrictive HR security policy.
    By contrast, if you implement proxy authentication with VPD, then you can determine the identity of the middle tier (and the application) that is actually connecting to the database on behalf of a user. In this way, the correct policy will be applied for each application to mediate data access.
    For example, a developer using the proxy authentication feature could determine that the application (the middle tier) connecting to the database is HRAPPSERVER. The package that implements the driving context can thus verify whether the proxy_user in the user session is HRAPPSERVER. If so, then it can set the driving context to use the HR policy group. If proxy_user is not HRAPPSERVER, then it can disallow access.
    In this case, when the following query is executed
    SELECT * FROM APPS.BENEFIT;
    Oracle Database picks up policies from the default policy group (SYS_DEFAULT) and active namespace HR. The query is internally rewritten as follows:
    SELECT * FROM APPS.BENEFIT WHERE COMPANY = SYS_CONTEXT('ID','MY_COMPANY') and SYS_CONTEXT('ID','TITLE') = 'MANAGER';
    How to Add a Policy to a Table, View, or Synonym
    The DBMS_RLS package enables you to administer security policies by using its procedures for adding, enabling, refreshing, or dropping policies, policy groups, or application contexts. You need to specify the table, view, or synonym to which you are adding a policy, as well as the data pertinent to that policy, such as the policy name. Such data also includes names for the policy group and the function implementing the policy. You can also specify the types of statements the policy controls (SELECT, INSERT, UPDATE, DELETE, CREATE INDEX, or ALTER INDEX).
    for more you can refer to
    http://download-west.oracle.com/docs/cd/B19306_01/network.102/b14266/apdvcntx.htm

  • Query based on Condition

    Hi,
    I have a select list based on the select list i need to generate the report
    if businees_unit = 'a'
    select emp.name from employess_dep1
    if business_unit = 'b'
    select emp.name from employess_dep2
    end if
    please help me to correct the above
    Thanks
    Sudhir

    Like..?
    select emp.name from employess_dep1
    where :businees_unit = 'a'
    union all
    select emp.name from employess_dep2
    where :business_unit = 'b'                                                                                                                                                                                                                                                                                                                               

  • Constructing a Query based on condition

    Dear all,
    i have a table attendance, it have two types of records, 1 is PLANNED 2 is RELEASED.
    Dept_id *1* has two child sections. *2* and *3*.
    if the Data entry operator from Dept_id=1 is logon, he could see PLANNED & RELEASED (BOTH) attendance from Dept_id =1
    but
    he could only see those entries from his child departments which are RELEASED.
    How could we construct such a query?
    Regards

    Thank you dear,
    i have a table for Department
    create table departments (dept_id number primary key,
    dept_type char(1), ---- 1 for Department and 2 for Section (one department could have sections)
    dname varchar2(60),
    parent_dept number references departments(dept_id),
    location varchar2(60));
    create table attendance_header (att_date date,
    att_kind char(1), ------------1 for OFFICIAL and 2 for OVERTIME
    dept_sec_id number references departments(dept_id),
    status char(1), -------PLANNED or RELEASED
    is_holiday char(1),
    is_weekend char(1));
    alter table attendance_header add constraint pk_att_header primary key(att_date,att_kind,dept_sec_id);
    create table attendance_details (emp_id varchar2(4) references emp(emp_id),
    att_date date,
    att_kind char(1),
    dept_sec_id number references departments(dept_id),
    att_type_no varchar2(2) references attendance_types(att_type_no), --- late , absent etc
    duration number, ------ how much time he late
    transaction_invoker varchar2(50));
    these are the tables
    NOW, suppose we take 3 departments 1,2,3 . 1 is the head Department of 2 &3 sections.
    every section or department has its own manager.
    the department 1 manager could see the data of its own departments both PLANNED & RELAESED.
    BUT
    for the sections 2 and 3, HE (the department 1 manager) could see only the RELEASED Data.
    i want a single query which is issued by the department 1 manager for this purpose.
    thanks and regards.
    Edited by: Muhammad on Mar 31, 2010 1:19 AM

  • Select Query Based on date condition

    Hi ,
    Is it Possible.
    i want to run select query based on date condition.
    Eg...
    if the date between 01-jan-01 and 01-jan-05 then
    select * from table1;
    if the date between 02-jan-05 and 01-jan-08 then
    select * from table2;
    Becaz i have data in 2 diffrent tables , based on the date condition i wnt to run the select statement to diffrent tables.
    i dont want plsql here Just SQL needed.
    thanks,
    -R
    Edited by: infant_raj on May 5, 2009 11:48 PM

    Helo Kanish,
    this is not the one i was asking..
    wht i mean was .
    i use bind variable to get date while running the select statement , once i get the date then i want to choose any one of the table to run select query.
    EG..
    select col1,col2 from table1 where date between only if 01-jan-01 and 01-jan-05;
    select col1,col2 from table2 where date between only if 02-jan-05 and 01-jan-08;
    Run any one of the two . not all
    thanks,
    _raj                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Query performance based on condition value

    Hi,
    I have a simple query which is actually on a view dwdb_dba.actl_partinfo_cust. Please see query bellow
    select * from dwdb_dba.actl_partinfo_cust WHERE insertdatetime=(select max(insertdatetime)
    from dwdb_dba.actl_partinfo_cust Where system_source='UTS') AND SUPPLIERID='CG1' and Custdevice in ('BT-M2789-C')This query is taking very very long time to return (around 30 records) but if i u
    Here if i change the condition "AND SUPPLIERID='CG1'" to "AND SUPPLIERID='DUMMY'", it returns within 3 seconds. Execution plan is same for both then why one query taking too much time and other returning so fast and how can i tune the query against the condition AND SUPPLIERID='CG1' so that it can also return within 3 seconds.
    I actualy dont understand the behaviour
    PLAN_TABLE_OUTPUT
    Plan hash value: 3622663398
    | Id  | Operation                       | Name                        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                |                             |    10 | 42790 |   152K  (6)| 00:00:59 |
    |*  1 |  VIEW                           | ACTL_PARTINFO_CUST          |    10 | 42790 | 59972   (4)| 00:00:23 |
    |   2 |   UNION-ALL                     |                             |       |       |            |       |
    |*  3 |    TABLE ACCESS BY INDEX ROWID  | ACTL_PARTINFO_CUST_UTS      |     9 |  3429 | 59968   (4)| 00:00:23 |
    |*  4 |     INDEX RANGE SCAN            | ACTL_PART_CUST_UTS_IDX3     |   420K|       |  1462  (11)| 00:00:01 |
    |*  5 |    TABLE ACCESS BY INDEX ROWID  | ACTL_PARTINFO_CUST_PROMIS_4 |     1 |   311 |     4   (0)| 00:00:01 |
    |*  6 |     INDEX RANGE SCAN            | ACTL_PARTINFO_CUST_4_IDX1   |     1 |       |     3   (0)| 00:00:01 |
    |   7 |   SORT AGGREGATE                |                             |     1 |    14 |            |       |
    |   8 |    VIEW                         | ACTL_PARTINFO_CUST          |  1363K|    18M| 92040   (8)| 00:00:36 |
    |   9 |     UNION-ALL                   |                             |       |       |            |       |
    |* 10 |      TABLE ACCESS BY INDEX ROWID| ACTL_PARTINFO_CUST_UTS      |  1363K|    33M| 92036   (8)| 00:00:36 |
    |* 11 |       INDEX RANGE SCAN          | ACTL_PART_CUST_UTS_IDX1     |  1481K|       |  5528  (10)| 00:00:03 |
    |* 12 |      TABLE ACCESS BY INDEX ROWID| ACTL_PARTINFO_CUST_PROMIS_4 |     1 |    15 |     4   (0)| 00:00:01 |
    |* 13 |       INDEX RANGE SCAN          | ACTL_PARTINFO_CUST_4_IDX1   |     1 |       |     3   (0)| 00:00:01 |
    ---------------------------------------------------------------------------------------------------------------Thanks

    Salman Qureshi wrote:
    This query is taking very very long time to return (around 30 records) but if i u
    Here if i change the condition "AND SUPPLIERID='CG1'" to "AND SUPPLIERID='DUMMY'", it returns within 3 seconds.
    My developer has changed the code of the view which was involved and not it is working fine but still i m curious to know that what could be the reason of this. Same execution plan but only condition value is different. One value returns some rows but returns within few seconds and other condition also returns a few rows but may hours.Salman,
    A bit more details would help diagnose the root cause.
    If you are still interested in diagnosing the root cause, you may want to provide complete EXPLAIN PLAN output, along with predicate section. If you are on 10g, you may want to provide the output of DBMS_XPLAN.DISPLAY_CURSOR which will show the actual plan used along with actual number of records generated by each step in the execution plan.
    It is possible that SUPPLIERID column data is skewed so that there are less records in table for the value 'DUMMY' but much more number of records for the value 'CG1'. This predicate combined with the other predicate on CUSTDEVICE column may have been resulting in similar number of rows the final query returns.
    It is possible that the predicate on CUSTDEVICE is being applied at different stage in the plan than the predicate on SUPPLIERID column.
    Edited by: user503699 on Aug 3, 2010 3:11 PM

  • POP UP  inside a report: conditional query based on other col el. values

    HI to all,
    i've a really simple question: is there a way inside a pop up in a report, to refer to other columns value (of the same row)?
    I'm giving my example:
    i've a table called CNT_VAL_SEG_DEMO
    id
    des
    value
    value have to be a pop up LOV, query based:
    the pseudo sql code is this:
    SELECT DISTINCT VALUE V1 , VALUE V2 FROM CNT_VAL_SEG_DEMO WHERE
    des=<pseudo code>#DES#<pseudo code>.
    What should i use instead of #DES#
    Hope that is clear enough
    thanx a lot

    Hi,
    i think i've found the solution on htmldb studio.
    Doesn't matter.
    However for pointing who's reading
    to the right direction:
    http://htmldb.oracle.com/pls/otn/f?p=18326:54:3063779097888583::::P54_ID:1282
    Tips and tricks: Simulating a correlated sub report in Lov
    Thanx a lot
    Message was edited by:
    Marcello Nocito

  • Query based taxonomy from scratch gives NoSuchMethodError...

    I'm trying to create a query based taxonomy following the instuctions specified in the help docs: KM Platform -> Admin Guide -> Content Mgmt -> Taxonomies and Classification -> Creating a QBT -> from scratch. I created an index on a newly created (hence empty) folder in the 'documents' repository. So, essentially, the data source points to that folder. Also, I selected 'TREX Classification' on the 'Service' drop-down while creating the index. I left the crwler profile as blank. Then I went on to create a new 'Query Based Taxonomy'. I was able to create it alright, but as soon as I click on it to add folder and the such, I get this error:
    java.lang.NoSuchMethodError
         at com.sapportals.wcm.repository.manager.taxonomy.TaxonomyNamespaceManager.getDocumentTaxRMRids(TaxonomyNamespaceManager.java:1876)
         at com.sapportals.wcm.repository.manager.taxonomy.TaxonomyNamespaceManager.getTaxonomyClassResources(TaxonomyNamespaceManager.java:1831)
         at com.sapportals.wcm.repository.manager.taxonomy.TaxonomyNamespaceManager.addChildDocuments(TaxonomyNamespaceManager.java:1942)
         at com.sapportals.wcm.repository.manager.taxonomy.TaxonomyNamespaceManager.getChildren(TaxonomyNamespaceManager.java:368)
         at com.sapportals.wcm.repository.CollectionImpl.internalGetChildren(CollectionImpl.java:966)
         at com.sapportals.wcm.repository.CollectionImpl.getChildren(CollectionImpl.java:179)
    Any help in solving this is highly apprecaited.
    We run EP6 SP2.
    I did NOT create a 'crawler profile' for this set up.
    thanks,
    Biju.

    Hi Biju,
    re. your NW'04 SP stack 4 migration intention:
    NW'04 is still in ramp-up (SP stack 4 is the current shipment bundle of it) so at the current point in time, only participating ramp-up customers can use it.
    A migration from EP6.0 SP2 to NW'04 will be possible (but not during the ramp-up phase).
    From a Knowledge Management & Collaboration perspective, we will port most of the NW'04 SP stack 4 functions to EP6.0 SP2 as well. These functions will be shipped as EP6.0 SP2 Patch 5 (planned shipment date beginning of Q4 / 2004) so for mid-term, you can also plan to stay on EP6.0 SP2 if you have no other pressing reasons for going to NW'04 (e.g. enhanced Web AS functions).
    This feature porting from NW -> EP6.0 SP2 is an 'only-once' action, however, and NetWeaver will be the release for new features in the future.
    Regards,
    Joerg

  • Include Button that executes PL/SQL procedure to SQL query based region

    I would like to add two columns to a SQL query region.
    These columns would not be sourced from the query, but rather would be used to execute a PL/SQL procedure.
    For example, I would like to have a manager approve or deny adding an additional employee to the department.
    There would be one button for APPROVE. And, one button for DENY.
    The PL/SQL procedure would execute to perform the required DML based upon the selected action (either APPROVE or DENY).
    A sample output would look like this:
    <APPROVE>, <DENY>, John Doe, Accountant
    <APPROVE>, <DENY>, Jane Doe, Accountant
    Is there any way to add a button to a SQL Query based report region where that button executes a stored proc? If so, what is the basic process for doing this?
    Thanks!
    -Reid

    Is there any way to add a button to a SQL Query based report region where that button executes a stored proc? If so, what is the basic process for doing this?Conditional page item? You can associate processes with buttons on a page

  • How to give color to the display of keyfigure based on condition using exception.

    Dear Friends.
       I am trying to color "BAD3" in exception based on condition but my problem is in exception I can have only formula variable to compare the value, How to assign a value to formula variable in BEx Query designer.
    What I am trying to do is :
       in Query designer :
       I have PO Quantity and Delivered Quantity. 
      if PO Qnantity > Delivered Quantity
        then Delivered Quantity field should be colored as "BAD3" in exception.
    but here proble is in exception
      I have alert level , operator, and  value fields for Delivered Quantity keyfigure ( Under definition tab - Exception is defined on = Delivered Quantity ).
    but for value field I dont have PO Quantity for that I have to supply one formula variable,
    When I created a forumula  and did this way
    FV_PO_QUANTITY = PO_QUANTITY formula editor throws errors. I dont understand How to assign a value of key figure to formula variable and use it in EXceptions.
    Please help me How I can solve my problem
    I will greatly appreciate your any help.
    Thanking you
    Regards
    Naim

    Thank you so much for your replies,
      I did following way and it helped me to solve my issues.
      I created one formula and under formula I use boolean < funtion to compare the values.
    like following way.
    ( 'PO Quantity' > 'Delivered Quantity' ) * ( FV_PO_QNT + PO_QUANTITY')
    here fv_po_qnt is formula variable I supply that variable to exception and since I have the value in it.. it compares with Delievered Quantity value and colored the perticular cell.
    Thanks again for your replies
    Regards
    Naim

Maybe you are looking for

  • How to set a default value in a dropdownlistbox

    Hi, In CRM 2007 WEBUII have created a dropdownlistbox (ddlb)  filled with currency codes. Now I want the default value of the ddlb to be the currency of the country of the loggedin user, ie : 'EUR' Anyone an creative idea how I can achieve this ? In

  • Error: package jxl does not exist

    I've tried everything on this thread from 2007 how to import a jxl package? and I still get the error: package jxl does not exist. I've: 1)added the the excelapi subdirectory that contains the jar file to the system class path, then I tried explicitl

  • Do they still sell the 2nd generation ipod nanos ?

    I was just wondering whether or not they still sell the 2nd generation ipod nanos. i live in Canada and ive been wanting a red ipod nano for ages...and my silver one is now starting to skip. i might as well get a new one seeing as my silver one has b

  • Problem opening BEx Analyzer Workbook (saved in Excel 2007) in Excel 2003!!

    Dear all: I know there are threads about this issue and numerous support tickets have been provided, but we still can't get any Excel 2007 Query to be opened by Excel 2003. I have tried to save Excel 2007 BEx Analyzer Query into 97-2003 XLS format. B

  • OAS 4.0.8.1 JServlet: Extra path info not implemented?

    Didn't Oracle implement extra path info for servlets? According to the Java Servlets spec it should be possible to invoke a servlet with a URL like http://host/servlets/MyServlet/index.html where /index.html would be accessible through the getPathInf