How to create VO with multiple dynamic where clauses on select with UNION?

I am trying to implement the View Object for the UNION query that looks like this:
     select a,b,c...
          from t1,t2,...
          where dynamic_where_clause1     
     union all
     select a,b,c,...
          from t11,t12, ...
          where dynamic_where_clause2
There are up to 60 input parameters that are used to generate dynamic where clauses. They are actually created by calling PL SQL function.
So far, I was not able to assign both where clauses to the view object. Is there a workable solution for this problem, besides resorting to programmatic View Object?
I understand that recommended way with UNIONs is to wrap both queries into a parent select:
select * from (
     select a,b,c...
          from t1,t2,...
          where ... -- table relationship joints
     union all
     select a,b,c,...
          from t11,t12, ...
          where ... -- table relationship joints
) QRSLT
     where dynamic_where_clause
Unfortunately this approach doesn't work here, since individual selects are producing unmanageable amount of data and resulting query takes forever to complete.

I afraid I would not have any real benefits from using VO if I replace the entire query with every request. Actually, the performance may suffer.
I solved the problem by creating a POJO Data Control and invoking the custom select query from java. Not sure if it is the best approach to the problem, but implementation time is limited and it works.
Actually, this is not the first time I see the need to implement VO with complicated SQL like select with unions and dynamic pieces. It would be nice to find a solution and not resort to workarounds.
Edited by: viksicom on Aug 2, 2012 8:48 AM

Similar Messages

  • Dynamic WHERE clause in SELECT statement

    Hi,
    I need to extract (SELECT) all the products in different salesorganizations. Since a product can be available in more than 1 salesorg I have created several properties in the PRODUCT dimension - 1 for each salesorganization (naming: Sxxxx where xxxx is the salesorganization number).
    Since I need to prefix the salesorganization property with an "S" I have created a property on the SALESORG dimension called SALESORG.
    Therefore I need to create a dynamic WHERE clause in the SELECT statement. Currently my script is:
    *SELECT(%SORG%, "[SALESORG]",SALESORG, [ID]=%SALESORG_SET%)
    *SELECT(%PROD%, "[ID]",PRODUCT, [%SORG%]="X")
    My first SELECT find the Sxxx (equal to the property I need in the PRODUCT dimension). My second SELECT uses the variable in the first SELCT statement to use the correct property for the WHERE clause.
    Unfortunately the code is not validated - any suggestions?
    /Lars

    Hi Lars,
    If you run it from a DM package without validating it, does it still work? I would bet it does.
    If this is the case I would open a message with SAP (it would be an enhancement request). Until they fix the validation code, you would just have to live with the script not validating.
    Cheers,
    Ethan

  • Dynamic where clause in select query

    Hi
    I'm trying for a dynamic query and in the dynamic where clause i'm checking a field for constant.....for instance if i wanna to use WERKS EQ '0478' how to declare it in dync where clause. i tried for the following:
    SELECT  (TAB_FIELD) INTO TABLE DITAB UP TO 10 ROWS FROM (TAB_NAME) WHERE (CONDI).
    heree CONDI = 'werks eq 0287'   . in this case the query fails as the werks shud be equal to '0287' and not just 0287. How to handle this? i tried for the following
    CONDI = 'werks eq " '0287' " ' but no luck as it is not a valid stmt as i knew.

    hi prabhu,
    this is how u select dynamically...
    DATA: COND(72) TYPE C,
    ITAB LIKE TABLE OF COND.
    PARAMETERS: CITY1(10) TYPE C, CITY2(10) TYPE C.
    DATA WA TYPE SPFLI-CITYFROM.
    CONCATENATE 'CITYFROM = ''' CITY1 '''' INTO COND.
    APPEND COND TO ITAB.
    CONCATENATE 'OR CITYFROM = ''' CITY2 '''' INTO COND.
    APPEND COND TO ITAB.
    CONCATENATE 'OR CITYFROM = ''' 'BERLIN' '''' INTO COND.
    APPEND COND TO ITAB.
    LOOP AT ITAB INTO COND.
    WRITE COND.
    ENDLOOP.
    SKIP.
    SELECT CITYFROM
    INTO WA
    FROM SPFLI
    WHERE (ITAB).
    WRITE / WA.
    ENDSELECT.
    regards,
    sohi

  • Pagination after executequery with a dynamic where clause

    Hi all,
    I have a problem with pagination after setting a where clause dynamically and performing an executequery in ViewObjectImpl.java.
    As a result of this, the amount of records are decreased returned by the viewobject, however the pagination is not changed. It still reflects the previous amount. It changes only if you have selected the last range of the changed recordset
    Does anybody know how to get the pagination to refect the correct amount of the updated recordset of the viewobject?
    Jdeveloper version 10.1.3.4 / Jheadstart 10.1.3.3.81
    Thanks in advance, Erwin

    Hi,
    I would not add this to the VO query. Instead I would create a View Criteria that uses a bind variable. Then in the Application Module Data Model, you select the VO instance and choose edit (button on top) to permanently associate the view criteria)
    Advantages of this approach
    - The VO definition can be used elsewhere without the restriction
    - the bind variable is not mandatory and yu can set it such that if no value is provided a full query is executed
    Frank

  • Using bind variable in dynamic where clause and concatenate with query

    Hi,
    In my procedure i am framing where clause dynamically with bind variable,When i am concatenate this with my sql query for REF CURSOR i got sql command not properly ended exception.
    Is it possible to pass values to the bind variable through the dynamic variable/value?
    Please advise
    Thanks in advance
    Siva
    IF in_applicationId IS NOT NULL THEN
              optional_where := optional_where || ' AND a.APPLICATION_ID like '||':e%';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'||',in_queue_id'||',in_applicationId';
         END IF;
    My query is like this
    open Out_Main FOR SelectQuery USING optional_using

    Thanks for reply,
    In my procedure, i suppose to frame the where clause with bind dynamically according to the input parameters. so that i am framing the values of the bind variables also dynamically like this,
    Please advise...
    IF in_assignedAppFlag IS NOT NULL THEN
              IF in_assignedAppFlag = 'Y' THEN
                   optional_where := optional_where || ' AND b.ASSIGNED_TO = :b' ;
              optional_using := ' in_appFuncGroup'||',in_currentUserID';          
              ELSe
                   IF in_isSupervisor = 0 THEN
                        optional_where := optional_where || ' AND (b.ASSIGNED_TO = :b'||' OR b.ASSIGNED_TO = ''-1'' OR b.ASSIGNED_TO IS NULL)';
              optional_using := ' in_appFuncGroup'||',in_currentUserID';
                   END IF;
              END IF;
         ELSE
              IF in_isSupervisor = 0 THEN
                   optional_where := optional_where || ' AND (b.ASSIGNED_TO = :b'||' OR b.ASSIGNED_TO = ''-1'' OR b.ASSIGNED_TO IS NULL)';
                   optional_using := ' in_appFuncGroup'||',in_currentUserID';
              END IF;
         END IF;
         IF in_appFuncGroup IS NOT NULL THEN
              optional_where := optional_where || ' AND e.APP_FUNC_GROUP= :c';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup';
         END IF;
         IF in_queue_id IS NOT NULL THEN
              optional_where := optional_where || ' AND b.QUEUE_ID = :d';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'||',in_queue_id';
         END IF;
         IF in_applicationId IS NOT NULL THEN
              optional_where := optional_where || ' AND a.APPLICATION_ID like '||':e%';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'||',in_queue_id'||',in_applicationId';
         END IF;
         IF in_sourceCode IS NOT NULL THEN
              optional_where := optional_where || ' AND e.APP_SOURCE_CODE like '||':f%';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
              ||',in_queue_id'||',in_applicationId'||',in_sourceCode';
         END IF;
         IF in_logo IS NOT NULL THEN
              optional_where := optional_where || ' AND appProds.PRODUCT_TYPE like '||':g%';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
              ||',in_queue_id'||',in_applicationId'||',in_sourceCode'||',in_logo';
         END IF;
         IF in_firstName IS NOT NULL THEN
              optional_where := optional_where || ' AND upper(a.FIRST_NAME) like upper(:h%)';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
              ||',in_queue_id'||',in_applicationId'||',in_sourceCode'||',in_logo'||',in_firstName';
         END IF;
         IF in_surName IS NOT NULL THEN
              optional_where := optional_where || ' AND upper(a.SURNAME) like upper(:i%)';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
              ||',in_queue_id'||',in_applicationId'||',in_sourceCode'||',in_logo'||',in_firstName'||',in_surName';
         END IF;
         IF in_retreival_id IS NOT NULL THEN
              optional_where := optional_where || ' AND e.RETREIVAL_ID like :j%';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
              ||',in_queue_id'||',in_applicationId'||',in_sourceCode'||',in_logo'||',in_firstName'||',in_surName'||',in_retreival_id';
         END IF;

  • Dynamic Where Clause in select using member attribute of class

    Hello,
    can anybody provide me some tips how to solve this problem:
              SELECT (lv_sql_select) INTO CORRESPONDING FIELDS OF TABLE lt_cntrl2
                         FROM (lv_db_name)
                     FOR ALL ENTRIES IN mt_guids
                 WHERE (lv_sql_where).
    works perfectly fine if I use a local table variable or a member of my class. But if I build my where clause using a member attribute of my class which comes from the interace- exactly the same type and data as before I get a dump.
    SELECT (lv_sql_select) INTO CORRESPONDING FIELDS OF TABLE lt_xyz
                         FROM (lv_db_name)
                     FOR ALL ENTRIES IN if_abc~mt_guids
    my where clause "guid = if_abc~mt_guids-guid.
    Dump:
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', was
         not caught in
        procedure "....GET_DATA" "(METHOD)", nor was it propagated
         by a RAISING clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        Das laufende ABAP-Programm wollte eine Open SQL-Anweisung ausführen,
        die eine dynamische Angabe enthält. Der Parser lieferte jedoch den
        Fehler: "Wrong table name or table alias name table alias name
         table alias name "....". table alias name
         "...". table alias name "...". t"

    Hi Marco Freischlag,
      As per my understanding , if we give for all entries we want to use internal table ,  For where conditions you want to pass variable , not internal table one filed,because it will not have header line...
    so code like this...
    SELECT (lv_sql_select) INTO CORRESPONDING FIELDS OF TABLE lt_xyz
                         FROM (lv_db_name)
                     FOR ALL ENTRIES IN if_abc~mt_guids
              where guid = if_abc~mt_guids-guid. " Here pass some variable or work area in it and test.
    Thanks,
    Vijay SR

  • How to create an UI element dynamically on action in drop down?

    Hi,
    How to create an UI element dynamically on action of selecting a value from the  drop down?
    help out with the steps i need to follow..

    Hi,
    <u><i><b>Dynamic UI Element creation</b></i></u>
    We can create it only in the WD Modify View.
    Get the instance for the Root UI Element Container.
    Create the UI element Ex: Input Field, Text View etc.
    Bind the UI Element to the Attribute Value.
    Now bind the UI Element to the Root UI Element Container.
              IWDTransparentContainer root =(IWDTransparentContainer)view.getRootElement();
              IWDDropdownByIndex DdbName = (IWDDropdownByIndex)view.createElement(IWDDropdownByIndex.class,"DdbName");
              IWDDropdownByIndex DdbAge = (IWDDropdownByIndex)view.createElement(IWDDropdownByIndex.class,"DdbAge");
              IWDDropdownByIndex DdbGender = (IWDDropdownByIndex)view.createElement(IWDDropdownByIndex.class,"DdbGender");
              IWDNode Mad =wdContext.getChildNode("Person",0);
              IWDAttributeInfo NameAtt = Mad.getNodeInfo().getAttribute("Name");
              IWDAttributeInfo AgeAtt = Mad.getNodeInfo().getAttribute("Age");
              IWDAttributeInfo GenderAtt = Mad.getNodeInfo().getAttribute("Gender");
              DdbName.bindValue(NameAtt);
              DdbAge.bindValue(AgeAtt);
              DdbGender.bindValue(GenderAtt);
              root.addChild(DdbName);     
              root.addChild(DdbAge);
              root.addChild(DdbGender);
    <u><i><b>Dynamic Action Creation</b></i></u>
    Create the Action in the Action tab.
    Create a Button.
    Get the reference for the created action (Through the Event Handler).
    Bind the Action to the Button.
    Bind the Button to the Root UI element Container.
    IWDButton ButGo = (IWDButton)view.createElement(IWDButton.class,"ButGo");
    IWDAction ActGo = wdThis.wdCreateAction(IPrivateStartView.WDActionEventHandler.GO,"Click");
    ButGo.setOnAction(ActGo);
    root.addChild(ButGo);
    Now write the required code for the Event Handler that is associated with the Action.
    //@@begin onActionGo(ServerEvent)
        IWDNode Mad = wdContext.getChildNode("Person",0);
         wdComponentAPI.getMessageManager().reportSuccess(Mad.getCurrentElement().getAttributeAsText("Name"));
         wdComponentAPI.getMessageManager().reportSuccess(Mad.getCurrentElement().getAttributeAsText("Age"));
         wdComponentAPI.getMessageManager().reportSuccess(Mad.getCurrentElement().getAttributeAsText("Gender"));
    //@@end
    Regards
    SURYA

  • Creating dynamic where clause with string delimiter " ; "

    hi...
    i need a solution for complex problem like, 1. start_date IN date,
    end_date IN date,
    shift_type IN varchar2
    i will get shift_type as "first_shift" or "first_shift;second_shift" or "first_shift;second_shift;third_shift" ....etc any combination. where fist & second & third shits are nothing but 1 , 2 , 3. i need to find out data between start_date and end_date in combination of shifts ( may be 1;2 or 1;3 or 1;2;3 or 2;3 ...etc) . now i need to write this code in dynamic where clause ...i tried in different ways...but not succeeded. can anybody guide me step by step...or with script.
    NOTE: there is a table called "shift" with data like
    shift_type shift_mode
    1 first_shift
    2 second_shift
    3 third_shift

    Hi,
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
    If the question involves parameters, give a few different sets of parameters and the results you want for each set, given the same sample data.
    It's unclear that you need dynamic SQL at all.
    If shift_type is a variable, that can be either a single value or a ;-delimited list (such as '1;3'), you can compare that to a column called shift_column like this:
    WHERE        ';' || shift_type   || ';'     LIKE
           '%;' || shift_column || ';%'No dynamic SQL or PL/SQL required.
    If you really do want to use dynamic SQL, these two pages should gives you some ideas:
    http://www.oracle-base.com/articles/misc/DynamicInLists.php
    http://tkyte.blogspot.com/2006/06/varying-in-lists.html

  • How to create dynamic where clause instead of pragmatically

    Hi,
    I'm using Jdev 11.1.2.2.0 and my requirement to create a two fields with search button to fetch data as adf table. User need to enter either of the field value and click search button to see his data.
    So I created a sql query based view object with 2 bind variables (which are input params) & 2 view criteria (to create dynamically where clause) and then drag on to the page by ExecuteWithParams operation from data controls but couldnt work.
    If anyone have idea to build dynamically please let me know.
    Amar

    User need to enter either of the field value and click search button to see his data.User need to enter either of the field value and click search button to see his data.
    Hi Amar,
    Is your requirement, creating a query panel with table??
    Drag and drop the view criteria(Application Navigator>DataControls> AppModule >NamedCriteria> ViewCriteriaName ) onto the page.
    In the context menu, select Query->ADFQueryPanel With Table.. That brings your necessary two columns and Search field with data represented as a table.
    Harsha
    Edited by: Harsha049 on Nov 28, 2012 3:51 PM

  • How to add a dynamic where clause for a sql based VO with group by query?

    Hi,
    Here is my case, I have a sql query based VO with the query like "select status, count(*) StatusCount from my_table group by status". Now I used the following java code trying to dynamically add the where clause to my VO to filter the rows based the type attribute in my DB table.
    vo.setWhereClause("type='MyType1' ");
    vo.executeQuery();
    Then I got the sql syntax error. Looks like the ADF has added the where clause to the end of my sql so my sql becomes "select status, count(*) StatusCount from my_table group by status where type='MyType1' ". But what I expected was the correct syntax "select status, count(*) StatusCount from my_table where type='MyType1' group by status".
    Does anyone know if this is an ADF bug? Or is there any other way to achieve my goal?
    Thanks,
    Chunyang
    Edited by: Chunyang on Dec 13, 2012 9:09 PM

    Hi,
    When you use setWhereClause on the VO, it is applied on top of the VO query. I.e, assume your VO has the following query.
    select empno, ename from empNow, if you apply the where clause programatically, only the two attributes that you are using in the select statement could be used. I.e
    select * from (select empno, ename from emp) where ename='KING' - VALID
    select * from (select empno, ename from emp) where deptno=10  - INVALID (because the inner query - the one you've defined as query for your vo does not have deptno attribute selected)If you would need to set a dynamic where clause, you need to make them available in your select statement / use bind variables.
    -Arun

  • Dynamic where clause with loop statement

    Hi all,
    is it possible to use a dynamic where clause with a loop statement?
    Can you please advise me, how the syntax needs to be?
    Thanks for your suggestions,
    kind regards, Kathrin!

    Hi Kathrin,
               If u are in ECC 6.0, please go through the code...
              REPORT  zdynamic_select.
    TYPES:
      BEGIN OF ty_sales,
        vbeln  TYPE vbak-vbeln,            " Sales document
        posnr  TYPE vbap-posnr,            " Sales document item
        matnr  TYPE vbap-matnr,            " Material number
        arktx  TYPE vbap-arktx,            " Short text for sales order item
        kwmeng TYPE vbap-kwmeng,           " Order quantity
        vkorg TYPE vbak-vkorg,             " Sales organization
        kunnr TYPE vbak-kunnr,             " Sold-to party
        netwr TYPE vbak-netwr,             " Net Value of the Sales Order
      END OF ty_sales.
    DATA :
      gt_sales TYPE STANDARD TABLE OF ty_sales,
      wa_sales TYPE ty_sales.
    DATA: ob_select TYPE REF TO cl_rs_where.
    DATA: ob_from   TYPE REF TO cl_rs_where.
    DATA: ob_where  TYPE REF TO cl_rs_where,
          gv_source TYPE abapsource.
    START-OF-SELECTION.
    *Step 1 : Prepare the select fields.
      PERFORM zf_build_select.
    *Step 2 : Build the from clause for the select
      PERFORM zf_build_from.
    *Step 3 : Build the where clause for the select
      PERFORM zf_build_where.
    *Step 4 : Execute the dynamic select
      SELECT (ob_select->n_t_where)
          FROM (ob_from->n_t_where)
            INTO CORRESPONDING FIELDS OF TABLE gt_sales
            WHERE (ob_where->n_t_where).
      LOOP AT gt_sales INTO wa_sales.
        WRITE :   /5 wa_sales-vbeln,
                  15 wa_sales-vkorg,
                  20 wa_sales-kunnr,
                  40 wa_sales-netwr,
                  50 wa_sales-posnr,
                  60 wa_sales-matnr,
                  70 wa_sales-arktx,
                  90 wa_sales-kwmeng.
      ENDLOOP.
    *&      Form  zf_build_select
    FORM zf_build_select .
      CREATE OBJECT ob_select.
    *Build the table name/field name combination
    *Add Sales order header fields
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAK'
          i_fieldname = 'VBELN'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAK'
          i_fieldname = 'VKORG'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAK'
          i_fieldname = 'KUNNR'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAK'
          i_fieldname = 'NETWR'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
    *Add Sales order item fields
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAP'
          i_fieldname = 'POSNR'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAP'
          i_fieldname = 'MATNR'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAP'
          i_fieldname = 'ARKTX'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
      CALL METHOD cl_rs_where=>build_tabname_fieldname
        EXPORTING
          i_tabname   = 'VBAP'
          i_fieldname = 'KWMENG'
          i_sign      = '~'
        IMPORTING
          e_combined  = gv_source.
    *Add the where line
      CALL METHOD ob_select->add_line
        EXPORTING
          i_line = gv_source.
    ENDFORM.                    " zf_build_select
    *&      Form  zf_build_from
    FORM zf_build_from .
      CREATE OBJECT ob_from.
    *Add opening bracket
      CALL METHOD ob_from->add_opening_bracket
      CLEAR gv_source.
    *Add the join condition.This can be made
    *fully dynamic as per your requirement
      gv_source = 'VBAK AS VBAK INNER JOIN VBAP AS VBAP'.
    *Add the where line
      CALL METHOD ob_from->add_line
        EXPORTING
          i_line = gv_source.
      CLEAR gv_source.
    *Add the join condition.This can be made
    *fully dynamic as per your requirement
      gv_source = 'ON VBAKVBELN = VBAPVBELN'.
    *Add the where line
      CALL METHOD ob_from->add_line
        EXPORTING
          i_line = gv_source.
    *Add the closing bracket
      CALL METHOD ob_from->add_closing_bracket
    ENDFORM.                    " zf_build_from
    *&      Form  zf_build_where
    FORM zf_build_where .
      DATA :
      lv_field TYPE REF TO data,
      lv_field_low TYPE REF TO data,
      lv_field_high TYPE REF TO data.
      CREATE OBJECT ob_where.
    *Add the field VBELN : Sales Document
    *Use this method if you want to assign a single value to a field
    *Set the value for VBELN : Sales Document Number
    CALL METHOD ob_where->add_field
       EXPORTING
         i_fieldnm  = 'VBAK~VBELN'
         i_operator = '='
         i_intlen   = 10
         i_datatp   = 'CHAR'
       IMPORTING
         e_r_field  = lv_field.
    CALL METHOD ob_where->set_value_for_field
       EXPORTING
         i_fieldnm = 'VBAK~VBELN'
         i_value   = '0000120020'.
    *Use this method if you want to assign a range of values
    *Set a range for the Sales Document number
      CALL METHOD ob_where->add_field_between_2values
        EXPORTING
          i_fieldnm      = 'VBAK~VBELN'
          i_intlen       = 10
          i_datatp       = 'CHAR'
        IMPORTING
          e_r_field_low  = lv_field_low
          e_r_field_high = lv_field_high.
      CALL METHOD ob_where->set_2values_for_field
        EXPORTING
          i_fieldnm    = 'VBAK~VBELN'
          i_value_low  = '0000120020'
          i_value_high = '0000120067'.
    *Set the 'AND' Clause
      CALL METHOD ob_where->add_and.
    *Add the field MATNR : Material
      CALL METHOD ob_where->add_field
        EXPORTING
          i_fieldnm  = 'MATNR'
          i_operator = '='
          i_intlen   = 18
          i_datatp   = 'CHAR'
        IMPORTING
          e_r_field  = lv_field.
    *Set the value for the Material field
      CALL METHOD ob_where->set_value_for_field
        EXPORTING
          i_fieldnm = 'MATNR'
          i_value   = '000000000050111000'.
    *Set the 'AND' Clause
      CALL METHOD ob_where->add_and
    *Add the field VKORG
      CALL METHOD ob_where->add_field
        EXPORTING
          i_fieldnm  = 'VKORG'
          i_operator = '='
          i_intlen   = 4
          i_datatp   = 'CHAR'
        IMPORTING
          e_r_field  = lv_field.
    *Set the value for VKORG : Sales Organization
      CALL METHOD ob_where->set_value_for_field
        EXPORTING
          i_fieldnm = 'VKORG'
          i_value   = 'GMUS'.
    ENDFORM.                    " zf_build_where

  • How to set dynamic WHERE clause to VO from backingBean?

    Hi,
    Can any one let me know the best way to add the dynamic WHERE clause in to VO query.
    I have created AM (with AMImpl.java) & VO (with VOImpl.java & VORowImpl.java) in my model project. I suppose to set the WHERE condition at runtime while the user click the search button. I am handling the user button click at UI layer backingBean. From the backing bean I could able to get the objct of the VO and set the where clause by below code.
            ValueExpression valueExp = elFactory.createValueExpression(elContext, "#{bindings.UserSearchVO1Iterator}", Object.class);
            DCIteratorBinding dcIter = (DCIteratorBinding)valueExp.getValue(elContext);
            ViewObject userSearchVO = dcIter.getViewObject();
            userSearchVO.setWhereClause("lower(usr_login) LIKE ':1' and usr_udf_suid like ':2' ");
            userSearchVO.executeQuery();But as I fear this is not the right way to do it. So I am creating the cutom method inside the VOImpl.java and triggring that method by creating one more cutom method in AMImpl.java. But I dont know how to invoke this AM method from backingBean.
    AMImpl method
    public void initDetails()
            UserSearchVOImpl vo = getUserSearchVO1();
            vo.initQuery();
    VOImpl method
        public void initQuery()
            setWhereClause("lower(usr_login) LIKE 'a%' and usr_udf_suid like '%1144%'");
            executeQuery();
        }Can any one guide me which is the best way to set the where clause to VO? How to call the AM method from backingBean?
    Thanks
    kln

    i am new to oracle 11g i writing a stored procedure in which i have made use of case in where clause to pass my parameter value v_toStoreID
    i have googled a lot regarding that i found that to use case in where clause it should be like this
    where
    case  column_value
    when 0
    then value1
    else
    value2
    end
    this my query
    SELECT ITMID as ItemId,
    NVL(OrderDtl.PackageID, 0) PackageId,
    OrderDtl.OrdDtlID,
    (CASE NVL(OrderDtl.PackageID, 0)
    WHEN 0
    THEN 1
    ELSE 0
    END) as PackageFlag,
    ivitem.Code ItemCode,
    ivitem.ITMNAME AS itemName,
    IvPatientIssueMst.IssueNo Issue_No,
    to_char(Issuedate, 'DD/MM/YYYY') IssueDate,
    OrderDtl.OrdQty,
    NVL(OrderDtl.AllocationID, 0) Package,
    OrderDtl.ServiceAmount MRP
    FROM IvPatientIssueMst
    JOIN OrderMst
    ON IvPatientIssueMst.OrderId = OrderMst.OrdId
    JOIN OrderDtl
    ON OrderDtl.OrdID = OrderMst.OrdId
    JOIN ivitem
    ON ivitem.ITMID = OrderDtl.DrugId
    LEFT JOIN IVPatientIndentMst
    ON IVPatientIndentMst.IndentID = IvPatientIssueMst.IndentId
    WHERE OrderMst.OrdVisitID = 395899
    AND
    *(CASE IvPatientIssueMst.StoreId*
    when NVL(IvPatientIssueMst.StoreId, 0)=0
    THEN v_toStoreID
    ELSE  IVPatientIndentMst.ToStoreID
    END)
    ORDER BY ivitem.ITMNAME;
    it is not working please someone help

  • Dynamic where clause for MULTIPLE values

    In the following of dynamic where clause?
    i have some somewhat different problem.
    Is a dynamic where clause for multiple values possible?
    If the inputvariable varCode1,varCode2,varCode3,varCode4 are 0 then show all id's otherwise filter the resultset on var1 and/or var2,and/or var3,and/or var4.
    Example table:
    create table t
    (d int,var int);
    insert into t values (1 ,1 );
    insert into t values (2 ,1 );
    insert into t values (3 ,2 );
    insert into t values (4 ,3 );
    insert into t values (5 ,4 );
    insert into t values (6 ,4 );
    insert into t values (7 ,4 );
    insert into t values (8 ,4 );
    insert into t values (9 ,5 );
    insert into t values (10, 6);
    insert into t values (11, 6);
    So what i want to change the where clause upon the value of the varCodes. If var1 and var are not 0 a "AND" should be used otherwise an "OR"
    select id
    from tst
    where var = DECODE( :varCode1, 0, var, :varCode1)
    or/and(?) DECODE( :varCode2, 0, var, :varCode2)
    or DECODE( :varCode3, 0, var, :varCode3)
    or DECODE( :varCode4, 0, var, :varCode4)

    Please turn off your Caps Lock
    and try this link
    Dynamic WHERE clause

  • Dynamic Where Clause - How To?

    I need help building a dynamic where clause in 1.6
    I have three fields:
    p1_col_where which is a static list of 8 columns
    p1_condition which is a static list of the 9 possible conditions(=,<,>...)
    p1_condition_value is a text field that the user enters the literal they want to use
    The lov select I thought would be:
    SELECT Description, positem
    FROM v_item
    WHERE :P1_COL_WHERE :P1_CONDITION :P1_CONDITION_VALUE
    I was hoping that this would be resolved to: WHERE item = 123
    but of course I get a big NASTY error.
    Can someone help me out?
    Thanks,
    Joe

    Mike,
    Thanks for the help.
    There's a problem in the docs for creating this popup on step 5. The docs say:
    Step 5 - Add the LOV report to the popup page
    select ename, job, sal , 'placeholder' the_link
    from emp
    where ename like '%'||:P2_ENAME||'%'
    and (job = :P2_JOB or :P2_JOB is null)
    and (sal = :P2_SAL or :P2_SAL is null)
    Note that the last column in this query is just a placeholder. once the region is created, turn that placeholder into a link by doing the following:
    1.     Navigate to the Page Definition for page 2
    2.     Next to the name of the report region created in step 5, Click Q
    3.     Next to the column THE_LINK, click the edit icon
    4.     In the "Link Text" field enter the string "select"
    5.     In the URL field enter: javascript:passBack('#ENAME#','#JOB#','#SAL#');
    6.     Click the "Apply Changes" button
    The problem is in number 5. There is NO URL field to enter that code. Where does it go?
    Also, your alternative method:
    IF :P1_COL_WHERE is null then
    RETURN 'SELECT Description, positem FROM v_item';
    ELSE
    RETURN 'SELECT Description, positem FROM v_item '||
    ' WHERE '||:P1_COL_WHERE||' '||:P1_CONDITION||' '||:P1_CONDITION_VALUE;
    END IF;
    With a 'GO' button is the method that I was trying. That's what gave me the error when the page loaded.
    Any assistance is greatly appreciated.
    Thanks,
    Joe

  • Creating a dynamic where clause

    hello,
    I am trying to create a procedure whech needs to parse a dynamic where clause into a cursor. The problem is I do not know the number of items that the user has selected (from previous input), thus what I want to pass in is a string of variables, but I donl;t think I can do this.
    Does anyone have any ideas on how I can do this?
    Thanks
    Bryan
    [email protected]
    an example of theh code I am trying to run is:
    v_update:='UPADTE :tabnam
    SET ctrecid = :ctrec';
    WHERE :v_and
    AND pxlrecno = :strt';
    v_cursor2 := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(v_cursor2,v_update,DBMS_SQL.V7);
    DBMS_SQL.BIND_VARIABLE(v_cursor2,':tabnam',tabnam);
    DBMS_SQL.BIND_VARIABLE(v_cursor2,':ctrec',ctrec);
    DBMS_SQL.BIND_VARIABLE(v_cursor2,':v_and',v_and);
    DBMS_SQL.BIND_VARIABLE(v_cursor2,':strt',strt);
    v_numrows:=DBMS_SQL.EXECUTE(v_cursor);
    Where v_and is something like:
    item1='TEST1' AND item2='TEST2' AND item3='TEST3'
    null

    SQL> EDIT update_tabnam
    CREATE OR REPLACE PROCEDURE update_tabnam
    (tabnam IN VARCHAR2,
    ctrec IN VARCHAR2,
    v_and IN VARCHAR2,
    strt IN VARCHAR2)
    IS
    v_update VARCHAR2 (3000);
    v_cursor2 INTEGER;
    v_numrows INTEGER;
    BEGIN
    v_update := 'UPDATE ' &#0124; &#0124; tabnam
    &#0124; &#0124; ' SET ctrecid = ' &#0124; &#0124; '''' &#0124; &#0124; ctrec &#0124; &#0124; ''''
    &#0124; &#0124; ' WHERE ' &#0124; &#0124; v_and
    &#0124; &#0124; ' AND pxlrecno = ' &#0124; &#0124; strt;
    v_cursor2 := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE (v_cursor2, v_update, DBMS_SQL.V7);
    v_numrows := DBMS_SQL.EXECUTE (v_cursor2);
    DBMS_SQL.CLOSE_CURSOR (v_cursor2);
    END update_tabnam;
    SQL> START update_tabnam
    Procedure created.
    SQL> EXEC update_tabnam('TEST',7,'ITEM1=''TEST1'' AND ITEM2=''TEST2'' AND ITEM3=''TEST3''',1)
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM test;
    CTRECID PXLRECNO ITEM1 ITEM2 ITEM3
    7 1 TEST1 TEST2 TEST3
    Note: Posting on this forum causes spaces to be inserted between the concatenation symbols where they don't belong, so anywhere you see a space between | and | remove it, before saving the file and starting it to create the procedure.
    null

Maybe you are looking for

  • I expand my icloud storage but i can't find my photos from my camera roll?

    Before I subscribed for icloud storage I read that all pictures from camera roll will be save also so I did subscribe but now that im viewing my icloud i couldn't find any except the one's from photo stream. What happened now to my photos in my camer

  • Why Can't I get Video Out to TV?

    I purchased an MSI Machine from a local distributor and they failed to give me any doocumentation. I've spent much time and anguish gathering the info. (Specs Below) I'm trying to get video out to TV and hopefully Video in also. But I don't know what

  • Connecting a macbook pro to a verizon wireless network

    how do i connect a macbook pro to a verizon wireless network? Wi-Fi connection automatically assigns an IP address and indicates that the Mac won't be able to connect to the internet. Two other MacBook Pros connect to the network without any problems

  • Automatically connects to wifi

    My Samsung Galaxy SIII keep automatically connecting to WIFI, even when I have switched WIFI  to OFF.  I also tried disabling NOTIFY ME WHEN THERE'S AVAILABLE WIFI.  I'm sitting in my house, did both those steps above, and when I use 4g to get into d

  • How can I find a post I made esterday

    How can I find a post I made yesterday