Bind Variables in SQL Statement

can someone tell me if there is a way to find out what the bind variables values are in an sql statement extracted from any of the v$sql or v$sqlarea type tables ?
sql example:
update DTree set OriginOwnerID=:A
where OriginOwnerID=:B and OriginDataID=:C
Thanks
Jim

Hi damorgan
i see two ot of the three:
SQL> desc gv$sql_bind_capture
ERROR:
ORA-04043: object gv$sql_bind_capture does not exist
i just trying to see what bind variable values would be associated with the sql when i extract the sql from v$sql and if that is even possible
Thanks
Jim

Similar Messages

  • Using bind variables with sql statements

    We connect from a VB 6.0 program via OO4O to an Oracle 8.1.7 database, using bind variables in connection with select statements. Running ok, but performance again by using bind vars not as good as expected!
    When looking into the table v$sqlarea, we were able to detect the reason. We expected that our program submits the sql statement with bind vars, Oracle parses this once, and with each select statement again, we do not have a reparse. But: It seems that with each new session Oracle reparses the sql statement, that is, Oracle is not able to memorize or cache bind vars and statements. Even more worrying, this kind of behaviour was visible with each new dynaset, but the same database/session.
    Is there anybody our there with an idea of what is happening here?
    Code snippet:
    Dim OraSession As OracleInProcServer.OraSessionClass
    Dim OraDatabase As OracleInProcServer.OraDatabase
    Set OraSession = CreateObject("OracleInProcServer.XOraSession")
    Set OraDatabase = OraSession.OpenDatabase(my database", "my connect", 0&)
    OraDatabase.Parameters.Add "my_bind", 0, ORAPARM_INPUT
    OraDatabase.Parameters("my_bind").DynasetOption = ORADYN_NOCACHE
    OraDatabase.Parameters("my_bind").serverType = ORATYPE_NUMBER ' Bind Var Type
    Dim RS As OracleInProcServer.OraDynaset
    strSQLstatement= "Select * from my_table where igz= [my_bind] "
    Set RS = OraDatabase.CreateDynaset(strSQLstatement, &H4)
    OraDatabase.Parameters("my_bind").Value = myValue
    RS.Refresh
    Cheers and thanks a lot :)
    Michael Sonntag

    We connect from a VB 6.0 program via OO4O to an Oracle 8.1.7 database, using bind variables in connection with select statements. Running ok, but performance again by using bind vars not as good as expected!
    When looking into the table v$sqlarea, we were able to detect the reason. We expected that our program submits the sql statement with bind vars, Oracle parses this once, and with each select statement again, we do not have a reparse. But: It seems that with each new session Oracle reparses the sql statement, that is, Oracle is not able to memorize or cache bind vars and statements. Even more worrying, this kind of behaviour was visible with each new dynaset, but the same database/session.
    Is there anybody our there with an idea of what is happening here?
    Code snippet:
    Dim OraSession As OracleInProcServer.OraSessionClass
    Dim OraDatabase As OracleInProcServer.OraDatabase
    Set OraSession = CreateObject("OracleInProcServer.XOraSession")
    Set OraDatabase = OraSession.OpenDatabase(my database", "my connect", 0&)
    OraDatabase.Parameters.Add "my_bind", 0, ORAPARM_INPUT
    OraDatabase.Parameters("my_bind").DynasetOption = ORADYN_NOCACHE
    OraDatabase.Parameters("my_bind").serverType = ORATYPE_NUMBER ' Bind Var Type
    Dim RS As OracleInProcServer.OraDynaset
    strSQLstatement= "Select * from my_table where igz= [my_bind] "
    Set RS = OraDatabase.CreateDynaset(strSQLstatement, &H4)
    OraDatabase.Parameters("my_bind").Value = myValue
    RS.Refresh
    Cheers and thanks a lot :)
    Michael Sonntag

  • ADF jdev10: SQL TRUNC with bind variable in sql statement in VO

    Hi,
    In VO in where clause:
    TRUNC(ServiceRequest.REQUEST_DATE) > :MyDate works fine!
    But TRUNC(ServiceRequest.REQUEST_DATE) > TRUNC(:MyDate) doesn't work!
    "SQL Query Error Message: ORA-00932: inconsistient datatypes: expected DATE got NUMBER"
    How to use TRUNC function for a bind variable?

    Basementjack,
    Any of these solutions that you are doing have possible performance implications in the database side, as you are applying a function to a database column; this is generally going to preclude the use of an index.
    Assuming that you are trying to find service requests that were before the date that is being passed in in the bind variable, and assuming that both the bind variable and service request date can have time components, you could try:
    ServiceRequest.REQUEST_DATE <= TO_DATE(trunc(:MyDate) - 1/86400)Does this do what you want?
    John

  • Bind Variable in SELECT statement and get the value  in PL/SQL block

    Hi All,
    I would like  pass bind variable in SELECT statement and get the value of the column in Dynamic SQL
    Please seee below
    I want to get the below value
    Expected result:
    select  distinct empno ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    100, HR
    select  distinct ename ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    TEST, HR
    select  distinct loc ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    NYC, HR
    Using the below block I am getting column names only not the value of the column. I need to pass that value(TEST,NYC..) into l_col_val variable
    Please suggest
    ----- TABLE LIST
    CREATE TABLE EMP(
    EMPNO NUMBER,
    ENAME VARCHAR2(255),
    DEPT VARCHAR2(255),
    LOC    VARCHAR2(255)
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (100,'TEST','HR','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (200,'TEST1','IT','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (300,'TEST2','MR','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (400,'TEST3','HR','DTR');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (500,'TEST4','HR','DAL');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (600,'TEST5','IT','ATL');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (700,'TEST6','IT','BOS');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (800,'TEST7','HR','NYC');
    COMMIT;
    CREATE TABLE COLUMNAMES(
    COLUMNAME VARCHAR2(255)
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('EMPNO');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('ENAME');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('DEPT');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('LOC');
    COMMIT;
    CREATE TABLE DEPT(
    DEPT VARCHAR2(255),
    DNAME VARCHAR2(255)
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('HR','HUMAN RESOURCE');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('MR','MARKETING');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
    COMMIT;
    PL/SQL BLOCK
    DECLARE
      TYPE EMPCurTyp  IS REF CURSOR;
      v_EMP_cursor    EMPCurTyp;
      l_col_val           EMP.ENAME%type;
      l_ENAME_val       EMP.ENAME%type;
    l_col_ddl varchar2(4000);
    l_col_name varchar2(60);
    l_tab_name varchar2(60);
    l_empno number ;
    b_l_col_name VARCHAR2(255);
    b_l_empno NUMBER;
    begin
    for rec00 in (
    select EMPNO aa from  EMP
    loop
    l_empno := rec00.aa;
    for rec in (select COLUMNAME as column_name  from  columnames
    loop
    l_col_name := rec.column_name;
    begin
      l_col_val :=null;
       l_col_ddl := 'select  distinct :b_l_col_name ,pr.dept ' ||'  from emp pr, dept ps where   ps.dept like ''%IT'' '||' and pr.empno =:b_l_empno';
       dbms_output.put_line('DDL ...'||l_col_ddl);
       OPEN v_EMP_cursor FOR l_col_ddl USING l_col_name, l_empno;
    LOOP
        l_col_val :=null;
        FETCH v_EMP_cursor INTO l_col_val,l_ename_val;
        EXIT WHEN v_EMP_cursor%NOTFOUND;
          dbms_output.put_line('l_col_name='||l_col_name ||'  empno ='||l_empno);
       END LOOP;
    CLOSE v_EMP_cursor;
    END;
    END LOOP;
    END LOOP;
    END;

    user1758353 wrote:
    Thanks Billy, Would you be able to suggest any other faster method to load the data into table. Thanks,
    As Mark responded - it all depends on the actual data to load, structure and source/origin. On my busiest database, I am loading on average 30,000 rows every second from data in external files.
    However, the data structures are just that - structured. Logical.
    Having a data structure with 100's of fields (columns in a SQL table), raise all kinds of questions about how sane that structure is, and what impact it will have on a physical data model implementation.
    There is a gross misunderstanding by many when it comes to performance and scalability. The prime factor that determines performance is not how well you code, what tools/language you use, the h/w your c ode runs on, or anything like that. The prime factor that determines perform is the design of the data model - as it determines the complexity/ease to use the data model, and the amount of I/O (the slowest of all db operations) needed to effectively use the data model.

  • Using Bind variables in SQL PLUS Report

    using Bind variables in SQL PLUS Report. This report gets the arguments from the application concurrent program. Now my need is to convert the start_date and end_date to bind Variables to improve the performance. I have commented the original code in 'prompt List of Unapproved Adjustments' and used my Bind Variable but it is giving an error
    error: Bind Variable "ENDING_DATE" not declared
    Report Date and Time:
    26-OCT-2010 15:44:13
    List of Unapproved Adjustments
    Bind Variable 'ENDING_DATE" not declared
    Please see below the code for the sql plus report:
    define p_org_id           = '&1'
    define p_fy_begin_date = '&2'
    define p_start_date = '&3'
    define p_end_date = '&4'
    define p_conversion = '&5'
    declare
    variable begin_date date;
    exec :begin_date := p_start_date;
    variable ending_date date;
    exec :ending_date := p_end_date;
    /* Begin
    :begin_date := to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS');
    :ending_date := to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS');
    End; */
    set newpage none
    set termout off
    set pagesize 55
    set linesize 180
    set heading on
    set feedback off
    set wrap off
    set space 1
    set heading on
    begin
    dbms_application_info.set_client_info('&p_org_id');
    end;
    prompt
    prompt Report Date and Time:
    prompt ----------------------
    select to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')
    from dual ;
    prompt
    prompt List of Unapproved Adjustments
    prompt -------------------------------
    select b.trx_number,
    a.adjustment_number,
    f.user_name created_by
    from apps.ar_adjustments a,
    apps.ra_customer_trx b,
    apps.fnd_user f
    where a.customer_trx_id = b.customer_trx_id
    and a.status <> 'A'
    and a.created_by = f.user_id
    and a.creation_date between :begin_date
    and :ending_date
    -- and a.creation_Date between to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS')
    -- and to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS')
    order by
    b.trx_number ;

    Hi
    Please go to customization part of the report and verify..You have set a default value out there ..And also verify your lov and look at the values ..If it is again giving you the problem ..pl delete the report and develop it again from the scratch it will be solved...
    vishnu
    null

  • Passing values in a vector list as bind variables in sql query.

    Hi,
    I have a vector list containing values 12,13,14.
    vector<string> v;
    v has values 12,13 and 14.
    Here the number of values in vector list are not fixed.
    I want to pass these values as bind variables to sql query.
    Can anyone suggest me how to do this.
    Thanks in advance!!

    Ah, the it's the classic 'Varying In-List' again
    See:
    The Tom Kyte Blog: Varying in lists...
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:110612348061 (started more than a decade ago, so scroll down for more recent examples)

  • Bind variables in SQL query of DBAdapter

    Hi,
    Can we add bind variables to SQL query when we define DB adapter...?

    No, not in the Wizard.
    I do not know if it is possible with the TopLink in combination with BPEL.
    But can you use a Pl/SQL procudere/package that performs the dynamic SQL?

  • Got an error while creating bind variables using sql database.

    iam going to use sql database for ADF-BC .
    i created the bind variable and apply the bind position for the corresponding variable in the view object editor.when i click test it shows me "query is valid". when i tried to run that it gives me two errors.
    1) sql error during statement preparation.(ie) select empid ,empname......from the emptable where empid like :'emp' and
    2) [Microsoft][SQl server  2000 driver  for jDBC] invalid parameter bindings
    i need help to know the solution for this...(or) is there any other way to create bind variable ......

    The 3 binding styles supported by JDev:
    Oracle Named - ie. SELECT xxxx FROM xxxx WHERE emp_id = :vEmp (note colon and variable name)
    Oracle Positional - ie SELECT xxxx FROM xxxx WHERE emp_id = :1 (note colon)
    JDBC Positional - ie SELECT xxxx FROM xxxx WHERE emp_id = ?
    Literally this query is sent to the database to execute, then the bind variables values are applied as a separate database operation. If SQL Server doesn't suport any of these binding styles, it's not going to work. As Chris Noonan suggests, try the JDBC Positional style though as you're using a JDBC driver to connect to SQL Server and it should support that style (the others are Oracle styles), and make sure you've switched the binding style on the VO query page to "JDBC Positional" too.
    You must also on the VO bind variable page define your bind variables.
    Also read the 10.1.3 JDev guide on ADF Business Components and View Object bind variables.
    CM.

  • Decode using bind variable in SQL

    I have decode statement in my SQL query which is used to define the VO object. I want to select a column depending on the value entered for the bind variable :1. dont know how to implement this in OAF - any pointers will be appreciated.
    decode(:1,'XO2C_CUST_SERV_REP',XO2C_CUST_SERV_REP,'XO2C_ACCOUNT_MGR',XO2C_ACCOUNT_MGR,'XO2C_CTS_ENGINEER',XO2C_CTS_ENGINEER ) "contact names"
    Thanks!!

    I have decode statement in my sql for the VO and the VO is executed when the user clicks the GO button(user initiated search and over-riding the default Go button).
    When I click the Go button , I am calling a method called Uneditable in my AM which appends the decode variable using the whereclause append but it is failing with an exception "java.sql.SQLException: Missing IN or OUT parameter at index:: 1". Can someone let me know if I am doing anything indifferently which is causing the program/sql query to fail.
    Binding style of the VO is "Oracle Named" - is this causing the problem?
    ProcessFormRequest:
    =============
    if ("ClickGo".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    System.out.println("Go Button pressed>> "+am);
    OATableBean table = (OATableBean) webBean.findChildRecursive("USSContactMainVO1");
    System.out.println("before QueryData");
    //table.queryData(pageContext,false);
    System.out.println("before Boolean executeQry");
    Boolean executeQuery = BooleanUtils.getBoolean(false);
    System.out.println("Get PartyName");
    String v_PartyName = pageContext.getParameter("xxPartyName");
    System.out.println("Get SalesContactQry");
    String v_SalesContact = pageContext.getParameter("SalesContact_qry");
    System.out.println("Party Name :" + v_PartyName + " Sales contact:" + v_SalesContact);
    Serializable[] parameters = {v_PartyName, v_SalesContact,executeQuery };
    Class[] paramTypes = { String.class, String.class, Boolean.class };
    am.invokeMethod("uneditable",parameters,paramTypes);
    Uneditable(AM)
    =========
    public void uneditable(String v_PartyName, String v_SalesContact,
    Boolean executeQuery){
    System.out.println("Im in uneditable..to call VO");
    USSContactMainVOImpl vo1= getUSSContactMainVO1();
    String Voqry =vo1.getQuery();
    //System.out.println("Query is :"+ Voqry);
    StringBuffer whereClause = new StringBuffer(100);
    Vector parameters = new Vector(3);
    int clauseCount = 0;
    int bindCount = 0;
    System.out.println("debug1");
    vo1.setWhereClauseParams(null); // Always reset
    System.out.println("check the params");
    if ((v_SalesContact != null) && (!("".equals(v_SalesContact.trim()))))
    System.out.println("Sales:"+v_SalesContact);
    whereClause.append(v_SalesContact);
    System.out.println("bindcount");
    whereClause.append(++bindCount);
    clauseCount++;
    System.out.println("setWhereclas");
    vo1.setWhereClause(whereClause.toString());
    System.out.println("setWhereclasParam");
    vo1.setWhereClauseParams(null);
    System.out.println("setWhereclasParam-2");
    vo1.setWhereClauseParam(0,v_SalesContact);
    if ((v_PartyName != null) && (!("".equals(v_PartyName.trim()))))
    whereClause.append(" Party_Name like :");
    whereClause.append(++bindCount);
    clauseCount++;
    vo1.setWhereClause(whereClause.toString());
    vo1.setWhereClauseParams(null);
    //vo1.setWhereClauseParam(0,v_PartyName);
    vo1.setWhereClauseParam(1,v_PartyName);
    System.out.println("Query is :" + vo1.getQuery()); //prints this debug msg but fails while executnig the vo
    vo1.executeQuery();
    Row[] rows1=vo1.getAllRowsInRange();
    USSContactMainVORowImpl row = null;
    for (int i = 0; i < rows1.length; i++)
    System.out.println(" Rows Found "+i);
    row = (USSContactMainVORowImpl)rows1;
    row.setAttribute("CTSEngineer_TR",Boolean.FALSE);
    //end of uneditable
    It appends the 2nd parameter and prints System.out.println("Query is :" + vo1.getQuery()) without any issues but think fails when trying to execute the VO.
    Error Stack :
    =======
    oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (SELECT hp.party_name,hp.party_number registry_id, hps.party_site_number Site_Number, hca.account_number,
    hca.account_name acc_desc,
    hl.address1
    || ''
    || hl.city
    || ''
    || hl.postal_code
    || ''
    || hl.state "Address",
    xagv.xo2c_entering_unit "Entering_Unit",
    DECODE(hou.Short_code,'USS CA OU','CA','USS USA OU','US') "Operating_Unit",DECODE('.',null,null) "CTS", DECODE(:1,'Customer Service Rep',XO2C_CUST_SERV_REP,'Account Manager',XO2C_ACCOUNT_MGR,'CTS Engineer',XO2C_CTS_ENGINEER ) "Contact Names" FROM hz_parties hp,
    hz_party_sites hps,
    hz_cust_accounts hca,
    hz_cust_acct_sites_all hcs,
    hz_locations hl,
    xo2c_ship_to_sales_o_agv xagv,
    hr_operating_units hou
    WHERE 1 = 1
    AND hp.party_id = hps.party_id
    AND hp.party_id = hca.party_id
    AND hcs.party_site_id = hps.party_site_id
    AND hca.cust_account_id = hcs.cust_account_id
    AND hps.location_id = hl.location_id
    AND hcs.status = 'A'
    AND xagv.party_site_id = hps.party_site_id
    AND xagv.party_site_id = hcs.party_site_id
    AND hou.ORGANIZATION_ID=hcs.ORG_ID) QRSLT WHERE (CTS Engineer1 Party_Name like :2)
         at oracle.apps.fnd.framework.OAException.wrapperException(Unknown Source)
         at oracle.apps.fnd.framework.OAException.wrapperException(Unknown Source)
         at oracle.apps.fnd.framework.OAException.wrapperInvocationTargetException(Unknown Source)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(Unknown Source)
         at xxuss.oracle.apps.xo2c.contactmaintenance.webui.USSContactMainCO.processFormRequest(USSContactMainCO.java:105)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at OA.jspService(_OA.java:71)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    ## Detail 0 ##
    java.sql.SQLException: Missing IN or OUT parameter at index:: 1
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175)
         at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1566)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2996)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3043)
         at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:857)
         at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:666)
         at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:3655)
         at oracle.jbo.server.OAJboViewObjectImpl.executeQueryForCollection(Unknown Source)
         at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQueryForCollection(Unknown Source)
         at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:742)
         at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:891)
         at oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:805)
         at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:799)
         at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:3575)
         at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQuery(Unknown Source)
         at xxuss.oracle.apps.xo2c.contactmaintenance.server.USSContactMainAMImpl.uneditable(USSContactMainAMImpl.java:244)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(Unknown Source)
         at xxuss.oracle.apps.xo2c.contactmaintenance.webui.USSContactMainCO.processFormRequest(USSContactMainCO.java:105)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at OA.jspService(_OA.java:71)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    java.sql.SQLException: Missing IN or OUT parameter at index:: 1
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175)
         at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1566)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2996)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3043)
         at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:857)
         at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:666)
         at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:3655)
         at oracle.jbo.server.OAJboViewObjectImpl.executeQueryForCollection(Unknown Source)
         at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQueryForCollection(Unknown Source)
         at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:742)
         at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:891)
         at oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:805)
         at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:799)
         at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:3575)
         at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQuery(Unknown Source)
         at xxuss.oracle.apps.xo2c.contactmaintenance.server.USSContactMainAMImpl.uneditable(USSContactMainAMImpl.java:244)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(Unknown Source)
         at xxuss.oracle.apps.xo2c.contactmaintenance.webui.USSContactMainCO.processFormRequest(USSContactMainCO.java:105)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at OA.jspService(_OA.java:71)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    Edited by: MyOAF on Jan 14, 2010 11:03 PM

  • Error using bind variables with SQL server with SQL92 mode

    I am using 2 bind variable in my VO (JDBC positional) . The mode is SQL 92 for ADF BC. I do not use the bind variable directly but in a view criteria. I see following error in the logs.
    The logs show the query executed and error.  I tried both ways - making bind variable required and not required. I have set -Djbo.SQLBuilder=SQLServer property. My other page works which has an updatable VO.
    JDEV version is - JDEVADF_11.1.1.7.0_GENERIC_130226.1400.6493
    <ViewObjectImpl> <getQueryHitCount> [4567] Estimated Row Count for ViewObject: [oracle.epm.fm.bc4j.queries.admin.UserOnSystemROVO]AdministrationAM.UserOnSystemROVO1, Query Statement:
    <ViewObjectImpl> <getQueryHitCount> [4568] "SELECT count(1) FROM (SELECT * FROM (SELECT
        TABLE1.SUSERNAME USERNAME,
        TABLE2.SMODULENAME MODULENAME,
        TABLE2.LACTIVITYCODE ACTIVITYCODE,
        TABLE2.DSTARTTIME STARTTIME,
        TABLE2.SSERVERNAME SERVERNAME,
        TABLE2.SAPPNAME APPNAME,
        TABLE2.LSESSIONID SESSIONID,
        TABLE2.LSESSIONSTATUS SESSIONSTATUS,
        TABLE2.LUSERID USERID,
        TABLE2.DSTILLALIVETS STILLALIVETS,
        TABLE2.LTASKID TASKID,
        TABLE2.SACTIVITYDESC ACTIVITYDESC,
        TABLE1.LUSERID USERID1,
        TABLE1.SUSERDESC USERDESC
    FROM
        TABLE2 TABLE2,
        TABLE1 TABLE1
    WHERE
        TABLE2.LUSERID = TABLE1.LUSERID) QRSLT  WHERE ( ( ( ( UPPER(SERVERNAME) = UPPER(?)  )  OR  ( ? IS NULL ) ) AND ( ( UPPER(APPNAME) = UPPER(?)  )  OR  ( ? IS NULL ) ) ) )) ESTCOUNT"
    <ViewObjectImpl> <getQueryHitCount> [4569] Bind params for ViewObject.getQueryHitCount: UserOnSystemROVO1
    <ViewRowSetImpl> <doSetWhereClauseParam> [4570] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(0, null, null)
    <ViewRowSetImpl> <doSetWhereClauseParam> [4571] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(1, null, null)
    <ViewRowSetImpl> <doSetWhereClauseParam> [4572] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(4, null, null)
    <ViewRowSetImpl> <doSetWhereClauseParam> [4573] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(5, null, null)
    <ViewRowSetImpl> <doSetWhereClauseParam> [4574] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(2, null, null)
    <ViewRowSetImpl> <doSetWhereClauseParam> [4575] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(3, null, null)
    <ADFLogger> <addContextData> Estimated row count
    <BaseSQLBuilderImpl> <bindParamValue> [4576] Binding null of type 12 for 1
    <BaseSQLBuilderImpl> <bindParamValue> [4577] Binding null of type 12 for 2
    <BaseSQLBuilderImpl> <bindParamValue> [4578] Binding null of type 12 for 3
    <BaseSQLBuilderImpl> <bindParamValue> [4579] Binding null of type 12 for 4
    <BaseSQLBuilderImpl> <bindParamValue> [4580] Binding null of type 12 for 5
    <ViewObjectImpl> <getQueryHitCount> [4581] ViewObjectImpl.getQueryHitCount failed...
    <ViewObjectImpl> <getQueryHitCount> [4582] java.sql.SQLException: [FMWGEN][SQLServer JDBC Driver]Invalid parameter binding(s).
      at weblogic.jdbc.sqlserverbase.dda4.b(Unknown Source)
      at weblogic.jdbc.sqlserverbase.dda4.a(Unknown Source)
      at weblogic.jdbc.sqlserverbase.dda3.b(Unknown Source)
      at weblogic.jdbc.sqlserverbase.dda3.a(Unknown Source)
      at weblogic.jdbc.sqlserverbase.ddb8.a(Unknown Source)
      at weblogic.jdbc.sqlserverbase.ddb9.a(Unknown Source)
      at weblogic.jdbc.sqlserverbase.ddb9.setNull(Unknown Source)
      at weblogic.jdbc.wrapper.PreparedStatement.setNull(PreparedStatement.java:622)
      at oracle.jbo.server.BaseSQLBuilderImpl.bindParamValue(BaseSQLBuilderImpl.java:2215)
      at oracle.jbo.server.BaseSQLBuilderImpl.bindParametersForStmt(BaseSQLBuilderImpl.java:3687)
      at oracle.jbo.server.ViewObjectImpl.bindParametersForCollection(ViewObjectImpl.java:22684)
      at oracle.jbo.server.ViewObjectImpl.getQueryHitCount(ViewObjectImpl.java:4944)
      at oracle.jbo.server.ViewObjectImpl.getQueryHitCount(ViewObjectImpl.java:4857)
      at oracle.jbo.server.QueryCollection.getEstimatedRowCount(QueryCollection.java:4204)
      at oracle.jbo.server.ViewRowSetImpl.getEstimatedRowCount(ViewRowSetImpl.java:2677)
      at oracle.jbo.server.ViewObjectImpl.getEstimatedRowCount(ViewObjectImpl.java:10632)

    After making all the bind variables not required, the error is no longer coming.

  • PL SQL using variable in SQL statement

    I am trying to execute several sql statements, that have the same format but different values. Does this
    mean I need a bind variable?
    ie
    select TO_CHAR ( (SYSDATE - 2), 'YYYY_MM_DD') from dual
    select TO_CHAR ( (SYSDATE - 4), 'YYYY_MM_DD') from dual
    select to_char(add_months(sysdate,-2*1) from dual
    When I try to put the values into a varaiable (date, varchar2 or number) I am getting a conversion
    error.
    Can somebody show me an example of how to do something like this? Or at least point me to the correct
    part of the documentation that provides and example. Pardon my syntax as I know it is incorrect
    val :=add_months(sysdate,-2*1
    select to_char(val) from dual
    Thanks in advance to all who answer

    Hi,
    840386 wrote:
    I am trying to execute several sql statements, that have the same format but different values. Does this
    mean I need a bind variable?No, you don't need a bind variable, though bind variables may be more efficient than using PL/SQL variables. I don't see where you're trying to use any varibables at all in your examples. Is it in place of the literals, such as 2 or 'YYYY_MM_DD'? You can use either bind varibales or PL/SQL variables in those places.
    ie
    select TO_CHAR ( (SYSDATE - 2), 'YYYY_MM_DD') from dual
    select TO_CHAR ( (SYSDATE - 4), 'YYYY_MM_DD') from dual
    select to_char(add_months(sysdate,-2*1) from dualIn PL/SQL, when you have a SELECT statement, you must specify what you want to do with the results. For example, a SELECT ... INTO statement:
    SELECT  AVG (sal)
    INTO    avg_salary
    FROM    scott.emp;There's usually no point in SELECTing from dual in PL/SQL. It's not an error, but it's simpler just to use an assignment statement.
    When I try to put the values into a varaiable (date, varchar2 or number) I am getting a conversion
    error.Post a complete procedure or anonymous block, including variable declarations, that shows exactly what you're trying to do.
    >
    Can somebody show me an example of how to do something like this? Or at least point me to the correct
    part of the documentation that provides and example. Pardon my syntax as I know it is incorrect
    val :=add_months(sysdate,-2*1Assuming val is a DATE, that's basically correct. You have unbalanced parentheses (there's a '(', but no matching ')' ), and you need a semicolon (';') at the end of the statement. Perhaps ');' just got cut off when you were posting this.
    select to_char(val) from dualAgain, SELECTing from dual is unnecessary, but if you had some way to catch the returned value, that would work.
    Usually, the reason why you need to call TO_CHAR is that you want a value in a particular format, which is specified in the 2nd argument to TO_CHAR. Calling TO_CHAR with only one argument is a possible mistake, but not something that would raise an error.
    Here's an example that works:
    SET     SERVEROUTPUT     ON
    DECLARE
         d     DATE;
         v     VARCHAR2 (30);
    BEGIN
         d := ADD_MONTHS (SYSDATE, -2);          -- -2 = (-2*1)
         v := TO_CHAR (d, 'DD-Mon-YYYY');
         dbms_output.put_line (v || ' = v');
    END;
    /Output (when run on March 13, 2011):
    13-Jan-2011 = v

  • Prompt for bind variables in SQL developer

    Hi!
    Just installed the latest 3.2 version of SQL Developer, and tried to do an explain plan.
    Now the tool prompts me for values for the bind variable. It didn't do that in my previous version (version 3. something).
    Thats anoying :-)
    How do I disable that feature?
    Example:
    explain plan for
    select * from emp
    where department_id = :1;
    If i right click on the statement or press F10, I get no prompt for the bind variable...
    Regards
    Søren

    Old fashioned way, like this:
    EXPLAIN PLAN FOR
    SELECT * FROM scott.emp
    where deptno = :1;
    SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());
    Executed with F5 gives me this output
    plan FOR succeeded.
    PLAN_TABLE_OUTPUT
    Plan hash value: 3956160932
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 5 | 190 | 3 (0)| 00:00:01 |
    |* 1 | TABLE ACCESS FULL| EMP | 5 | 190 | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    1 - filter("DEPTNO"=TO_NUMBER(:1))
    13 rows selected

  • Bind variables in SQL causes slowness

    We are having a strange problem in our PeopleSoft system that I have traced to a SELECT statement using bind variables, if we hard-code the values in the SQL it runs very fast,
    but using binds (which is what the application does) causes a huge efficiency problem. I am going to re-write the code that is based on a view of three joined tables to go against
    the base tables and I don't think I will have a problem. However, I would like to know why the problem exists in the first place. Here is what info I have:
    Oracle version: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    This is the "good" query without binds:
    SELECT COUNT(*)
    FROM sysadm.PS_ERN_PROG_DESCR A
    WHERE A.ERN_PROGRAM = 'VT'
    AND A.ERNCD         = '01'
    AND EFFDT           =
      (SELECT MAX(B.EFFDT)
      FROM sysadm.PS_ERN_PROG_DESCR B
      WHERE B.ERN_PROGRAM = 'VT'
      AND B.EFFDT        <= TO_DATE('2009-10-10','YYYY-MM-DD')
      );And the "good" explain plan:
    Plan hash value: 3344976101
    | Id  | Operation                              | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                       |                    |     1 |    33 |    58  (23)| 00:00:01 |
    |   1 |  SORT AGGREGATE                        |                    |     1 |    33 |            |          |
    |   2 |   NESTED LOOPS                         |                    |     1 |    33 |     3   (0)| 00:00:01 |
    |   3 |    NESTED LOOPS                        |                    |     1 |    22 |     2   (0)| 00:00:01 |
    |*  4 |     INDEX UNIQUE SCAN                  | PS_ERN_PROGRAM_DEF |     1 |    12 |     1   (0)| 00:00:01 |
    |   5 |      SORT AGGREGATE                    |                    |     1 |     9 |            |          |
    |   6 |       VIEW                             |                    |    23 |   207 |    51  (26)| 00:00:01 |
    |*  7 |        FILTER                          |                    |       |       |            |          |
    |   8 |         SORT GROUP BY                  |                    |    23 |  1748 |    51  (26)| 00:00:01 |
    |*  9 |          HASH JOIN                     |                    |  2995 |   222K|    49  (23)| 00:00:01 |
    |* 10 |           TABLE ACCESS FULL            | PS_EARNINGS_TBL    |  1913 | 24869 |    15   (7)| 00:00:01 |
    |* 11 |           HASH JOIN                    |                    | 13621 |   838K|    30  (20)| 00:00:01 |
    |  12 |            TABLE ACCESS FULL           | PS_EARNINGS_TBL    |  1913 | 42086 |    14   (0)| 00:00:01 |
    |* 13 |            HASH JOIN                   |                    |  3097 |   124K|    14  (29)| 00:00:01 |
    |* 14 |             TABLE ACCESS BY INDEX ROWID| PS_ERN_PROGRAM_TBL |     9 |   207 |     2   (0)| 00:00:01 |
    |* 15 |              INDEX RANGE SCAN          | PS_ERN_PROGRAM_TBL |    18 |       |     1   (0)| 00:00:01 |
    |* 16 |             TABLE ACCESS FULL          | PS_ERN_PROGRAM_DEF | 12035 |   211K|    10  (20)| 00:00:01 |
    |* 17 |     INDEX RANGE SCAN                   | PS_EARNINGS_TBL    |     1 |    10 |     1   (0)| 00:00:01 |
    |  18 |      SORT AGGREGATE                    |                    |     1 |    10 |            |          |
    |* 19 |       INDEX RANGE SCAN                 | PS_EARNINGS_TBL    |     1 |    10 |     2   (0)| 00:00:01 |
    |* 20 |    TABLE ACCESS BY INDEX ROWID         | PS_ERN_PROGRAM_TBL |     1 |    11 |     1   (0)| 00:00:01 |
    |* 21 |     INDEX UNIQUE SCAN                  | PS_ERN_PROGRAM_TBL |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("A"."ERN_PROGRAM"='VT' AND "A"."EFFDT"= (SELECT MAX("$vm_col_2") FROM  (SELECT /*+ */
                  "EFFDT" "$vm_col_1","A"."EFFDT" "$vm_col_2" FROM SYSADM."PS_EARNINGS_TBL"
                  "C",SYSADM."PS_ERN_PROGRAM_TBL" "B",SYSADM."PS_ERN_PROGRAM_DEF" "A",SYSADM."PS_EARNINGS_TBL" "D"
                  WHERE "D"."EFFDT"<="A"."EFFDT" AND "D"."ERNCD"="C"."ERNCD" AND "D"."EFFDT"<=TO_DATE(' 2009-10-10
                  00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "A"."EFFDT"="B"."EFFDT" AND
                  "A"."ERN_PROGRAM"="B"."ERN_PROGRAM" AND "A"."ERN_PROGRAM"='VT' AND "A"."EFFDT"<=TO_DATE(' 2009-10-10
                  00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "B"."EFFDT"<=TO_DATE(' 2009-10-10 00:00:00', 'syyyy-mm-dd
                  hh24:mi:ss') AND "B"."ERN_PROGRAM"='VT' AND "B"."EFF_STATUS"='A' AND "C"."ERNCD"="A"."ERNCD" GROUP
                  BY "D"."ERNCD",ROWID,ROWID,ROWID,ROWID,"A"."EFFDT","EFFDT" HAVING "EFFDT"=MAX("D"."EFFDT"))
                  "$vm_view") AND "A"."ERNCD"='01')
       7 - filter("EFFDT"=MAX("D"."EFFDT"))
       9 - access("D"."ERNCD"="C"."ERNCD")
           filter("D"."EFFDT"<="A"."EFFDT")
      10 - filter("D"."EFFDT"<=TO_DATE(' 2009-10-10 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
      11 - access("C"."ERNCD"="A"."ERNCD")
      13 - access("A"."ERN_PROGRAM"="B"."ERN_PROGRAM" AND "A"."EFFDT"="B"."EFFDT")
      14 - filter("B"."EFF_STATUS"='A')
      15 - access("B"."ERN_PROGRAM"='VT' AND "B"."EFFDT"<=TO_DATE(' 2009-10-10 00:00:00', 'syyyy-mm-dd
                  hh24:mi:ss'))
      16 - filter("A"."ERN_PROGRAM"='VT' AND "A"."EFFDT"<=TO_DATE(' 2009-10-10 00:00:00', 'syyyy-mm-dd
                  hh24:mi:ss'))
      17 - access("C"."ERNCD"='01')
           filter(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))= (SELECT
                  MAX(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))) FROM SYSADM."PS_EARNINGS_TBL" "D" WHERE
                  SYS_OP_DESCEND("EFFDT") IS NOT NULL AND SYS_OP_DESCEND("EFFDT")>=SYS_OP_DESCEND(:B1) AND
                  "D"."ERNCD"=:B2 AND SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=:B3))
      19 - access("D"."ERNCD"=:B1 AND SYS_OP_DESCEND("EFFDT")>=SYS_OP_DESCEND(:B2) AND
                  SYS_OP_DESCEND("EFFDT") IS NOT NULL)
           filter(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=:B1)
      20 - filter("B"."EFF_STATUS"='A')
      21 - access("B"."ERN_PROGRAM"='VT' AND "A"."EFFDT"="B"."EFFDT")Here is the "good" autotrace:
    SQL> variable ppe_date varchar2(10)
    SQL> variable erncd varchar2(3)
    SQL> exec :ppe_date := '2009-10-10'
    SQL> exec :erncd := '01'
    SQL> SELECT COUNT(*)
      2  FROM PS_ERN_PROG_DESCR A
      3  WHERE A.ERN_PROGRAM = 'VT'
      4  AND A.ERNCD         = '01'
      5  AND EFFDT           =
      6    (SELECT MAX(B.EFFDT)
      7    FROM PS_ERN_PROG_DESCR B
      8    WHERE B.ERN_PROGRAM = 'VT'
      9    AND B.EFFDT        <= TO_DATE('2009-10-10','YYYY-MM-DD')
    10    );
      COUNT(*)
             1
    Elapsed: 00:00:01.23
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=59 Card=1 Bytes=33)
       1    0   SORT (AGGREGATE)
       2    1     NESTED LOOPS (Cost=3 Card=1 Bytes=33)
       3    2       NESTED LOOPS (Cost=2 Card=1 Bytes=22)
       4    3         INDEX (UNIQUE SCAN) OF 'PS_ERN_PROGRAM_DEF' (INDEX (UNIQUE)) (Cost=1 Card=1 Bytes=12)
       5    4           SORT (AGGREGATE)
       6    5             VIEW (Cost=52 Card=24 Bytes=216)
       7    6               FILTER
       8    7                 SORT (GROUP BY) (Cost=52 Card=24 Bytes=1824)
       9    8                   HASH JOIN (Cost=50 Card=3177 Bytes=241452)
      10    9                     TABLE ACCESS (FULL) OF 'PS_EARNINGS_TBL' (TABLE) (Cost=15 Card=1921 Bytes=24973)
      11    9                     HASH JOIN (Cost=31 Card=14488 Bytes=912744)
      12   11                       TABLE ACCESS (FULL) OF 'PS_EARNINGS_TBL' (TABLE) (Cost=14 Card=1921 Bytes=42262)
      13   11                       HASH JOIN (Cost=15 Card=3303 Bytes=135423)
      14   13                         TABLE ACCESS (FULL) OF 'PS_ERN_PROGRAM_TBL' (TABLE) (Cost=2 Card=9 Bytes=207)
      15   13                         TABLE ACCESS (FULL) OF 'PS_ERN_PROGRAM_DEF' (TABLE) (Cost=12 Card=12856 Bytes=231408)
      16    3         INDEX (RANGE SCAN) OF 'PS_EARNINGS_TBL' (INDEX (UNIQUE)) (Cost=1 Card=1 Bytes=10)
      17   16           SORT (AGGREGATE)
      18   17             INDEX (RANGE SCAN) OF 'PS_EARNINGS_TBL' (INDEX (UNIQUE)) (Cost=2 Card=1 Bytes=10)
      19    2       TABLE ACCESS (BY INDEX ROWID) OF 'PS_ERN_PROGRAM_TBL' (TABLE) (Cost=1 Card=1 Bytes=11)
      20   19         INDEX (UNIQUE SCAN) OF 'PS_ERN_PROGRAM_TBL' (INDEX (UNIQUE)) (Cost=0 Card=1)
    Statistics
              0  recursive calls
              0  db block gets
            182  consistent gets
              0  physical reads
              0  redo size
            232  bytes sent via SQL*Net to client
            278  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL> spool off===================================
    Here is the "bad" query using binds:
    ===================================
    SELECT COUNT(*)
    FROM sysadm.PS_ERN_PROG_DESCR A
    WHERE A.ERN_PROGRAM = 'VT'
    AND A.ERNCD         = :erncd
    AND EFFDT           =
      (SELECT MAX(B.EFFDT)
      FROM sysadm.PS_ERN_PROG_DESCR B
      WHERE B.ERN_PROGRAM = 'VT'
      AND B.EFFDT        <= TO_DATE(:ppe_date,'YYYY-MM-DD')
      );The "bad" explain plan
    explain plan succeeded.
    PLAN_TABLE_OUTPUT
    Plan hash value: 337039962
    | Id  | Operation                         | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                  |                    |     1 |    33 |    20  (25)| 00:00:01 |
    |   1 |  SORT AGGREGATE                   |                    |     1 |    33 |            |          |
    |   2 |   NESTED LOOPS                    |                    |     1 |    33 |     3   (0)| 00:00:01 |
    |   3 |    NESTED LOOPS                   |                    |     1 |    22 |     2   (0)| 00:00:01 |
    |*  4 |     INDEX UNIQUE SCAN             | PS_ERN_PROGRAM_DEF |     1 |    12 |     1   (0)| 00:00:01 |
    |   5 |      SORT AGGREGATE               |                    |     1 |    63 |            |          |
    |   6 |       NESTED LOOPS                |                    |     1 |    63 |    13  (39)| 00:00:01 |
    |   7 |        NESTED LOOPS               |                    |     1 |    52 |    12  (42)| 00:00:01 |
    |*  8 |         HASH JOIN                 |                    |     4 |   168 |    12  (42)| 00:00:01 |
    |   9 |          VIEW                     | VW_SQ_1            |    88 |  2112 |     9  (45)| 00:00:01 |
    |  10 |           SORT GROUP BY           |                    |    88 |  2728 |     9  (45)| 00:00:01 |
    |  11 |            MERGE JOIN             |                    |  3087 | 95697 |     7  (29)| 00:00:01 |
    |  12 |             SORT JOIN             |                    |   643 | 11574 |     2   (0)| 00:00:01 |
    |* 13 |              INDEX RANGE SCAN     | PS_ERN_PROGRAM_DEF |   643 | 11574 |     2   (0)| 00:00:01 |
    |* 14 |             SORT JOIN             |                    |    96 |  1248 |     5  (40)| 00:00:01 |
    |* 15 |              INDEX FAST FULL SCAN | PS_EARNINGS_TBL    |    96 |  1248 |     4  (25)| 00:00:01 |
    |* 16 |          INDEX RANGE SCAN         | PS_ERN_PROGRAM_DEF |   643 | 11574 |     2   (0)| 00:00:01 |
    |* 17 |         INDEX UNIQUE SCAN         | PS_EARNINGS_TBL    |     1 |    10 |     0   (0)| 00:00:01 |
    |* 18 |        TABLE ACCESS BY INDEX ROWID| PS_ERN_PROGRAM_TBL |     1 |    11 |     1   (0)| 00:00:01 |
    |* 19 |         INDEX UNIQUE SCAN         | PS_ERN_PROGRAM_TBL |     1 |       |     0   (0)| 00:00:01 |
    |* 20 |     INDEX RANGE SCAN              | PS_EARNINGS_TBL    |     1 |    10 |     1   (0)| 00:00:01 |
    |  21 |      SORT AGGREGATE               |                    |     1 |    10 |            |          |
    |* 22 |       INDEX RANGE SCAN            | PS_EARNINGS_TBL    |     1 |    10 |     2   (0)| 00:00:01 |
    |* 23 |    TABLE ACCESS BY INDEX ROWID    | PS_ERN_PROGRAM_TBL |     1 |    11 |     1   (0)| 00:00:01 |
    |* 24 |     INDEX UNIQUE SCAN             | PS_ERN_PROGRAM_TBL |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("A"."ERN_PROGRAM"='VT' AND "A"."EFFDT"= (SELECT MAX("A"."EFFDT") FROM
                  SYSADM."PS_EARNINGS_TBL" "C",SYSADM."PS_ERN_PROGRAM_TBL" "B",SYSADM."PS_ERN_PROGRAM_DEF" "A",
                  (SELECT MAX(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))) "VW_COL_1","D"."ERNCD" "ERNCD",ROWID
                  "ROWID" FROM SYSADM."PS_EARNINGS_TBL" "D","PS_ERN_PROGRAM_DEF" "A" WHERE
                  "A"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD') AND "A"."ERN_PROGRAM"='VT' AND
                  SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=INTERNAL_FUNCTION("A"."EFFDT") AND
                  SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=TO_DATE(:PPE_DATE,'YYYY-MM-DD') GROUP BY
                  "D"."ERNCD",ROWID) "VW_SQ_1" WHERE "ROWID"=ROWID AND
                  "A"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD') AND "A"."ERN_PROGRAM"='VT' AND
                  "A"."EFFDT"="B"."EFFDT" AND "B"."ERN_PROGRAM"='VT' AND "B"."EFF_STATUS"='A' AND
                  "B"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD') AND
                  SYS_OP_DESCEND("EFFDT")=SYS_OP_DESCEND("VW_COL_1") AND "ERNCD"="C"."ERNCD" AND
                  "C"."ERNCD"="A"."ERNCD" AND SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))="VW_COL_1") AND
                  "A"."ERNCD"=:ERNCD)
       8 - access("ROWID"=ROWID)
      13 - access("A"."ERN_PROGRAM"='VT' AND "A"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD'))
      14 - access(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=INTERNAL_FUNCTION("A"."EFFDT"))
           filter(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=INTERNAL_FUNCTION("A"."EFFDT"))
      15 - filter(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=TO_DATE(:PPE_DATE,'YYYY-MM-DD'))
      16 - access("A"."ERN_PROGRAM"='VT' AND "A"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD'))
      17 - access("ERNCD"="C"."ERNCD" AND SYS_OP_DESCEND("EFFDT")=SYS_OP_DESCEND("VW_COL_1"))
           filter("C"."ERNCD"="A"."ERNCD" AND SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))="VW_COL_1")
      18 - filter("B"."EFF_STATUS"='A')
      19 - access("B"."ERN_PROGRAM"='VT' AND "A"."EFFDT"="B"."EFFDT")
           filter("B"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD'))
      20 - access("C"."ERNCD"=:ERNCD)
           filter(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))= (SELECT
                  MAX(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))) FROM SYSADM."PS_EARNINGS_TBL" "D" WHERE
                  SYS_OP_DESCEND("EFFDT") IS NOT NULL AND SYS_OP_DESCEND("EFFDT")>=SYS_OP_DESCEND(:B1) AND
                  "D"."ERNCD"=:B2 AND SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=:B3))
      22 - access("D"."ERNCD"=:B1 AND SYS_OP_DESCEND("EFFDT")>=SYS_OP_DESCEND(:B2) AND
                  SYS_OP_DESCEND("EFFDT") IS NOT NULL)
           filter(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=:B1)
      23 - filter("B"."EFF_STATUS"='A')
      24 - access("B"."ERN_PROGRAM"='VT' AND "A"."EFFDT"="B"."EFFDT")Here is the bad autotrace:
    SQL> variable ppe_date varchar2(10)
    SQL> variable erncd varchar2(3)
    SQL> exec :ppe_date := '2009-10-10'
    SQL> exec :erncd := '01'
    SQL> SELECT COUNT(*)
      2  FROM PS_ERN_PROG_DESCR A
      3  WHERE A.ERN_PROGRAM = 'VT'
      4  AND A.ERNCD         = :erncd
      5  AND EFFDT           =
      6    (SELECT MAX(B.EFFDT)
      7    FROM PS_ERN_PROG_DESCR B
      8    WHERE B.ERN_PROGRAM = 'VT'
      9    AND B.EFFDT        <= TO_DATE(:ppe_date,'YYYY-MM-DD')
    10    );
      COUNT(*)
             1
    Elapsed: 00:04:07.40
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=20 Card=1 Bytes=33)
       1    0   SORT (AGGREGATE)
       2    1     NESTED LOOPS (Cost=3 Card=1 Bytes=33)
       3    2       NESTED LOOPS (Cost=2 Card=1 Bytes=22)
       4    3         INDEX (UNIQUE SCAN) OF 'PS_ERN_PROGRAM_DEF' (INDEX (UNIQUE)) (Cost=1 Card=1 Bytes=12)
       5    4           SORT (AGGREGATE)
       6    5             NESTED LOOPS (Cost=13 Card=1 Bytes=63)
       7    6               NESTED LOOPS (Cost=12 Card=1 Bytes=52)
       8    7                 HASH JOIN (Cost=12 Card=4 Bytes=168)
       9    8                   VIEW OF 'VW_SQ_1' (VIEW) (Cost=9 Card=88 Bytes=2112)
      10    9                     SORT (GROUP BY) (Cost=9 Card=88 Bytes=2728)
      11   10                       MERGE JOIN (Cost=7 Card=3087 Bytes=95697)
      12   11                         SORT (JOIN) (Cost=2 Card=643 Bytes=11574)
      13   12                           INDEX (RANGE SCAN) OF 'PS_ERN_PROGRAM_DEF' (INDEX (UNIQUE)) (Cost=2 Card=643 Bytes=11574)
      14   11                         SORT (JOIN) (Cost=5 Card=96 Bytes=1248)
      15   14                           INDEX (FAST FULL SCAN) OF 'PS_EARNINGS_TBL' (INDEX (UNIQUE)) (Cost=4 Card=96 Bytes=1248)
      16    8                   INDEX (RANGE SCAN) OF 'PS_ERN_PROGRAM_DEF' (INDEX (UNIQUE)) (Cost=2 Card=643 Bytes=11574)
      17    7                 INDEX (UNIQUE SCAN) OF 'PS_EARNINGS_TBL' (INDEX (UNIQUE)) (Cost=0 Card=1 Bytes=10)
      18    6               TABLE ACCESS (BY INDEX ROWID) OF 'PS_ERN_PROGRAM_TBL' (TABLE) (Cost=1 Card=1 Bytes=11)
      19   18                 INDEX (UNIQUE SCAN) OF 'PS_ERN_PROGRAM_TBL' (INDEX (UNIQUE)) (Cost=0 Card=1)
      20    3         INDEX (RANGE SCAN) OF 'PS_EARNINGS_TBL' (INDEX (UNIQUE)) (Cost=1 Card=1 Bytes=10)
      21   20           SORT (AGGREGATE)
      22   21             INDEX (RANGE SCAN) OF 'PS_EARNINGS_TBL' (INDEX (UNIQUE)) (Cost=2 Card=1 Bytes=10)
      23    2       TABLE ACCESS (BY INDEX ROWID) OF 'PS_ERN_PROGRAM_TBL' (TABLE) (Cost=1 Card=1 Bytes=11)
      24   23         INDEX (UNIQUE SCAN) OF 'PS_ERN_PROGRAM_TBL' (INDEX (UNIQUE)) (Cost=0 Card=1)
    Statistics
           3820  recursive calls
             66  db block gets
        4677728  consistent gets
          80608  physical reads
              0  redo size
            232  bytes sent via SQL*Net to client
            278  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              2  sorts (memory)
              1  sorts (disk)
              1  rows processed
    SQL> spool off

    I had earlier removed SYSADM from the code, but this code is still slow (200 seconds):
    SQL_ID  6krxh8wx47gfg, child number 0
    SELECT COUNT(*)  FROM PS_ERN_PROG_DESCR A  WHERE A.ERN_PROGRAM = 'VT'  AND A.ERNCD         = :erncd 
    AND EFFDT           =    (SELECT MAX(B.EFFDT)    FROM PS_ERN_PROG_DESCR B    WHERE B.ERN_PROGRAM = 'VT'
       AND B.EFFDT        <= TO_DATE(:ppe_date,'YYYY-MM-DD')    )
    Plan hash value: 3692387151
    | Id  | Operation                         | Name               | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                  |                    |       |       |       |   914 (100)|          |
    |   1 |  SORT AGGREGATE                   |                    |     1 |    33 |       |            |          |
    |   2 |   NESTED LOOPS                    |                    |     1 |    33 |       |     3   (0)| 00:00:01 |
    |   3 |    NESTED LOOPS                   |                    |     1 |    22 |       |     2   (0)| 00:00:01 |
    |*  4 |     INDEX UNIQUE SCAN             | PS_ERN_PROGRAM_DEF |     1 |    12 |       |     1   (0)| 00:00:01 |
    |   5 |      SORT AGGREGATE               |                    |     1 |    63 |       |            |          |
    |   6 |       NESTED LOOPS                |                    |     1 |    63 |       |   907  (90)| 00:00:11 |
    |*  7 |        HASH JOIN                  |                    |     1 |    52 |       |   906  (90)| 00:00:11 |
    |   8 |         NESTED LOOPS              |                    |   438 | 14892 |       |   890  (91)| 00:00:11 |
    |   9 |          VIEW                     | VW_SQ_1            |   438 | 10512 |       |   889  (91)| 00:00:11 |
    |  10 |           SORT GROUP BY           |                    |   438 | 13578 |       |   889  (91)| 00:00:11 |
    |  11 |            MERGE JOIN             |                    |  1234K|    36M|       |   178  (52)| 00:00:03 |
    |  12 |             SORT JOIN             |                    |  1921 | 24973 |       |     5  (40)| 00:00:01 |
    |* 13 |              INDEX FAST FULL SCAN | PS_EARNINGS_TBL    |  1921 | 24973 |       |     4  (25)| 00:00:01 |
    |* 14 |             SORT JOIN             |                    | 12856 |   225K|   824K|    96  (14)| 00:00:02 |
    |* 15 |              TABLE ACCESS FULL    | PS_ERN_PROGRAM_DEF | 12856 |   225K|       |    15  (40)| 00:00:01 |
    |* 16 |          INDEX UNIQUE SCAN        | PS_EARNINGS_TBL    |     1 |    10 |       |     0   (0)|          |
    |* 17 |         TABLE ACCESS FULL         | PS_ERN_PROGRAM_DEF | 12856 |   225K|       |    15  (40)| 00:00:01 |
    |* 18 |        TABLE ACCESS BY INDEX ROWID| PS_ERN_PROGRAM_TBL |     1 |    11 |       |     1   (0)| 00:00:01 |
    |* 19 |         INDEX UNIQUE SCAN         | PS_ERN_PROGRAM_TBL |     1 |       |       |     0   (0)|          |
    |* 20 |     INDEX RANGE SCAN              | PS_EARNINGS_TBL    |     1 |    10 |       |     1   (0)| 00:00:01 |
    |  21 |      SORT AGGREGATE               |                    |     1 |    10 |       |            |          |
    |* 22 |       INDEX RANGE SCAN            | PS_EARNINGS_TBL    |     1 |    10 |       |     2   (0)| 00:00:01 |
    |* 23 |    TABLE ACCESS BY INDEX ROWID    | PS_ERN_PROGRAM_TBL |     1 |    11 |       |     1   (0)| 00:00:01 |
    |* 24 |     INDEX UNIQUE SCAN             | PS_ERN_PROGRAM_TBL |     1 |       |       |     0   (0)|          |
    Peeked Binds (identified by position):
       1 - :ERNCD (VARCHAR2(30), CSID=46): '01'
       2 - :PPE_DATE (VARCHAR2(30), CSID=46): '2009-10-10'
    Predicate Information (identified by operation id):
       4 - access("A"."ERN_PROGRAM"='VT' AND "A"."EFFDT"= AND "A"."ERNCD"=:ERNCD)
       7 - access("C"."ERNCD"="A"."ERNCD" AND "ROWID"=ROWID)
      13 - filter(SYS_OP_UNDESCEND("D"."SYS_NC00084$")<=TO_DATE(:PPE_DATE,'YYYY-MM-DD'))
      14 - access(SYS_OP_UNDESCEND("D"."SYS_NC00084$")<="A"."EFFDT")
           filter(SYS_OP_UNDESCEND("D"."SYS_NC00084$")<="A"."EFFDT")
      15 - filter(("A"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD') AND "A"."ERN_PROGRAM"='VT'))
      16 - access("ERNCD"="C"."ERNCD" AND "C"."SYS_NC00084$"=SYS_OP_DESCEND("VW_COL_1"))
           filter(SYS_OP_UNDESCEND("C"."SYS_NC00084$")="VW_COL_1")
      17 - filter(("A"."ERN_PROGRAM"='VT' AND "A"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD')))
      18 - filter("B"."EFF_STATUS"='A')
      19 - access("B"."ERN_PROGRAM"='VT' AND "A"."EFFDT"="B"."EFFDT")
           filter("B"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD'))
      20 - access("C"."ERNCD"=:ERNCD)
           filter(SYS_OP_UNDESCEND("C"."SYS_NC00084$")=)
      22 - access("D"."ERNCD"=:B1 AND "D"."SYS_NC00084$">=SYS_OP_DESCEND(:B2) AND "D"."SYS_NC00084$" IS NOT
                  NULL)
           filter(SYS_OP_UNDESCEND("D"."SYS_NC00084$")<=:B1)
      23 - filter("B"."EFF_STATUS"='A')
      24 - access("B"."ERN_PROGRAM"='VT' AND "A"."EFFDT"="B"."EFFDT")

  • Bind variables in SQL Developer

    I declared a bind variable called 'test_num' and assigned a value of 10 as shown below.
    variable test_num number
    BEGIN
    :test_num := 10;
    dbms_output.put_line ('The Test Value: ' || :test_num);
    END;
    When I execute the above program, the output is thrown as 'The Test Value: '. The value of test_num is not shown. I fear whether this issue is due to SQL Developer which i am using to execute this program.
    Please let me know why the value is not getting printed
    Thanks for your help!

    I see the same issue you are seeing when using the bind variable. The bind variable works fine in SQL*Plus but not from SQL Developer.
    From SQLPlus*
    SQL> set serveroutput on
    SQL> variable test_num number
    SQL> BEGIN
    2 :test_num := 10;
    3 dbms_output.put_line ('The Test Value: ' || :test_num);
    4 END;
    5 /
    The Test Value: 10
    PL/SQL procedure successfully completed.
    From SQLDeveloper*
    set serveroutput on
    variable test_num number
    BEGIN
    :test_num := 10;
    dbms_output.put_line ('The Test Value: ' || :test_num);
    END;
    anonymous block completed
    The Test Value:

  • Bind Variable In Case Statement Produces Error ORA-01036

    When running the following command using ODP.Net 10.1.0.301 I recieve error 1036. Statement runs fine within SQL+ and Toad.
    Dim SQL As String = "SELECT CASE WHEN EXISTS(SELECT part_nbr FROM item_master WHERE part_nbr=:part_number) THEN 1 ELSE 0 END AS RECORD_EXISTS FROM Dual"
    Dim OraConnection As New OracleConnection(connectstring)
    Dim OraCommand As New OracleCommand(SQL, OraConnection)
    OraCommand.Parameters.Add("part_number", OracleDbType.Varchar2).Value = PartNumber
    Dim Obj as Object=OraCommand.ExecuteScalar

    Hi Michael,
    I was able to get your code to work on my system by changing the SQL statement as follows:
    SELECT (CASE WHEN EXISTS(SELECT part_nbr FROM item_master WHERE part_nbr=:part_number) THEN 1 ELSE 0 END) AS RECORD_EXISTS FROM Dual
    I simply enclosed the case statement in opening and closing parenthesis...
    Hope that helps,
    - Mark

Maybe you are looking for

  • NFE 2.0 - Contingencia

    Bom dia, Estou testanto do processo de contingencia para a versão 2.0 do XML da NFE. Através do monitor da NFE (J1BNFE) eu coloco em contingência o local de negócio. Flego o primeiro campo MS Down e coloco o motivo da contingencia no campo Mt Cont MS

  • How do I print multiple files in file name order

    I'm using Windows XP SP3.  When I select all the PDF files within a folder and right click and print, the files do not come out of the printer in the order of the file names. I have the file names displayed properly in order on the screen, but they s

  • Incorrect Pay Load in XI Message

    Hi, We have Http->XI->RFC synchronous post scenario in XI. Lately we are observing a number of entries in XI log where sender is sending the interface 1 in the header but the pay load in the log is for interface 2. This is only happening under high l

  • Collating all related files when finished

    Hi all, When finishing a book, I want to collate all the image files etc, so I can back this up on DVD. Is there a function where it will copy (not move) all files to a location with the InDesign files? (Note: I don't want to move all the linked file

  • Reading List disappeared how can I get it back?

    I had several items in my Reading list.  I went to find them today and they are all gone!  How do I retrieve them?