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?
Similar Messages
-
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) -
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 -
How to pass a value to a bind variable in a query report in oracle apex
Hi Guys,
I have requirement to send weekly reports via email to some users. The users should receive their own records in the report. The user details is stored in a table. What I am planning to do is to create a report query in oracle apex to generate the report and then run a function/procedure via a scheduler to email the report to respective users. Now my query is ............. is it possible to pass a value (user name) to the report query to pull records of only that user? I know we can have bind variables in the report query but I have no idea how to pass a value for bind variables from a function/procedure.
Can anyone help me on this issue or suggest a better approach?
Thanks,
SanYou need to use dynamic sql
But please keep in mind that since you're using Oracle you may be better off posting this in some Oracle forums
This forum is specifically for SQL Server
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
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 -
How to use bind variable in the query to avoid hard parsing
Hi,
I have a query which is using literals
strquery:='SELECT SUMTOTAL FROM tab1 WHERE BATCHNO = '''
|| gBNo
|| ''' AND A_ID = '''
|| g_id
|| ''' AND L_ID = '''
|| g_LId
|| ''' AND S_Code = ''C_3'' ';
execute immediate strquery;I have been asked to use a bind variable to avoid hard parsing.
How do i do it?
Edited by: user8731258 on Jul 27, 2012 5:07 AM
Edited by: user8731258 on Jul 27, 2012 5:08 AMYou dont need Dynamic SQL. Your Table and Column Name are static in that query. Just use Static SQL
SELECT SUMTOTAL
INTO lSumTotal
FROM tab1
WHERE BATCHNO = gBatchNo
AND ATM_ID = gAtm_id
AND LOAD_ID = gLoadId
AND STEP_CODE = 'C_3'; -
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.
-
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 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 offI 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") -
How to use SYSDATE as a default value of a bind variable in a query report?
Hi,
I want to use SYSDATE as default value for a bind variable in Query based report.
I don't see any way to do it, someone helps?
Thanks a lot.
Paulo.You can aslo use #sysdate directly.
Hi,
The way I'm doing in my report is, I have a database function (f_ret_sysdate) with the following code
create function f_ret_sysdate return varchar2
begin
return to_char(sysdate,'mm/dd/yyyy');
end;
Now, in the 'Customization Form Display Options' section of the report I'm calling this function as #f_ret_sysdate in the default value field of corresponding bind variable to display SYSDATE with the format.
Hope this helps!...
-Krishnamurthy -
IF NEW VARIABLE IN SQL QUERY, DISPLAYS AS LAST COLUMN + rpad not working
Hello everybody and thank you in advance,
1) if I add a new variable to my sql query to select a column which was already in the table, it shows it in the report table as the Last column to the right. That is, if I add "street" to
something like city, postcode, street, store, manager, etc, instead of placing street between postcode and store, it places it as i said as the last column to the right.
2) When values are entered into the cells of the tables, yes, they do expand it to their needed lenght, But, only if it is one word. If it is two, like when i enter the value "very good"
then it takes two lines so as with a carriage return within the cell, thus, making it too high the row. I tried to padd spaces with rpad but it did not work. something like rpad(stock, 20,' ')
I must say that the table is in the same page where there is a Form, so as the table grows in lenth it is actually squeezing the form located right on its left.
3) rpad did not work with the most simple syntax, but less would with what i need because it turns out i am using DECODE in order to do a conversion between value displayed and
value returned in my select list of values, something like : DECODE (TO_CHAR (stock),'1','Deficient','2','Average','3','Good','4','Very Good',null) AS stock,
so, i have tried to put the rpad there in several places but either it gave parsing error or it left the column empty not picking any values.
thank you very much
AlvaroAlvaro
1) That is standard behaviour of apex builder. You can change the display order with the arrows in the report attributes column report.
2) You will have to play with the style attributes of the column to accomplice this. For instance style="white-space:pre;" in the Element Attributes of the column attributes. White-space:normal would thread several space (' ') as 1. So no matter how many you add with rpad they will be shown as 1.
Or set a width either as attibute or in a style class for that column.
Nicolette -
Passing Session State Variables to SQL query
Hi,
I am using 3 pages in my application build by APEX 3.1.2. Login Page, Report Page and Form Page.
I am using LDAP authentication for Login Page and I want the user session information to be feeded to the filter query
being used to display data on Report Page. Is there any way to do that. I know
there is one variable %LDAP_USER% which is using the userid given on login
page. But I dont know how to use APEX session variables to filter query. Need
assistance on that stuff.
Thanks,
GauravHi Gaurav,
Session "variables" (global items, application items and page items) can be accessed using v('ITEM_NAME') (for strings) or nv('ITEM_NAME') (for numbers) within sql queries/procedures/triggers etc.
If you look at the Substitution Strings section here: http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10499/index.htm#S you'll find more information about this and a list of items that you can use that are set by Apex itself.
Andy -
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
JimHi 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 -
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 SonntagWe 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
Maybe you are looking for
-
TV @nywhere Master MSIPVS Does Not Work With P4 Hyperthreading
For some months now I have been tracking down a problem that has plagued a large number of members in this forum. The symptoms of this problem are the intermittent freezing of the MSIPVS picture and the inability to exit MSIPVS, forcing a reboot to e
-
Problem with speaker in Skype.
Hello, i have problem with Skype on Xperia Z2, if i missed call (in skype), top speaker will off and would work only for phone calls, but if listen music, play video and game would work only bottom speaker, if sign out from skype and close it in mult
-
How to connect Apple TV without HDMI input, what are my options?
I don't have HDMI input on my TV, but I have RCA, RGB, S-Video, Audio input, and a few others. What options exist to make the Apple TV work and still get HD quality (aside from getting a new TV)? Thanks!
-
How can I change my backup e-mail?
My Apple ID has an email that is not mine and i cannot reset my security info. Is there a way i can change my backup email?
-
HELP!! Volume slider dimmed in track info--using Shure 8900W mic + iMic
After much back and forth at the Apple Retail store, I was talked into buying a Shure 8900W microphone plus a Griffin iMic for recording vocals in GB3. I'm on a MacBook Pro running Tiger (10.4.7). I've done all the right stuff--in both system prefere