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;

Similar Messages

  • Exception caused by bind variables in ORDER BY clause and VO RANGE_PAGING

    Hi,
    I'm using a ViewObject in RANGE_PAGING mode and discovered a problem when using bind variables in the ORDER BY clause of my statement:
    SELECT * FROM (SELECT /*+ FIRST_ROWS */ IQ.*, ROWNUM AS Z_R_N FROM (
      SELECT * FROM T_TABLE WHERE (attr1 = :1) ORDER BY decode (attr2, :2, 1, null, 0, -1) desc, attr3 ) IQ 
      WHERE ROWNUM < :2) WHERE Z_R_N > :3 When a bind variable is used in the ORDER BY CLAUSE and the method VO.getEstimatedRowCount() is call then the DB issued an SQL error:
    java.sql.SQLException: Ungültiger Spaltenindex (eng.: invalid column index)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:137)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:174)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:239)
         at oracle.jdbc.driver.OraclePreparedStatement.setStringInternal(OraclePreparedStatement.java:4612)The numbering of the bind variables indicates that the last two bind variables have the wrong numbering (??)
    When I rewrite the SQL into the following statement, the SQL error does not occur but I have not verified yet that the VO delivers the correct range of data because the numbering of the bind variables is not correct.
    SELECT * FROM (SELECT /*+ FIRST_ROWS */ IQ.*, ROWNUM AS Z_R_N FROM (
      SELECT *, decode (attr2, :1, 1, null, 0, -1) as ATTR_FOR_SORTING FROM T_TABLE WHERE (attr1 = :2) ORDER BY ATTR_FOR_SORTING  desc, attr3 ) IQ 
      WHERE ROWNUM < :2) WHERE Z_R_N > :3I'm working with JDev 10.1.2 and Oracle DB 9203.
    Any comments are welcome!
    Thanks,
    Markus

    You are using the bind variable :2 twice. Did you try
    SELECT * FROM (SELECT /*+ FIRST_ROWS */ IQ.*, ROWNUM AS Z_R_N FROM (
      SELECT * FROM T_TABLE WHERE (attr1 = :1) ORDER BY decode (attr2, :2, 1, null, 0, -1) desc, attr3 ) IQ 
      WHERE ROWNUM < :4) WHERE Z_R_N > :3
    setWhereClauseParm(0, "a"); // :1
    setWhereClauseParm(1, "b"); // :2
    setWhereClauseParm(2, "c"); // :3
    setWhereClauseParm(3, "b"); // :2setting the fourth parameter the same as the second one?
    I remeber reading something about using bind variables twice causing problems, but I#m not sure about it.

  • 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

  • How to use a lexical variable in a WHERE clause and as a function argument.

    Hello,
    My report has a lexical variable which has values like 'and id in (1,3,4)'. I want to use this variable in two separate queries. In the first, it is used in the WHERE clause, something like:
    .. where date is not null &var;
    In the second query, the variable is used in a function call, something like:
    select * from table (my_function(&var));
    The trouble is that the first query works when the value of the variable is unquoted, but for the second query the value should be quoted.
    Does anyone have an idea how I could solve this problem?
    Thanks in advance,
    Frans
    Message was edited by:
    fransie

    http://tkyte.blogspot.com/2006/06/varying-in-lists.html
    Presents many options.

  • 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

  • Csv no data found when using bind variables

    Hi,
    I have created a report, that uses 2 date variables to limit the query and rows display as they should. But clicking the csv link opens csv having one row stating 'No data found...'. If I set static values in place of variables, I get the right result. How could I use bind variables and get the right answer in csv (without coding my own function)?
    Kaja

    I am having the same problem.
    The export link opens a new session without submitting the current page. The page item values are therefor not saved to cache before the export is undertaken.
    Any report using page item bind variables in the where clause will not export correctly as the bind values are either null or those of the previous page submit.
    Any ideas on how to get round this??

  • How to dynamically update columns in a where clause to a SQL query in OSB?

    Hi Gurus,
    I have a requirement where in we need to dynamically update a where clause to a SQL query in OSB(11.1.1.6.0).
    For example:
    If the JCA sql string is "select * from emp where emp_id = 100 and emp_status ='Permanent'" now i want to change this where clause and the new query has to be like "select * from emp where emp_name like 'S%' and emp_dept like 'IT' ". basically we need to change the where clause dynamically.
    We can also use "fn-bea:execute-sql()" in a xquery but I don't want to use this function as creates a new connection.
    I have done some home work and found out --> as per the DOC "http://docs.oracle.com/cd/E23943_01/dev.1111/e15866/jca.htm#OSBDV943" section: "25.5.2 JCA Transport Configuration for Proxy and Business Services", when a business service is created by using JCA, we can see Interaction Spec Properties under JCA Transport Tab. This will have a property "SqlString' and we can over ride it. But I am unable to figure out how to over ride the value. I have tried by using Transport Headers activity but no luck. Please guide me how to achieve this?
    Thanks in advance
    Surya

    I solved my problem.
    In my header renderer, I simply added a line to set the text to the object value "label.setText( (String) value );" (where label is an instance of a JLabel.
    Thank you to who took some time to think about it.
    Marc

  • Loop with dynamic where clause

    hi,
        In a program we need to use a loop into an internal table with a where condition is decided on run time.
    "Select" from database table is using dynamic where clause and it is working fine.
    For the loop part does any one have any idea on this? if we can have dynamic where clause in a loop into internal tab?
    Thanks

    Hi,
    You can't use 'loop where' dynamically  .
    Have you already tried to use Ranges and CHECK statement?
    Like:
    First mount range options;
    Loop at <table>.
    Check using the range.
    endloop.
    Maybe it's works for you !!
    Marcelo Ramos

  • 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

  • Using bind variable with IN clause

    My application runs a limited number of straight up queries (no stored procs) using ODP.NET. For the most part, I'm able to use bind variables to help with query caching, etc... but I'm at a loss as to how to use bind variables with IN clauses. Basically, I'm looking for something like this:
    int objectId = 123;
    string[] listOfValues = { "a", "b", "c"};
    OracleCommand command = new OracleCommand();
    command.Connection = conn;
    command.BindByName = true;
    command.CommandText = @"select blah from mytable where objectId = :objectId and somevalue in (:listOfValues)";
    command.Parameters.Add("objectId", objectId);
    command.Parameters.Add("listOfValues", listOfValues);
    I haven't had much luck yet using an array as a bind variable. Do I need to pass it in as a PL/SQL associative array? Cast the values to a TABLE?
    Thanks,
    Nick

    Nevermind, found this
    How to use OracleParameter whith the IN Operator of select statement
    which contained this, which is a brilliant solution
    http://oradim.blogspot.com/2007/12/dynamically-creating-variable-in-list.html

  • How to use a bind variable in an IN clause

    I am trying to use a bind variable in an IN clause where the column is a varchar2 type. Something like:
    select *
    from test
    where test_column in (:bindVariable)I have tried assigning the bind variable comma separated strings (eg. test,test,test) and comma separated strings with quotes (eg. 'test','test','test'). Neither of these work. Does anyone know the correct way to do this?
    Thanks in advance.

    http://tkyte.blogspot.com/2006/06/varying-in-lists.html
    Presents many options.

  • Dynamic Where clause in 4.6C [Literals allowed but not variables]

    Good afternoon-
    We have a dynamic select statement that works perfectly in 4.7 ext 2, but is causing a short dump in 4.6C. The error in the short dump says:
    The current ABAP/4 program attempted to execute an ABAP/4 Open SQL       
    statement containing a WHERE condition of the form WHERE (itab) or       
    WHERE ... AND (itab). The part of the WHERE condition specified at       
    runtime in the internal table itab contains an invalid                   
    value "HDR_COMP_CODE". Literals are allowed as values, but not variables.
    HDR_COMP_CODE is in incoming parameter to the function module that is calling this code. It is of type BKPF-BUKRS.
    Here is the code:
    DATA: BEGIN OF L_WHERE_CLAUSE OCCURS 0,
            TEXT_LINE(60) TYPE C,
      END OF L_WHERE_CLAUSE.
      CLEAR L_WHERE_CLAUSE.
      IF NOT HDR_COMP_CODE IS INITIAL.
        SELECT SINGLE KTOPL
        INTO LV_KTOPL
        FROM T001
        WHERE BUKRS = HDR_COMP_CODE.
        L_WHERE_CLAUSE = 'B~BUKRS = HDR_COMP_CODE'.
        APPEND L_WHERE_CLAUSE.
        CLEAR  L_WHERE_CLAUSE.
        L_WHERE_CLAUSE = 'AND'.
        APPEND L_WHERE_CLAUSE.
        CLEAR  L_WHERE_CLAUSE.
        L_WHERE_CLAUSE = 'T~KTOPL = LV_KTOPL'.
        APPEND L_WHERE_CLAUSE.
        CLEAR  L_WHERE_CLAUSE.
        L_WHERE_CLAUSE = 'AND'.
        APPEND L_WHERE_CLAUSE.
        CLEAR  L_WHERE_CLAUSE.
      ENDIF.
      L_WHERE_CLAUSE = 'T~SPRAS = SY-LANGU'.
      APPEND L_WHERE_CLAUSE.
      CLEAR  L_WHERE_CLAUSE.
      SELECT BSAKNR TTXT50
      INTO (LT_GL_ACCOUNT_DATA-GL_ACCOUNT, LT_GL_ACCOUNT_DATA-DESCRIPTION)
      FROM  SKB1 AS B INNER JOIN SKAT AS T
         ON TSAKNR = BSAKNR
      WHERE (L_WHERE_CLAUSE).
        APPEND LT_GL_ACCOUNT_DATA.
        CLEAR  LT_GL_ACCOUNT_DATA.
      ENDSELECT.
    This EXACT query works in 4.7, has anyone run into this, or can they tell me why I might be getting the error?
    Thanks,
    Andy

    Well, in this case, unless I'm missing something,  you do not requre a dynamic WHERE clause.  You can use RANGES instead.
    report zrich_0001.
    *DATA: BEGIN OF L_WHERE_CLAUSE OCCURS 0,
    *TEXT_LINE(60) TYPE C,
    *END OF L_WHERE_CLAUSE.
    ranges: r_bukrs for t001-bukrs.
    ranges: r_ktopl for t001-ktopl.
    *CLEAR L_WHERE_CLAUSE.
    IF NOT HDR_COMP_CODE IS INITIAL.
    clear r_bukrs. refresh r_bukrs.
    r_bukrs-sign = 'I'.
    r_bukrs-option = 'EQ'.
    r_bukrs-low = hdr_comp_code.
    append r_bukrs.
    SELECT SINGLE KTOPL
    INTO LV_KTOPL
    FROM T001
    WHERE BUKRS = HDR_COMP_CODE.
    clear r_ktopl. refresh r_ktopl.
    r_ktopl-sign = 'I'.
    r_ktopl-option = 'EQ'.
    r_ktopl-low = lv_ktopl.
    append r_ktopl.
    *L_WHERE_CLAUSE = 'B~BUKRS = HDR_COMP_CODE'.
    *APPEND L_WHERE_CLAUSE.
    *CLEAR L_WHERE_CLAUSE.
    *L_WHERE_CLAUSE = 'AND'.
    *APPEND L_WHERE_CLAUSE.
    *CLEAR L_WHERE_CLAUSE.
    *L_WHERE_CLAUSE = 'T~KTOPL = LV_KTOPL'.
    *APPEND L_WHERE_CLAUSE.
    *CLEAR L_WHERE_CLAUSE.
    *L_WHERE_CLAUSE = 'AND'.
    *APPEND L_WHERE_CLAUSE.
    *CLEAR L_WHERE_CLAUSE.
    ENDIF.
    *L_WHERE_CLAUSE = 'T~SPRAS = SY-LANGU'.
    *APPEND L_WHERE_CLAUSE.
    *CLEAR L_WHERE_CLAUSE.
    SELECT B~SAKNR T~TXT50
    INTO (LT_GL_ACCOUNT_DATA-GL_ACCOUNT, LT_GL_ACCOUNT_DATA-DESCRIPTION)
    FROM SKB1 AS B INNER JOIN SKAT AS T
    ON T~SAKNR = B~SAKNR
    WHERE  b~bukrs in r_bukrs
      and  t~ktopl in r_ktopl.
    APPEND LT_GL_ACCOUNT_DATA.
    CLEAR LT_GL_ACCOUNT_DATA.
    ENDSELECT.
    Regards,
    Rich Heilman

  • ADF dynamic where clause for VO query using BC

    I'm hoping someone can help me out. I have a read only view object that I want to filter results based on some user choices. For example the user may want to see all results or they may only want to see a much smaller subset. This is for an error dashboard, the smaller subset maybe by application or maybe by application and by error severity. I think I can use a dynamic where clause but I'm not sure, Can someone get me started down the right path, or post an example that I can see.

    Hi user,
    You can use a dynamic where clause for this, but maybe there is a more practical option. Maybe you can have a fixed where clause, but using a bind parameter, like:
    vo.application like :applicationParam. This makes an executeWithParams method available that you can call from your page, and use in the bindings. This parameter you can populate with the results of for example a poplist, with a default value of '%'.
    When you do want to use a dynamic where clause, you will need to add a method to the java code of your application module, and make this method available for the client. In this method, you can use findViewObject to retrieve your VO, use VO.setWhereClause to set the whereclause to what you want, and then call VO.executeQuery. This method can then again be called from the page.
    Success,
    Jeroen van Veldhuizen

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

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

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

  • REP 300 error when using dynamic where clause

    Hi,
    I am developing a report and I need a dynamic where clause.The code I have written in the where clause is as below
    function where_clauseFormula return VARCHAR2 is
    begin
    if :P_PO_REQD = 'No' then
    return ('and pha.segment1 is null');
    elsif :P_PO_REQD = 'Yes' then
         return('and pha.segment1 between NVL(:p_po_num_from,1) and NVL(:p_po_num_to,99999999999999999)');
    else return NULL;
    end if;
    end;
    Now if i directly use either of the conditions in my report query it works fine.But if the parameter is No then the where clause does not work.I have also tried different statements in the if clause of the 'No' part and they work.For example the following code works when :P_PO_REQD is 'No' :
    function where_clauseFormula return VARCHAR2 is
    begin
    if :P_PO_REQD = 'No' then
    return ('and pha.segment1 between NVL(:p_po_num_from,1) and NVL(:p_po_num_to,99999999999999999)');
    elsif :P_PO_REQD = 'Yes' then
         return('and pha.segment1 between NVL(:p_po_num_from,1) and NVL(:p_po_num_to,99999999999999999)');
    else return NULL;
    end if;
    end;
    I don't know why this is happening.I really need a solution or a workaround urgently
    Thanks
    Mukund

    You may use Lexical Reference for the dynamic where. In After Parameter Form Trigger, code....
    if :P_PO_REQD = 'No' then
    :P_where := :P_where || 'and pha.segment1 is null';
    elsif :P_PO_REQD = 'Yes' then
    :P_where := :P_where || 'and pha.segment1 between NVL(:p_po_num_from,1) and NVL(:p_po_num_to,99999999999999999)';
    end if;
    ..........

Maybe you are looking for

  • PO print preview displays incorrect setting in decimal places

    Dear Experts Please help me on the following condition. I have a problem in print preview of a PO. It displays the incorrect setting for decimal place in currency. It shows USD 1.404,00 whereby the amount should be USD 1,404.00 This only happens to a

  • How to calculate the data in bex

    Dear all,             i have a service order no and it current active status  and it time stamp details in my query example sevice orer no  posting date name    current active status  active status date    part aging 800000243      15.01.2009   shahi

  • My ipod is not being recognized anymore by my computer- HELP!

    i have an HP- i use windows home as my software, and i have a 20gb ipod... it's less than a year old... for some reason suddenly when i go to import songs/music from my computer to my ipod my computer is not recognizing my ipod- i can import the musi

  • Adding text field to Web Dynpro

    Hi Experts, I need to add new text field on Standard SAP Dynpro for standard field . In standard it has two value : "01" or "02". And I nedd to add near "Material" or "Service" depending on value of  standard field. I checked standard field in F4. It

  • Quick Edit mode with Aperture

    Using Elements 11 as an external editor for Aperture. In Quick mode the changes are not saved to Aperture. Expert mode works fine and Quick worked ok using Elements 9, What's up with the new program?