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

Similar Messages

  • 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

  • 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

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

  • ORA-01722: invalid number caused with SQL using bind variable

    Hi,
    Im am hoping that someone can help me resolve a problem thats only just services and is being experienced on quite a few clients.
    our application uses C++ exes and makes OCI calls to the database.
    what has happened in the last week or so, there has been quite a few invalid number errors being received on a prod server but strangly enough we cannot reproduct the error on our UAT system.
    The sql is using bind variables and the information in the trace file shows that a number is being used for the bind variable, here is an extract from one trace file:
    for some schemas, the bind variable value is some currupted value, i think:
    oacdty=01 mxl=32(21) mxlc=00 mal=00 scl=00 pre=00
    oacflg=03 fl2=1206001 frm=01 csi=178 siz=32 off=0
    kxsbbbfp=9a8d62b8 bln=32 avl=03 flg=05
    value="Â*d"
    but on another schema, the value used is:
    Bind#0
    oacdty=01 mxl=32(32) mxlc=00 mal=00 scl=00 pre=00
    oacflg=03 fl2=1206001 frm=01 csi=178 siz=32 off=0
    kxsbbbfp=c5f92718 bln=32 avl=04 flg=05
    value="2101"
    however both produce invalid number errors.
    I am relatively inexperienced as a DBA so would appreciate as much help as i can get.

    Could you post your sql statement that is being run.
    Also post the query plan from your uat system and the one from your production system (They are likely to be different)
    You can export the stats from your production system and run them in your uat system. If you do this, then the execution plans should be the same on both systems(dbms_stats) and if you have the same data you should run into the same problem on uat as in production.
    The root cause of this type of problem is having a column in a table which holds values which are of different datatypes. Typically there is a condition in the where clause which indicates that for example only numeric columns should be retrieved from the column which holds multiple data types. However since the optimizer is free to rewrite the query any way it sees fit, (It does not necessarily execute in the order the sql statement is written) it does not filter this data first, and therefore you hit non-numeric data and run into the invalid number error.
    You can use little techniques like using an inline view with rownum in the column list, to perform the first filter. This ensures that the inline view is executed on its own, rather than being merged (materialized) with the rest of the query.
    A quick temporary solution is to use a comparison like to_char(column_name) = variable
    Make sure your comparisons are correct and it doesn't negatively impact on performance of the query

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

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

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

  • PL SQL using bind variables

    I am very much new to PL/SQL to pardon my neivte.
    I would like to have some PL/SQL code that uses
    bind variables for insert statements and than issue
    commit's after a specific number of inserts.
    For example.
    desc xxx.taba
    a number
    b varchar2(20)
    I want to do someting like this:
    declare
    l_start number default dbms_utility.get_time;
    create or replace procedure insert_xxx(commit in number)
    begin
    for i in 1 .. 1000
    loop
    :a:=i;
    :b:=dbms_random.string('P', 20);
    intert into xxx :a :b;
    if i/mod=(number passed into to proc)
    commit
    end loop;
    dbms_output.put_line
    (round((dbms_utility.get_time-l_start)/100, 2) ||
    ' Seconds...' );
    end;
    end;
    Can somebody help me out with the correct syntax
    as I know it's incorrect.

    A few remarks
    - procedures don't have hidden variables defined in the outside world, as procedures are black boxes, which communicate only with the outside world
    using the actual parameter list
    - procedures don't commit. The caller should always commit!!!
    - procedures don't commit every <n> records. A commit finalizes a logical unit of work, not a technical one.
    If I would have been your supervisor and you would have presented this code, I would have fired you on the spot.
    Committing inside a loop also increases the likelihood of ora-1555 errors.
    So: remove the current parameter
    a and b should be formal parameters of the procedure
    Inside the procedure it should read
    insert into xxx values (a, b)
    Sybrand Bakker
    Senior Oracle DBA

  • How to obtain SQL that don't use bind variables

    Hi,
    I'm trying to identify the SQL that should benefit from using bind variables.
    First, I tried to obtain the common signature from all those sql calls, by using:
    select * from (
    select  force_matching_signature, count(1) from v$sql where force_matching_signature<>0 group by force_matching_signature order by 2 desc
    ) where rownum < 50;Then, I copied those values to clipboard and executed: select sql_text from v$sql where force_matching_signature=<<<copied_signature_value>>>;Now I want to make it automatically, and get just 1 occurrence of each SQL that is similar to others by using a query.
    I've tried this:
    select sql_text from
    select sql_text, force_matching_signature, row_number() over (partition by force_matching_signature order by sql_text desc)rn from v$sql where force_matching_signature <>0
    )where rn <2 and rownum < 10 order by force_matching_signature descBut this is not returning results by attending to the count(1) of the first query I used. How can I modify this so I get the results in order of 'importance'?
    Thanks

    And I said. First use order by, then use rownum. I didn't mention row_number. Also there should be no need to add any more columns.
    Did you try it? Why didn't it work?
    untested example
    select * from (
       select sql_text from (select sql_text, force_matching_signature, row_number() over (partition by force_matching_signature order by sql_text desc) rn from v$sql where force_matching_signature != 0)
       where rn = 1
       order by force_matching_signature desc /* add any ordering you like here */
    where rownum < 10  /* then filter on the first 10 results */If you want to order it in such a way that the statement that is found most times comes first then say so. However I do not see how to group in your case.
    maybe like this
    tested example
    select * from (
       select cnt, sql_text
       from (select sql_text, force_matching_signature, row_number() over (partition by force_matching_signature order by sql_text desc) rn , count(*) over (partition by force_matching_signature) cnt
             from v$sql
             where force_matching_signature != 0)
       where rn = 1
       order by cnt desc, force_matching_signature desc /* add any ordering you like here */
    where rownum < 10  /* then filter on the first 10 results */
    ;Edited by: Sven W. on Oct 11, 2012 2:49 PM
    Edited by: Sven W. on Oct 11, 2012 2:51 PM
    Edited by: Sven W. on Oct 11, 2012 2:56 PM -- added count column to the output

  • Correct Way to use Bind variables when using an MS SQL server backend

    Hey,
    I'm having some trouble figuring out how to use bind variables in a view when using an MS SQL server backend. For some reason when I'm using an ApplicationModule that has a MS SQL Server JDBC library loaded and I attempt to click OK when editing the following query:
    SELECT kit_status, component_id
    FROM numbered_inv
    WHERE trialname = :1
    I get an error stating that "SQL Query Error Message Incorrect Syntax near ':'". Is JDeveloper compatible with SQL server for bind variables because this query runs just fine if I replace the :1 with a say "Testing testing".
    Thanks in advance
    Edited by: NullCheck on Dec 15, 2010 2:06 PM

    Gotcha. I had tried %1% %0% ?0 and ?1 and various other permutations none of which worked. Got it working by setting the query to:
    SELECT kit_status, component_id
    FROM numbered_inv
    WHERE trialname = ?
    ORDER BY kit_status
    And then adding a bind variable with "Bind position" set to 0.
    Thanks again Shay!

  • Report Using Bind Variables

    Hey Everyone,
    I'm having a bit of trouble creating a report. I need the FROM part of the code to use bind variables. I have come up with this peice of code below but im getting the following error:
    failed to parse SQL query:
    ORA-06550: line 1, column 8:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin function package pragma procedure subtype type use
    form
    current cursor
    The symbol "" was ignored.
    ORA-06550: line 2, column 24:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin function package pragma procedure subtype type use
    form
    current
    Can anyone see where im going wrong?
    Thanks in advance,
    -N.S.N.O.
    Code*
    DECLARE
    x VARCHAR2 (4000);
    BEGIN
    x := x || 'select *';
    x := x || 'from ';
    x := x || :p13_schema;
    x := x || '.ddl_log@';
    x := x || :p13_db_name;
    x := x || '_DBAAPEX.TNTEWW.COM';
    RETURN (x);
    END;

    Hey Roel and Daylocks,
    After getting frustrated for a while i deleted the page and started again. I put in the exact same code and it worked just how i wanted in the first place :S
    The only thing i did different is when i was creating the report region the first time around i used a normal SQL query, For Example:
    select sysdate from dual;
    Then i modified it to
    DECLARE
    x VARCHAR2 (4000);
    BEGIN
    x := x || 'select ';*
    x := x || 'from ';
    x := x || :p14_schema;
    x := x || '.ddl_log@';
    x := x || :p14_db_name;
    x := x || '_DBAAPEX.TNTEWW.COM';
    RETURN (x);
    END;
    Whereas on the second attempt i used the peice of code in question straight away. Its been a bit of a frustrating morning because i used a similar peice of code for a different application, nevermind tho :)
    Thanks for your replys, much appreciated.
    -N.S.N.O.

  • Query don't use the right index when using bind variables

    Hi people !
    I need some help because I have an issue with a query that don t use the right Indexes as it should
    First of all, I have mainly three tables :
    ORDER : Table that contains description for each Order (approximately 1 000 000 Records)
    ORDER_MVTS : Table that contains the tasks made (called movements) to set up each Orders
    with quantity of packages prepared for each product (approximately 10 000 000 Records)
    PRODUCT : Tables that contains the products (approximately 50 000 Records)
    When I launch the query with hard coded values, it brings back response very fast
    because it uses the right index (ORDER_DHR_VALID) which represent the date and hour of the order
    (with format 'DD/MM/YYYY HH24:MI:SS'). The selectivity for this index is good.
    NB 1: I have to use the trick " >= Trunc(date) and < trunc(date) +1 " to filter on a simple date because
    the index contains hour and minutes (I know it wasn't probably a bright idea at conception time).
    NB 2: The index on ORDER_MVTS.PRODUCT_CODE is'nt discriminating enough because there is'nt enough different products.
    It's the same for index on CUSTOMER_CODE and on MVT_TYPE so only the index on ORDER.DHR_VALID is good.
    Here is the correct explain plan when I execute the query with hard coded values :
    SELECT SUM(ORDER_MVTS.NB_PACKAGE)
    FROM ORDER_MVTS, PRODUCT, ORDER
    WHERE ORDER.DHR_VALID >= TRUNC(to_date('14/11/2008 10:04:56','DD/MM/YYYY HH24:MI:SS'))
    AND ORDER.DHR_VALID < TRUNC(to_date('14/11/2008 10:04:56','DD/MM/YYYY HH24:MI:SS')) + 1
    AND ORDER_MVTS.MVT_TYPE = 'DELIVERY'
    AND PRODUCT.CODE = ORDER_MVTS.PRODUCT_CODE
    AND ORDER_MVTS.ORDER_CODE = ORDER.CODE
    AND ORDER.CUSTOMER_CODE = 'ADIDAS'
    AND PRODUCT.CODE = 1234
    Rows Row Source Operation
    1 SORT AGGREGATE
    2 NESTED LOOPS
    4 NESTED LOOPS
    2 INDEX UNIQUE SCAN (object id 378548) --> PRODUCT_PK
    4 TABLE ACCESS BY INDEX ROWID ORDER
    777 INDEX RANGE SCAN (object id 378119) --> ORDER_DHR_VALID
    2 TABLE ACCESS BY INDEX ROWID ORDER_MVTS
    30 INDEX RANGE SCAN (object id 377784) --> ORDER_MVTS_ORDER_FK
    Now the problem is when the query is used in a Cursor with bind variables.
    It seems like Oracle don't use index on ORDER.DHR_VALID because he can't figure out that he have
    to actually filter on a short period of time (only one day).
    So Oracle uses the index on ORDER_MVTS.PRODUCT_CODE which is'nt a bright idea (it takes 10 secondes instead of just one)
    Here is the bad explain plan :
    Rows Row Source Operation
    1 SORT AGGREGATE
    2 NESTED LOOPS
    722 NESTED LOOPS
    2 INDEX UNIQUE SCAN (object id 378548) --> PRODUCT_PK
    722 TABLE ACCESS BY INDEX ROWID ORDER_MVTS
    1790 INDEX RANGE SCAN (object id 377777) --> ORDER_MVTS_PRODUCT_FK
    2 TABLE ACCESS BY INDEX ROWID ORDER
    1442 INDEX UNIQUE SCAN (object id 378439) --> ORDER_PK
    Now I have found two solutions to this problem :
    1) using a Hint to force the use of index on ORDER.DHR_VALID (with /*+ INDEX(ORDER ORDER_DHR_VALID) */ )
    2) Using Dynamic SQL and keeping the date hard coded (but not the other values except mvt_type)
    For example :
    QUERY :=
    'SELECT SUM(ORDER_MVTS.NB_PACKAGE)
    FROM ORDER_MVTS, PRODUCT, ORDER
    WHERE ORDER.DHR_VALID >= TRUNC(TO_DATE('''||To_char(P_DTE_VAL,'DD/MM/YYYY')||''',''DD/MM/YYYY'')) '||
    AND ORDER.DHR_VALID < TRUNC(TO_DATE('''||To_char(P_DTE_VAL,'DD/MM/YYYY')||''',''DD/MM/YYYY'')) + 1 '||
    AND ORDER_MVTS.MVT_TYPE = 'DELIVERY'
    AND PRODUCT.CODE = ORDER_MVTS.PRODUCT_CODE
    AND ORDER_MVTS.ORDER_CODE = ORDER.CODE
    AND ORDER.CUSTOMER_CODE = :CUSTOMER
    AND PRODUCT.CODE = :CODE ';
    These two solutions work but Number 1 is bad in theory because it uses a Hint
    and Number 2 may be difficult to code.
    So my question is : Does someone knows another solution to force the use of index ORDER_DHR_VALID that can be simple and reliable.
    Thank you very much for support
    Edited by: remaï on Apr 1, 2009 4:08 PM

    What version of oracle you have? CBO work is different in 9i and 10g.
    Usually cost based optimizer do not want to use index for >< condition with binding variables because optimizer can not use statistic to determine selectivity, and by default selectivity of <> operators is low.
    (As I remember '>' selectivity by default is 5%, you have two conditions > and <, therefore resulting selectivity will be 0.05*0.05=0.0025 as two independent events, but selectivity of other conditions
    ORDER_MVTS.MVT_TYPE = 'DELIVERY' or ORDER.CUSTOMER_CODE = 'ADIDAS' looks much better for CBO)
    The best solution I see is do not use binding variables. Actually your query looks as searching query, which executes not so often, therefore you will not have perfomance win along of skipping execution plan creation.
    Edited by: JustasVred on Apr 1, 2009 10:10 AM

  • Using Bind Variable in a SELECT

    Hi,
    I'm trying to build up my SQL query at run-time using bind variables and in the Oracle® Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework 11g Release 1 (11.1.1) it says that 'After defining the bind variables, the next step is to reference them in the SQL statement. While SQL syntax allows bind variables to appear both in the SELECT list and in the WHERE clause, you'll typically use them in the latter context, as part of your WHERE clause.'.
    However, when I try to use the bind variables in my SELECT list because I've had to set a type for the variable to String the variable gets inserted with inverted commas either side e.g. SELECT 'Service' FROM TestTable. Is it possible to use bind variables to insert a value into my select list without these inverted commas around it?
    Thanks in advance,
    Tom

    OK, thanks for your response. Do you know of a way then where I can control my SELECT parameters programmatically? I'm currently trying to do it using the information in the chapter '35.9 Using Programmatic View Objects for Alternative Data Sources' from the Oracle® Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework 11g Release 1 (11.1.1). I think I'm part way there, would this be the correct way of acheiving what I want?
    Cheers, Tom

  • Using bind variable with IN clause

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

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

  • Performance when using bind variables

    I'm trying to show myself that bind variables improve performance (I believe it, I just want to see it).
    I've created a simple table of 100,000 records each row a single column of type integer. I populate it with a number between 1 and 100,000
    Now, with a JAVA program I delete 2,000 of the records by performing a loop and using the loop counter in my where predicate.
    My first JAVA program runs without using bind variables as follows:
    loop
    stmt.executeUpdate("delete from nobind_test where id = " + i);
    end loop
    My second JAVA program uses bind variables as follows:
    pstmt = conn.prepareStatement("delete from bind_test where id = ?");
    loop
    pstmt.setString(1, String.valueof(i));
    rs = pstmt.executeQuery();
    end loop;
    Monitoring of v$SQL shows that program one doesn't use bind variables, and program two does use bind variables.
    The trouble is that the program that does not use bind variables runs faster than the bind variable program.
    Can anyone tell me why this would be? Is my test too simple?
    Thanks.

    [email protected] wrote:
    I'm trying to show myself that bind variables improve performance (I believe it, I just want to see it).
    I've created a simple table of 100,000 records each row a single column of type integer. I populate it with a number between 1 and 100,000
    Now, with a JAVA program I delete 2,000 of the records by performing a loop and using the loop counter in my where predicate.
    Monitoring of v$SQL shows that program one doesn't use bind variables, and program two does use bind variables.
    The trouble is that the program that does not use bind variables runs faster than the bind variable program.
    Can anyone tell me why this would be? Is my test too simple?
    The point is that you have to find out where your test is spending most of the time.
    If you've just populated a table with 100,000 records and then start to delete randomly 2,000 of them, the database has to perform a full table scan for each of the records to be deleted.
    So probably most of the time is spent scanning the table over and over again, although most of blocks might already be in your database buffer cache.
    The difference between the hard parse and the soft parse of such a simple statement might be negligible compared to effort it takes to fulfill each delete execution.
    You might want to change the setup of your test: Add a primary key constraint to your test table and delete the rows using this primary key as predicate. Then the time it takes to locate the row to delete should be negligible compared to the hard parse / soft parse difference.
    You probably need to increase your iteration count because deleting 2,000 records this way probably takes too short and introduces measuring issues. Try to delete more rows, then you should be able to spot a significant and constant difference between the two approaches.
    In order to prevent any performance issues from a potentially degenerated index due to numerous DML activities, you could also just change your test case to query for a particular column of the row corresponding to your predicate rather than deleting it.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • How to use bind variables in this procedure

    Hi Experts,
    How to use bind variables in this procedure for static queries.
    PROCEDURE DELETE_MER_PROC (M_id IN NUMBER)
    IS
    BEGIN
    V_date DATE;
    SELECT PD_DATE INTO v_date FROM PD_MAINTAIN;
        DELETE FROM MER_CLEAR
        WHERE MER_DT < v_date
        AND ID = M_ID;
    COMMIT;
    END;   
    How to use  v_date and m_id as bind variables in this procedure to avoid hard parsing.
    Please help me.
    Thanks.

    976208 wrote:
    How to use  v_date and m_id as bind variables in this procedure to avoid hard parsing.
    You cannot avoid hard parsing - as the 1st time a SQL statement (like the SELECT or DELETE statements in your code) is encountered, it does not reside in the server's Shared Pool, and needs to be added into the pool via a hard parse.
    Bind variables does not prevent hard parsing. Hard parsing happens when the SQL statement (with or without bind variables) is a brand new statement encountered by the server.
    Bind variables enables the same SQL cursor to be reused, by simply changing the bind variable value.
    Not using bind variables means that each SQL statement is unique and not shareable - as the value is hardcoded into the statement and cannot be changed via a bind value. This typically means LOTS of different SQL statements (where the only difference is the changed value in the statement) are created - with each statement being a new statement not seen before in the Shared Pool and needing to be hard parsed.
    One does not design one's code not to be hard parsed. There ALWAYS will be a hard parse in order to get a SQL statement into the Shared Pool. One designs one's code to REUSE cursors in the Shared Pool.

Maybe you are looking for

  • Dont work 'REUSE_ALV_FIELDCATALOG_MERGE' with table type

    Hi Experts ; My problem about   'REUSE_ALV_FIELDCATALOG_MERGE' . I use intarnal table with Table Type ( with header line ). And 'REUSE_ALV_FIELDCATALOG_MERGE'  is not working . Field catalog is employ. I dont use 'REUSE_ALV_FIELDCATALOG_MERGE' have a

  • Writing binary data to file ???

    Hi all, I am facing a strange problem in my java program. Please go through the following code... import java.io.*; public class Hex2BinFile Hex2BinFile() boolean hex2bin(String source,String destFile) try PrintWriter opGif = new PrintWriter ( new Fi

  • How can I remove the Facebook Exporter Plugin (32-bit) designed for AP2?

    Now that I have A3 which has native ability to export to Facebook, I wanted to delete this plugin I have used and downloaded from the plugin page. This plugin does not create/provide a plugin that is supposed to reside in the Library/Application Supp

  • Adobe to Word Doesnt WorK

    Please Help me to conect to word and trasfer my adobe document. The Program didnt allow me to change the Program doesnt matter I have already paid. Dr. Wanda Soto

  • 10.6.8 to 10.8.4

    Hi! I just bought a AirPort Time Capsule. It works with my MacBook Pro, but it doesn't with my iMac, which is still under 10.6.8. In that case, do I have to update my iMac to 10.8.4, or is there a workaround? If not, will updating my iMac from 10.6.8