Bind variables Where X in (:B)

Hi
Is there a way to use bind variables in a where in clause (not where =)
Here's my query:
select *
from events
where BE_ID in (:BE_IDS)
and BE_TIME between to_date(:StartDate, 'dd/MM/yyyy HH24:MI:SS')
and to_date(:EndDate, 'dd/MM/yyyy HH24:MI:SS')
order by BE_ID, BE_TIME
I can't define BE_IDS as number since it's a collection of numbers (f.e. 1,2,3,4) but when i try to define it as nvarchar I recieve ORA-01722: Invalid number error.
Any ideas?

SQL> var str varchar2(1000)
SQL> exec :str := '1,2,3,4,5,666,7890,9999'
PL/SQL procedure successfully completed.
SQL> run
  1  SELECT empno, ename
  2               from   emp e
  3               WHERE  empno IN (
  4                         SELECT EXTRACTVALUE (xt.COLUMN_VALUE, 'e')
  5                         FROM   TABLE (XMLSEQUENCE (EXTRACT (XMLTYPE (   '<ord_num><e>'
  6                                                                      || REPLACE (:str, ',', '</e><e>')
  7                                                                      || '</e></ord_num>'
  8                                                                     )
  9                                                           , '/ord_num/*'
10                                                            )
11                                                   )
12*                                     ) xt)
     EMPNO ENAME
      9999 Tim

Similar Messages

  • Asking for bind variable where none is needed

    Good Morning,
    I am still working these regexp date_time project.
    I have a problem where oracle is asking for a bind variable where it doesn't need any as far as I can see. I am trying to capture various date times in a column and formatting them into one default format used by oracle. Here is what I got which works before I wrap it in the TO_DATE function
    There are many when then's but I am using only one here.
    select case
    when regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}') is not null
    then regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}')
    else date_time
    end as new_time
    from raw_data;
    The above statement works
    Now when I want to format the date that I found with this:
    select case
    when regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}') is not null
    then TO_DATE('regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}')','MM/DD/YYYY')
    else date_time
    end as new_time
    from raw_data;
    I get a request to insert a value for the digit as a bind variable. The digit should be populated from the when statement when it returns not null when a date is found.
    Could some one please tell me even if what I wrote here is even possible or make a suggestion to the syntax to get around this issue?
    All this is going to be incorporated into an update statement later on.
    I am running this on sql developer, oracle 11g.
    Thanks for your help in this matter in advance.
    regards,
    Al

    From looking at the code, as you have not supplied any scripts to create a table and demonstrate the error...
    Your case statement is trying to return two types
    select case
    when regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}') is not null
    then TO_DATE('regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}')','MM/DD/YYYY')
    else date_time
    end as new_time
    from raw_data;or simply
    select case when <expr>
                then <RETURN A DATE>
                else <RETURN A VARCHAR2>
            end as new_time
      from raw_data;The column cannot be both.
    Sorry I don't know your requirements.
    You could drop the else part and just return the converted date.
    You could fetch it back in two columns, the ones you can convert in one column (Which would be an oracle date type),
    the ones you cannot convert in another (which would be varchar2).
    Cheers,
    GP>

  • HELP: VO Bind variable gets lost, VO passivation checked!

    JDEv 10.1.3.0.4 + Struts/ADF
    I have a VO with one bind variable "accountId", this VO is the "root master" of the hierarchy => not a detail of a link.
    I added a method in the VO (that is part of one AM only) to set the bind variable:
      WHERE CLAUSE:
    (Wevent.EVENT_ID = WeventDesign.EVENT_ID) AND (Wevent.ACCOUNT_ID = AccountOwner.ACCOUNT_ID) AND (Wevent.PHOTOGRAPHER_ACCOUNT_ID = AccountPhotoGrapher.ACCOUNT_ID) AND (Wevent.EVENT_STATUS BETWEEN 30 AND 80) AND (Wevent.ACCOUNT_ID = :0)
      Binding Style: Oracle Positional
      private Number accountId = null;
      private Object[] DEFAULT_VALUES = new Object[]{ Constants.NUMBER_ZERO };
      private static int NUM_DEFAULT_VALUES = DEFAULT_VALUES.length;
      public Row setAccountId(Number newAccountId)
        Row row = null;
        if (newAccountId == null)
        this.accountId = null;
        this.clearCache();
        System.out.println(getClass().getName()+".setAccountId no exeqry newAccountId == null");    
        else
          this.accountId = newAccountId;
          row = this.getCurrentRow();
          if(row == null || row.getAttribute("AccountId") == null || !newAccountId.equals(row.getAttribute("AccountId")))  
    // not good account events !!!!
          this.setWhereClauseParam(0,newAccountId);
          System.out.println(getClass().getName()+".setAccountId before exeqry newAccountId: "+newAccountId);    
          this.executeQuery();
    //      System.out.println(getClass().getName()+".setAccountId after exeqry getRowCount(): "+this.getRowCount());    
          row = this.first();
            if (row != null)
            System.out.println(getClass().getName()+".setAccountId after exeqry+first row.getAttribute(AccountId): "+row.getAttribute("AccountId"));            
            else
            System.out.println(getClass().getName()+".setAccountId after exeqry+first row is null => no rows");                    
          else
          System.out.println(getClass().getName()+".setAccountId NO exeqry this.accountId: "+this.accountId+", newAccountId: "+newAccountId+" current is null? "+(this.getCurrentRow() == null));          
          this.accountId = newAccountId;   
          DEFAULT_VALUES[0] = newAccountId;
          System.out.println(getClass().getName()+".setAccountId this.accountId: "+this.accountId+", newAccountId: "+newAccountId+", DEFAULT_VALUES[0]: "+DEFAULT_VALUES[0]);          
        return row;
    In the AMImpl class I added a service method:
      public Row prepareModelForEventAccountOwnerList(Number accountId)
        EventAccountOwnerListExtVOImpl eventAccountOwnerListExtVOImpl = this.getEventAccountOwnerListExtVO1();
        return eventAccountOwnerListExtVOImpl.setAccountId(accountId);
      }When the user logs in his accountId is retrieved and stored in the HttpSession.
    and the service method is called.
    Ok at this point.
    I have a Page that displays the view.
    In the class AccountEventsAction that extends PagingDataForwardAction I have following initializeModelForPage method.
      protected void initializeModelForPage(DataActionContext ctx)
        System.out.println(getClass().getName()+".initializeModelForPage BEGIN "+System.currentTimeMillis());
        WebAccountAM webAccountAM = (WebAccountAM) this.getApplicationModule(WebConstants.AM_WEBACCOUNT,ctx);
        if (webAccountAM == null)
         // return error
         System.out.println(getClass().getName()+".initializeModelForPage webAccountAM not found.");
        else
          UserContainer userContainer = this.getUserContainer(ctx);
          Row row = webAccountAM.prepareModelForEventAccountOwnerList(userContainer.getAccountId());
          if (row != null)
          System.out.println(getClass().getName()+".initializeModelForPage userContainer.getAccountId(): "+userContainer.getAccountId()+", EventId: "+row.getAttribute("EventId")+", current row key: "+row.getKey());             
          else
          System.out.println(getClass().getName()+".initializeModelForPage userContainer.getAccountId(): "+userContainer.getAccountId()+", First row is null? "+(row == null));     
          super.initializeModelForPage(ctx);
        }To my knowledge because this page is accessible only after login and the VO passivation state (+bind vars ..) is yes it shouldn't be necessary?
    FIRST PROBLEM:(non blocking)
    =============
    I noticed in my trace that the VO current row is null when the service method gets called in the initializeModelForPage binding method?
    So the query gets re-exceuted, is this normal??
    SECOND PROBLEM (blocking)
    ================
    At some point the Web app. the frameworks calls the executeQueryForCollection and an exception is thrown as if the bind variable was lost???
    extract:
    oracle.jbo.JboException: JBO-29000: Unexpected exception caught: oracle.jbo.SQLStmtException, msg=JBO-27122: SQL error during statement preparation.  Statement: SELECT Wevent.EVENT_ID, ...       
    FROM WEVENT Wevent, WEVENT_DESIGN WeventDesign, ACCOUNT AccountOwner, ACCOUNT AccountPhotoGrapher WHERE (Wevent.EVENT_ID = WeventDesign.EVENT_ID) AND (Wevent.ACCOUNT_ID = AccountOwner.ACCOUNT_ID) AND (Wevent.PHOTOGRAPHER_ACCOUNT_ID = AccountPhotoGrapher.ACCOUNT_ID) AND (Wevent.EVENT_STATUS BETWEEN 30 AND 80) AND (Wevent.ACCOUNT_ID = :0) ORDER BY Wevent.T_MODIFIED
         at oracle.jbo.JboException.<init>(JboException.java:346)
         at oracle.adf.controller.lifecycle.PageLifecycle.handleError(PageLifecycle.java:722)
         at oracle.adf.controller.struts.actions.DataAction.handleError(DataAction.java:257)
         at oracle.adf.controller.struts.actions.DataAction.handleError(DataAction.java:453)
         at oracle.adf.controller.lifecycle.PageLifecycle.handleLifecycle(PageLifecycle.java:147)
         at oracle.adf.controller.struts.actions.DataAction.handleLifecycle(DataAction.java:223)
         at com.photoswing.webview.actions.BaseDataForwardAction.handleLifecycle(BaseDataForwardAction.java:239)
         at oracle.adf.controller.struts.actions.DataAction.execute(DataAction.java:155)
         at oracle.adf.controller.v2.struts.actions.DataAction.execute(DataAction.java:104)
         at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:434)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:332)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
         at com.photoswing.filter.LocaleFilter.doFilter(LocaleFilter.java:318)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:627)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:218)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:119)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    ## Detail 0 ##
    oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. 
    06/10/13 22:37:15 java.sql.SQLException: Missing IN or OUT parameter at index:: 1
    06/10/13 22:37:15      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)I hope I didn't miss something and I don't have to review all my bind variables setting methods!
    Your help is required and will be appreciated
    Fred

    More info:
    I added a trace in the executeQueryForCollection method of the VO.
    As I said before the binding var is set on login and in initializeModelForPage
    but when the executeQueryForCollection is called by framework later on in the action cycle, it is called without any parameters => bind variables = numUserParams: 0 ??
    trace extract
    com.photoswing.model.site.EventAccountOwnerListExtVOImpl.executeQueryForCollection this.accountId: null, numUserParams: 0, DEFAULT_VALUES[0]: 0
    I suppose that some code must be added so that my bind variables will be part of the passivation process.
    Can you help me with that?
    Thanks for your time.
    Fred
    PS It's my second day on this problem.

  • 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;

  • Where clause with Bind Variable in ViewObject

    As per recomendations from Jdev team they say that using Bind varialbles in where clause will improve the performance (Option 1) But it is causing us to create more view objects.
    Example : Lets say we have a View Object EmpVO
    Option 1:
    ViewObject vo=context.getViewObject("EmpVO");
    vo.setWhereClause("EMPNO=?");
    vo.setWhereClauseParam(0,st);
    (or)
    Option 2:
    vo.setWhereClause("EMPNO="+st);
    If we want to use same View Object "EmpVO" in another Action Class
    ViewObject vo1=context.getViewObject("EmpVO");
    vo1.setWhereClause("DEPTNO=?");
    vo1.setWhereClauseParam(0,str);
    It this case it throws an error saying BIND VARIABLE already exits. So we have to make another View Object.
    Where as if we did not use bind variable but used Option 2 approach the same view object can be used in multiple pages.(at the expense of performance as per Jdev team)
    Are we doing something wrong here or are there other ways to use the same view object when using bind variable in where clause.
    Thanks

    I haven't been using BC4J for a while, but I seem to recall that the recommendations are that you don't set the where clause at runtime: You're supposed to define your view with the bind parameter already in it.
    So you'd probably define an EmpsForEmpNoVO and type "EMPNO = ?" in the where box. (There are other ways of finding a single row/entity and one of those may well be more efficient. Perhaps a better example of where you might want a view of employees is WHERE DEPTNO = ?.)
    IIRC, all instances of a particular type of view share the same definition, so you have to be careful if you alter that at runtime. However, I think everything's set up so that you can have many different (and separate) resultsets for a single view (instance) - meaning that it's possible to "run" a view for (e.g.) two different ids. (It's definitely possible to create two different instances of a view from its definition - and the resultsets will definitely be separate then. I think there's a "create" method on the application module; I remember that "find..." always returns the same instance of the view.)
    Hope that's a push in the right direction (since no-one else had replied - and I hope not too much has changed since 9.0.3)....
    Mike.

  • Bind variable error while adding dynamic where clause to VO query

    hi
    i have extended a VO and in the VOImpl i have written the following code
    public class HzPuiClassificationListVOExImpl extends HzPuiClassificationListVOImpl
    public void initQuery(String partyId, String s1, String classCode)
    /* Logging Code*/
    if(this.isLoggingEnabled(OAFwkConstants.PROCEDURE))
    {this.writeDiagnostics(this," > initQuery() , partyId ="+partyId+" , s1 ="+s1+", classCode="+classCode,OAFwkConstants.PROCEDURE);}
    setWhereClauseParams(null);
    setWhereClauseParam(0, classCode);
    setWhereClauseParam(1, classCode);
    setWhereClauseParam(2, partyId);
    String query = super.getQuery();
    * Check if the whereClause is already present
    if(query!=null && query.toUpperCase().indexOf("AAAAA") == -1)
    OAApplicationModule am = (OAApplicationModule)this.getApplicationModule();
    OADBTransaction oadbTxn = am.getOADBTransaction();
    String whereClause = "   class_category IN ("+
    *" SELECT flv.lookup_code"+*
    *" FROM fnd_lookup_values flv, fnd_lookup_values_dfv dfv"+*
    *" WHERE flv.rowid = dfv.row_id"+*
    *" AND flv.lookup_type = 'XXXXX'"+*
    *" AND dfv.context_value = flv.lookup_type"+*
    *" AND dfv.oco_enabled = 'Y' "+*
    this.addWhereClause(whereClause);
    this.executeQuery();
    * This is the default constructor (do not remove)
    public HzPuiClassificationListVOExImpl()
    when i run the page i get this error
    java.sql.SQLException: Missing IN or OUT parameter at index:: 2
    the original vo query below has 3 bind variables
    SELECT *
    FROM (SELECT *
    FROM (SELECT cc.class_category
    ,l.meaning
    FROM hz_class_categories cc
    ,fnd_lookup_types_vl l
    WHERE cc.class_category = l.lookup_type
    AND l.view_application_id = 222
    AND EXISTS (
    SELECT NULL
    FROM hz_code_assignments ca
    WHERE ca.owner_table_name = 'HZ_CLASS_CATEGORIES'
    AND ca.owner_table_id IS NULL
    AND ca.owner_table_key_1 = cc.class_category
    AND ca.class_category = 'CLASS_CATEGORY_GROUP'
    AND ca.class_code = :1
    AND NVL (ca.status, 'A') = 'A'
    AND SYSDATE BETWEEN ca.start_date_active AND NVL (ca.end_date_active, SYSDATE + 1))
    UNION ALL
    SELECT cc.class_category
    ,l.meaning
    FROM hz_class_categories cc
    ,fnd_lookup_types_vl l
    WHERE cc.class_category = l.lookup_type
    AND l.view_application_id = 222
    AND 'INDUSTRIAL_GROUP' <> :2
    AND NOT EXISTS (
    SELECT NULL
    FROM hz_code_assignments ca
    WHERE ca.owner_table_name = 'HZ_CLASS_CATEGORIES'
    AND ca.owner_table_id IS NULL
    AND ca.owner_table_key_1 = cc.class_category
    AND ca.class_category = 'CLASS_CATEGORY_GROUP'
    AND NVL (ca.status, 'A') = 'A'
    AND SYSDATE BETWEEN ca.start_date_active AND NVL (ca.end_date_active, SYSDATE + 1))
    AND hz_classification_v2pub.is_valid_category ('HZ_PARTIES'
    ,cc.class_category
    ,:3) = 'T') a
    WHERE EXISTS (
    SELECT NULL
    FROM hz_class_code_denorm
    WHERE class_category = a.class_category
    AND TRUNC (SYSDATE) BETWEEN NVL (start_date_active, TRUNC (SYSDATE)) AND NVL (end_date_active, TRUNC (SYSDATE))
    AND enabled_flag = 'Y'
    AND LANGUAGE = USERENV ('LANG'))) qrslt
    A similar error was discussed at this link but it did not give final solution
    [http://kr.forums.oracle.com/forums/thread.jspa?threadID=618451]
    help me to solve this issue..
    Thanks,
    Varun
    Edited by: user10707840 on May 19, 2009 7:18 AM

    its not the AM code .. its the code in VOImpl...
    the same code is working in 11i but when its migrated to R12 its giving this error..
    The original seeded VO query in 11i contains the same bind variable :1 at three places
    SELECT * FROM (select class_category, meaning from hz_class_categories, fnd_lookup_types_vl l where hz_class_categories.class_category = l.lookup_type and l.view_application_id = 222 and class_category in (select owner_table_key_1 from hz_code_assignments ca where ca.owner_table_name = 'HZ_CLASS_CATEGORIES' and ca.owner_table_id is null and ca.class_category = 'CLASS_CATEGORY_GROUP' and ca.class_code = :1 and nvl(ca.status, 'A') = 'A' and sysdate between ca.start_date_active and nvl(ca.end_date_active, sysdate+1)) union all select cc.class_category , meaning from hz_class_categories cc, fnd_lookup_types_vl l, hz_class_category_uses cu where cc.CLASS_CATEGORY = cu.class_category AND ( UPPER(CU.ADDITIONAL_WHERE_CLAUSE) LIKE decode(:1, 'ORG_GROUP','%PARTY_TYPE%ORGANIZATION%', 'PERSON_GROUP', '%PARTY_TYPE%PERSON%', '%') or CU.ADDITIONAL_WHERE_CLAUSE IS NULL or UPPER(CU.ADDITIONAL_WHERE_CLAUSE) LIKE '%WHERE 1=1%' ) and cu.owner_table = 'HZ_PARTIES' and cc.class_category = l.lookup_type and l.view_application_id = 222 and cc.class_category not in (select owner_table_key_1 from hz_code_assignments hca where hca.owner_table_name = 'HZ_CLASS_CATEGORIES' and hca.owner_table_id is null and hca.class_category = 'CLASS_CATEGORY_GROUP' and nvl(hca.status, 'A') = 'A' and sysdate between hca.start_date_active and nvl(hca.end_date_active, sysdate+1)) and cc.class_category not in ( 'RELATIONSHIP_TYPE_GROUP', 'CLASS_CATEGORY_GROUP') and 'INDUSTRIAL_GROUP' <> :1) QRSLT ORDER BY meaning
    the code working in 11i had only one setWhereClauseParam line i.e. setWhereClauseParam(0, classCode);
    when i ran the same code in R12 it errd out..
    I checked the original R12 query... it has 3 bind variables :1 , :2 and :3 ... so i added 2 more setWhereClauseParam statements
    setWhereClauseParam(1, classCode);
    setWhereClauseParam(2, partyId);
    but still its giving the same error
    ORIGINAL R12 query already posted above...

  • How to populate bind variable in view objects where clause in ADF faces

    I've got a page with 2 input items.
    The user manually enters the first value.
    On the second input item I have created a LOV for the item which opens in a popup. How do I restrict the data returned in the LOV using the value entered in the first input item. I have created a bind variable and have included it in the where clause for the view object but how do I populated it.

    Here is an example:
    Using the HR schema with the EMPLOYEES and DEPARTMENTS tables.
    Example is using ADF BC and created an EMPLOYEES entity with an updateable view object for page,
    and created a DEPARTMENTS view as a lookup
    (SQL: select department_id, department_name from departments where department_name = :DeptName)
    1: add method to the backing bean to filter the LOV
    public void getTextValueToFilterLOV(ValueChangeEvent valueChangeEvent) {
    Object value_from_form = valueChangeEvent.getNewValue();
    FacesContext fctx = FacesContext.getCurrentInstance();
    Application fapp = fctx.getApplication();
    JUFormBinding formBinding = (JUFormBinding)fapp.createValueBinding("#{bindings}").getValue(fctx);
    DCIteratorBinding dcBinding = (DCIteratorBinding)formBinding.get("DeptLOVIterator");
    ViewObject vo = dcBinding.getViewObject();
    vo.setNamedWhereClauseParam("DeptName",value_from_form);
    vo.executeQuery();
    2. add valueChangeListener to the inputText on the page with an id and autoSubmit="true"
    <af:inputText value="#{bindings.LastName.inputValue}" label="#{bindings.LastName.label}" binding="#{backing_DeptForm.inputText3}"
    id="inputText3"
    autoSubmit="true"
    valueChangeListener="#{backing_DeptForm.getTextValueToFilterLOV}">
    </af:inputText>
    3. reference the LOV with the id name on the partialTriggers property
    <af:selectOneChoice value="#{bindings.EmployeesUpdView1DepartmentId.inputValue}"
    label="#{bindings.EmployeesUpdView1DepartmentId.label}" binding="#{backing_DeptForm.selectOneChoice1}"
    id="selectOneChoice1"
    partialTriggers="inputText3">
    <f:selectItems value="#{bindings.EmployeesUpdView1DepartmentId.items}"
    binding="#{backing_DeptForm.selectItems1}"
    id="selectItems1"/>
    </af:selectOneChoice>
    Summary:
    When you entered a text (LastName), that value is passed into the backing bean method.
    The Bean method code will find the LOV Iterator and put the value into the bind variable.
    Cheers,
    Jim

  • VO - bind variable in where clause problem

    Hi
    I have Jdeveloper 12. I successfully connected to mySQL database which works in Oracle mode (PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, NO_KEY_OPTIONS, NO_TABLE_OPTIONS, NO_FIELD_OPTIONS, NO_AUTO_CREATE_USER)
    Next I created EO, VO (screenshot) and finally AM.
    when I run Application Module and enter bind variable value I receive error (screenshot):
    oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation.  Statement: SELECT EO_TMP.create_date,         EO_TMP.id,         EO_TMP.name FROM autoid.advert EO_TMP WHERE EO_TMP.id = :var1
    ## Detail 0 ##
    java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
    Doesn anybody know hot to fix this issue?
    Regards.

    I decided to check if it is a mySQL driver so I've performed the same query using a below code and it works. This is definitely model configuration issue.
    Connection con = null;
    try{
    Class.forName( "com.mysql.jdbc.Driver" ).newInstance();
    con = DriverManager.getConnection("jdbc:mysql://localhost/sakila?user=root&password=1qaz2wsx");
    String selectSQL = "SELECT actor_id,first_name,last_name,last_update FROM actor WHERE actor_id = ?";
    PreparedStatement preparedStatement = con.prepareStatement(selectSQL);
    preparedStatement.setInt(1, 4);
    ResultSet rs = preparedStatement.executeQuery();
    while (rs.next()) {
    String userid = rs.getString("ACTOR_ID");
    String username = rs.getString("FIRST_NAME"); 
    System.out.println(userid); 
    System.out.println(username); 
    }catch (Exception e){
    System.out.println(e.toString());  

  • Request for "WHERE  -   IN" Combination with Bind Variables.

    Hi,
    In ADF BC
    Im Creating the Bind Variables Searching methodolgy in ViewObject.
    SQL Editor:
    Query Like
    SELECT * FROM SEASON season WHERE season.MMYEAR IN (102007,112007) Here Done this query.
    In ViewObject Bind Variable Like B_MMYear .
    SQL Statement : SELECT season.Code,season.Location,season.MMYEAR FROM SEASON season already is there in SQL Statement in ViewObject
    Just im adding this conditon "WHERE season.MMYEAR IN (:B_MMYear)"
    after
    Drag&drop the ExecutewithParams form
    and im giving the MMYear like *102007,112008* then push ExecutewithParams....no Rows to Display...
    when im giving the only one vlaue like 102007 (Or ) 112007 then displays the suitable Row.
    how i can give the query Like "WHERE - IN" Combination in Bind Variables.
    Thanks,
    Rama.
    Edited by: user634195 on Oct 17, 2008 6:37 AM

    Thanks for rply Mr Timo.
    my BindVariable is not Numeric Type...it as a String. ok
    i already checks the debugging
    but i didn't get Exact Query
    query seems without Values same As SQL Statement in ViewOBject.
    like this
    SELECT season.Code,season.Location,season.MMYEAR FROM SEASON season WHERE season.MMYEAR IN (:B_MMYear)
    you Know...India Season of the Culture....
    see.
    In India Colture have Two Seasions
    1.Rabi.
    2.Kharif.
    example:
    Present Year : 2008 ok
    Rabi Season Strats from Oct2008 to March2009.
    Kharif Season Starts from Apr2008 to Sep2008.
    ok
    In my JSP Page one DropDown is there that is Season ok.
    when i select the Rabi....Then Rabi Months comes to page in CoreTable.
    i already done in DB:
    For Rabi:
    SELECT season.Code,season.Location,season.MMYEAR FROM SEASON season WHERE season.MMYEAR IN (10,11,12,01,02,03) done.
    For Kharif:
    SELECT season.Code,season.Location,season.MMYEAR FROM SEASON season WHERE season.MMYEAR IN (04,05,06,07,08,09) also done.
    the realtion b/w Bind Variable and Value....i think is somethink diff.
    Edited by: user634195 on Oct 17, 2008 7:50 AM

  • [Solved] Named Bind Variables at Runtime - SQL WHERE clause issue

    Hey 'all,
    I've been having this issue today with a Search page using Named Bind Variables at Runtime for the search parameters for the WHERE clause in the view objects SQL.
    I've got everything working except for a clearing method which I've created so that the user can clear the current WHERE clause from the SQL statment and set it as 1=2 (so that it doesn't do a blind query on load).
    The method can clear and set the WHERE clause to 1=2 only when there is already one there.
    Below are the methods: (located in my view object class)
    public void findInvoiceById(Number invoiceId){
        setWhereClause("invoice_id = :P_INVOICE_ID");
        defineNamedWhereClauseParam("P_INVOICE_ID",null,null);
        setNamedWhereClauseParam("P_INVOICE_ID",invoiceId);
        executeQuery();
    public void clearCriteria(){
        setWhereClause("1=2");
        removeNamedWhereClauseParam("P_INVOICE_ID");
        executeQuery();
    }The error which I get is the following - this happens when the button is pressed twice in a row, or when no query has been passed previously.
    1. JBO-29000: Unexpected exception caught: oracle.jbo.NoDefException, msg=JBO-25058: Definition P_INVOICE_ID of type Variable not found in SupplierInvoicesView1
    2. JBO-25058: Definition P_INVOICE_ID of type Variable not found in SupplierInvoicesView1
    Any help with this would be greatly appreciated!
    Cheers,

    Hi Bonnie,
    we have it working ok, but still feel that there is room for improvement in the design.
    For us the key factors are:
    Pages based on the same view object that can be queried multiple ways.
    We don't want to put design time bind variables in because it limits the use of the VO
    We don't wan't multiple VO's with different where clauses.
    The page is displaying the same table columns and fields, but the where clause must be dynamic.
    We only want to query on the search field entered (some of our tables are massive)
    TopLink named queries are really what we are after, but we don't want to forgo all the other ADF BC functionality. The only examples of ViewCriteria in the developer guide had literals in the where clause and no bind variables. The View Criteria may still be an option, but it appeared quite complex compaired to directly adding and removing bind variables at runtime.
    a couple of footnotes:
    the following methods are used to clear the runtime variables prior to reusing the VO (thanks to John Stegman for the pointer on the exception handler):
        public void clearBindVariable(String bindVariableName){
            try
                removeNamedWhereClauseParam(bindVariableName);
            catch (NoDefException e)
        public void clearBindVariables(){
            clearBindVariable("P_INVOICE_ID");
            clearBindVariable("P_INVOICE_NUM");
            clearBindVariable("P_SUPPLIER_NAME");
            clearBindVariable("P_INVOICE_DATE_FROM");
            clearBindVariable("P_INVOICE_DATE_TO");
            clearBindVariable("P_SUPPLIER_NUMBER");
        }We are using 1=1 and 1=2 in the where clause to supress blind querying. 1=2 is applied when ever we are not explicitely searching for something. We had a problem with using the refresh condition ${adfFacesContext.postback == true} which I posted about here:
    executeQuery called twice using ${adfFacesContext.postback == true}
    Would still gladly hear other ideas on a better reuse design.
    regards,
    Brenden

  • How to use sql "IN" operator with named bind variable in where clause ?

    Can one bind variable be used for the "IN" list ('1','2','3') ?

    rob,
    No worries. Glad it helped. Glad to see also that you're doing things right and trying to use bind variables ;)
    May I suggest adding "SOLVED" to the title of the original post?
    Best,
    John

  • How to override the where clause (Bind Variables) in Backing Bean.

    HI
    I am using bind variables in VO and using exeutewithparam to pass the values to bind. Which is working fine.
    But what i want now to override the values pro grammatically from backing_bean of that page.
    How can i pass the values to bind variables from bean.
    M Niaz.

    Hi
    Try this if it works. this is from 10g
    1)create value binding in the backing bean on any action
    FacesContext ctx=FacesContext.getCurrentInstance();
    ValueBinding vb= ctx.getApplication().createValueBinding("#{bindings['account_name1'].inputValue}");
    2) and then set the value for binding
    vb.setValue(ctx,(String)accountInput.getValue());
    Now execute the method with method binding and execute it
    ctx.getApplication().createMethodBinding("#{bindings.ExecuteWithParams.execute}",null).invoke(ctx,null);
    Regards
    Rohit

  • Report Performance with Bind Variable

    Getting some very odd behaviour with a report in APEX v 3.2.1.00.10
    I have a complex query that takes 5 seconds to return via TOAD, but takes from 5 to 10 minutes in an APEX report.
    I've narrowed it down to one particular bind. If I hard code the date in it returns in 6 seconds, but if I let the date be passed in from a parameter it takes 5+ minutes again.
    Relevant part of the query (an inline view) is:
    ,(select rglr_lect lect
    ,sum(tpm) mtr_tpm
    ,sum(enrols) mtr_enrols
    from ops_dash_meetings_report
    where meet_ev_date between to_date(:P35_END_DATE,'DD/MM/YYYY') - 363 and to_date(:P35_END_DATE,'DD/MM/YYYY')
    group by rglr_lect) RPV
    I've tried replacing the "to_date(:P35_END_DATE,'DD/MM/YYYY') - 363" with another item which is populated with the date required (and verified by checking session state). If I replace the :P35_END_DATE with an actual date the performance is fine again.
    The weird thing is that a trace file shows me exactly the same Explain Plan as the TOAD Explain where it runs in 5 seconds.
    Another odd thing is that another page in my application has the same inline view and doesn't hit the performance problem.
    The trace file did show some control characters (circumflex M) after each line of this report's query where these weren't anywhere else on the trace queries. I wondered if there was some sort of corruption in the source?
    No problems due to pagination as the result set is only 31 records and all being displayed.
    Really stumped here. Any advice or pointers would be most welcome.
    Jon.

    Don't worry about the Time column, the cost and cardinality are more important to see whther the CBO is making different decisions for whatever reason.
    Remember that the explain plan shows the expected execution plan and a trace shows the actual execution plan. So what you want to do is compare the query with bind variables from an APEX page trace to a trace from TOAD (or sqlplus or whatever). You can do this outside APEX like this...
    ALTER SESSION SET EVENTS '10046 trace name context forever, level 1';Enter and run your SQL statement...;
    ALTER SESSION SET sql_trace=FALSE;This will create a a trace file in the directory returned by...
    SELECT value FROM v$parameter WHERE name = 'user_dump_dest' Which you can use tkprof to format.
    I am assuming that your not going over DB links or anything else slightly unusual?
    Cheers
    Ben

  • How to Dene a Data Link Between Queries: Bind Variables

    This is an interesting topic and I cannot get it to work using Bind Variables.
    I have 2 queries: Q1 and Q2. Q2 needs c_id, account_code and account_type from Q1.
    Whe I run the data template below, I get only the data for Q1.
    Now people may argue that there is no data in Q2 for the relevant clause. So if I even remove the where clause in Q2 I still get no joy i.e Data appears for Q1 but not for Q2
    <dataTemplate name="FLCMR519_DATA_SET" description="Termination Quote Report">
         <parameters>
              <parameter name="cid" dataType="number" defaultValue="1"/>
              <parameter name="p_cln_id" dataType="number" defaultValue="62412"/>
         </parameters>
         <dataQuery>
              <sqlStatement name="Q1">
                   <![CDATA[SELECT qm.qmd_id,
    qm.contract_period,
    qm.quo_quo_id||'/'||qm.quote_no||'/'||qm.revision_no reference_no,
    qm.contract_distance,
    qm.mdl_mdl_id,
    q.qpr_qpr_id,
    q.quo_id,
    q.drv_drv_id,
    qm.revision_user username,
    pb.first_name||' '||pb.last_name op_name,
    pb.telephone_no,
    pb.facsimile_no,
    pb.email,
    q.c_id c_id,
    q.account_type account_type,
    q.account_code account_code,
    m.model_desc,
    ph.payment_description payment_head_desc,
    cl.fms_fms_id,
    cl.start_date,
    cl.end_date,
    cl.actual_end_date,
    cl.con_con_id,
    cl.cln_id,
    cl.term_qmd_id term_qmd_id,
    qm2.contract_period term_period,
    qm2.contract_distance term_distance
    FROM quotations q,
               quotation_models qm,
               contract_lines cl,
               personnel_base pb,
               models m,
               model_types mt,
               payment_headers ph,
               quotation_models qm2
    WHERE q.quo_id = qm.quo_quo_id
           AND cl.cln_id = :p_cln_id
           AND qm.qmd_id = cl.qmd_qmd_id
           AND qm2.revision_user = pb.employee_no (+)
           AND qm.mdl_mdl_id = m.mdl_id
           AND m.mtp_mtp_id = mt.mtp_id
           AND qm.payment_id = ph.payment_header_id
           AND qm2.qmd_id (+) = cl.term_qmd_id
    ]]>
              </sqlStatement>
              <sqlStatement name="Q2">
                   <![CDATA[SELECT ea.c_id,                  ea.account_type,ea.account_code,ea.account_name
    FROM external_accounts ea
                 WHERE ea.c_id = :c_id
                   AND ea.account_type = :account_type
                   AND ea.account_code = :account_code
    ]]>
              </sqlStatement>
         </dataQuery>
    </dataTemplate>

    Defining dataStructure section is mandatory for multiple queries.

  • Can I use bind variable instaed of writing static COLUMN Name

    Hi , I am having a table containing id and column names, the data is stored against that id in other tables. Now I wish to update data into another table so that it goes into apppropriate column without using decode function.
    I am trying to do this:
    EXECUTE IMMEDIATE 'update TEST set :1 = :2
    where PROJECT_ID= :3 and UNIQUE_ID= :4' using P_DEST_COLUMN, P_TEXT_VALUE, P_PROJ_ID, P_TASK_UID;
    the values P_DEST_COLUMN, P_TEXT_VALUE, P_PROJ_ID, P_TASK_UID are populated using a cursor in PL/SQl
    Is this statement valid? If not can you tell me how to do it as I am getting some error I am unable to comprehend.
    thanks
    Rishabh

    Column names cannot be substituted at run-time as bind variables. If you need to specify the column name at run-time, you'd need to construct a new string and execute that string dynamically, i.e.
    EXECUTE IMMEDIATE 'UPDATE test SET ' || p_dest_column || ' = :1 ' || ...From a data model standpoint, storing column names as data elements in another table is generally a rather poor idea. It's likely to make ad-hoc reporting nearly impossible and to cause a lot more parsing than would otherwise be required.
    Justin

Maybe you are looking for

  • How can i use labview for communicating with pic18 microcontroller through usb port?

    Hi all, I want to make a DAQ card using pic 18 microcontroller which has a built-in usb protocol. I have the firmware of this controller which will  make it as a usb device. How can i receive the analog voltages from this DAQ card in Labview? or i me

  • Can anyone explain this logic?

    Totally been pulling my hair out over this over the past few nights... I have a flash file that has 101 frames. Frame 1 is a navigation page that does a _root.gotoAndStop(x); on 100 buttons. Each of the 100 frames there after have between 50 and 100

  • IPod Classic Failing To Recover From Reset

    Hi folks Anyone else seen this? My new 160Gb classic (purchased new last month) behaves a bit differently to my old one (old 160gb from '07). It doesn't 'freeze' very often, but when it does, resetting does not solve the problem- it doesn't reboot, s

  • Upgrading from PSE 9 to 12

    I tried to do this several times but each time it failed. When I checked my account it said that "It may take 24 hours for my order to be processed. Is this the reason why my download failed?

  • Dehydration Store Table

    Hi, I want to calculate time taken by service to give back response from dehydration tables or any other database tables of soa. Does any  one have idea on that. ??