Bind variables in SQL Developer
I declared a bind variable called 'test_num' and assigned a value of 10 as shown below.
variable test_num number
BEGIN
:test_num := 10;
dbms_output.put_line ('The Test Value: ' || :test_num);
END;
When I execute the above program, the output is thrown as 'The Test Value: '. The value of test_num is not shown. I fear whether this issue is due to SQL Developer which i am using to execute this program.
Please let me know why the value is not getting printed
Thanks for your help!
I see the same issue you are seeing when using the bind variable. The bind variable works fine in SQL*Plus but not from SQL Developer.
From SQLPlus*
SQL> set serveroutput on
SQL> variable test_num number
SQL> BEGIN
2 :test_num := 10;
3 dbms_output.put_line ('The Test Value: ' || :test_num);
4 END;
5 /
The Test Value: 10
PL/SQL procedure successfully completed.
From SQLDeveloper*
set serveroutput on
variable test_num number
BEGIN
:test_num := 10;
dbms_output.put_line ('The Test Value: ' || :test_num);
END;
anonymous block completed
The Test Value:
Similar Messages
-
Prompt for bind variables in SQL developer
Hi!
Just installed the latest 3.2 version of SQL Developer, and tried to do an explain plan.
Now the tool prompts me for values for the bind variable. It didn't do that in my previous version (version 3. something).
Thats anoying :-)
How do I disable that feature?
Example:
explain plan for
select * from emp
where department_id = :1;
If i right click on the statement or press F10, I get no prompt for the bind variable...
Regards
SørenOld fashioned way, like this:
EXPLAIN PLAN FOR
SELECT * FROM scott.emp
where deptno = :1;
SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());
Executed with F5 gives me this output
plan FOR succeeded.
PLAN_TABLE_OUTPUT
Plan hash value: 3956160932
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5 | 190 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| EMP | 5 | 190 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("DEPTNO"=TO_NUMBER(:1))
13 rows selected -
Using Bind variables in SQL PLUS Report
using Bind variables in SQL PLUS Report. This report gets the arguments from the application concurrent program. Now my need is to convert the start_date and end_date to bind Variables to improve the performance. I have commented the original code in 'prompt List of Unapproved Adjustments' and used my Bind Variable but it is giving an error
error: Bind Variable "ENDING_DATE" not declared
Report Date and Time:
26-OCT-2010 15:44:13
List of Unapproved Adjustments
Bind Variable 'ENDING_DATE" not declared
Please see below the code for the sql plus report:
define p_org_id = '&1'
define p_fy_begin_date = '&2'
define p_start_date = '&3'
define p_end_date = '&4'
define p_conversion = '&5'
declare
variable begin_date date;
exec :begin_date := p_start_date;
variable ending_date date;
exec :ending_date := p_end_date;
/* Begin
:begin_date := to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS');
:ending_date := to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS');
End; */
set newpage none
set termout off
set pagesize 55
set linesize 180
set heading on
set feedback off
set wrap off
set space 1
set heading on
begin
dbms_application_info.set_client_info('&p_org_id');
end;
prompt
prompt Report Date and Time:
prompt ----------------------
select to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')
from dual ;
prompt
prompt List of Unapproved Adjustments
prompt -------------------------------
select b.trx_number,
a.adjustment_number,
f.user_name created_by
from apps.ar_adjustments a,
apps.ra_customer_trx b,
apps.fnd_user f
where a.customer_trx_id = b.customer_trx_id
and a.status <> 'A'
and a.created_by = f.user_id
and a.creation_date between :begin_date
and :ending_date
-- and a.creation_Date between to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS')
-- and to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS')
order by
b.trx_number ;Hi
Please go to customization part of the report and verify..You have set a default value out there ..And also verify your lov and look at the values ..If it is again giving you the problem ..pl delete the report and develop it again from the scratch it will be solved...
vishnu
null -
Passing values in a vector list as bind variables in sql query.
Hi,
I have a vector list containing values 12,13,14.
vector<string> v;
v has values 12,13 and 14.
Here the number of values in vector list are not fixed.
I want to pass these values as bind variables to sql query.
Can anyone suggest me how to do this.
Thanks in advance!!Ah, the it's the classic 'Varying In-List' again
See:
The Tom Kyte Blog: Varying in lists...
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:110612348061 (started more than a decade ago, so scroll down for more recent examples) -
Bind variables in SQL query of DBAdapter
Hi,
Can we add bind variables to SQL query when we define DB adapter...?No, not in the Wizard.
I do not know if it is possible with the TopLink in combination with BPEL.
But can you use a Pl/SQL procudere/package that performs the dynamic SQL? -
Got an error while creating bind variables using sql database.
iam going to use sql database for ADF-BC .
i created the bind variable and apply the bind position for the corresponding variable in the view object editor.when i click test it shows me "query is valid". when i tried to run that it gives me two errors.
1) sql error during statement preparation.(ie) select empid ,empname......from the emptable where empid like :'emp' and
2) [Microsoft][SQl server 2000 driver for jDBC] invalid parameter bindings
i need help to know the solution for this...(or) is there any other way to create bind variable ......The 3 binding styles supported by JDev:
Oracle Named - ie. SELECT xxxx FROM xxxx WHERE emp_id = :vEmp (note colon and variable name)
Oracle Positional - ie SELECT xxxx FROM xxxx WHERE emp_id = :1 (note colon)
JDBC Positional - ie SELECT xxxx FROM xxxx WHERE emp_id = ?
Literally this query is sent to the database to execute, then the bind variables values are applied as a separate database operation. If SQL Server doesn't suport any of these binding styles, it's not going to work. As Chris Noonan suggests, try the JDBC Positional style though as you're using a JDBC driver to connect to SQL Server and it should support that style (the others are Oracle styles), and make sure you've switched the binding style on the VO query page to "JDBC Positional" too.
You must also on the VO bind variable page define your bind variables.
Also read the 10.1.3 JDev guide on ADF Business Components and View Object bind variables.
CM. -
Decode using bind variable in SQL
I have decode statement in my SQL query which is used to define the VO object. I want to select a column depending on the value entered for the bind variable :1. dont know how to implement this in OAF - any pointers will be appreciated.
decode(:1,'XO2C_CUST_SERV_REP',XO2C_CUST_SERV_REP,'XO2C_ACCOUNT_MGR',XO2C_ACCOUNT_MGR,'XO2C_CTS_ENGINEER',XO2C_CTS_ENGINEER ) "contact names"
Thanks!!I have decode statement in my sql for the VO and the VO is executed when the user clicks the GO button(user initiated search and over-riding the default Go button).
When I click the Go button , I am calling a method called Uneditable in my AM which appends the decode variable using the whereclause append but it is failing with an exception "java.sql.SQLException: Missing IN or OUT parameter at index:: 1". Can someone let me know if I am doing anything indifferently which is causing the program/sql query to fail.
Binding style of the VO is "Oracle Named" - is this causing the problem?
ProcessFormRequest:
=============
if ("ClickGo".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
OAApplicationModule am = pageContext.getApplicationModule(webBean);
System.out.println("Go Button pressed>> "+am);
OATableBean table = (OATableBean) webBean.findChildRecursive("USSContactMainVO1");
System.out.println("before QueryData");
//table.queryData(pageContext,false);
System.out.println("before Boolean executeQry");
Boolean executeQuery = BooleanUtils.getBoolean(false);
System.out.println("Get PartyName");
String v_PartyName = pageContext.getParameter("xxPartyName");
System.out.println("Get SalesContactQry");
String v_SalesContact = pageContext.getParameter("SalesContact_qry");
System.out.println("Party Name :" + v_PartyName + " Sales contact:" + v_SalesContact);
Serializable[] parameters = {v_PartyName, v_SalesContact,executeQuery };
Class[] paramTypes = { String.class, String.class, Boolean.class };
am.invokeMethod("uneditable",parameters,paramTypes);
Uneditable(AM)
=========
public void uneditable(String v_PartyName, String v_SalesContact,
Boolean executeQuery){
System.out.println("Im in uneditable..to call VO");
USSContactMainVOImpl vo1= getUSSContactMainVO1();
String Voqry =vo1.getQuery();
//System.out.println("Query is :"+ Voqry);
StringBuffer whereClause = new StringBuffer(100);
Vector parameters = new Vector(3);
int clauseCount = 0;
int bindCount = 0;
System.out.println("debug1");
vo1.setWhereClauseParams(null); // Always reset
System.out.println("check the params");
if ((v_SalesContact != null) && (!("".equals(v_SalesContact.trim()))))
System.out.println("Sales:"+v_SalesContact);
whereClause.append(v_SalesContact);
System.out.println("bindcount");
whereClause.append(++bindCount);
clauseCount++;
System.out.println("setWhereclas");
vo1.setWhereClause(whereClause.toString());
System.out.println("setWhereclasParam");
vo1.setWhereClauseParams(null);
System.out.println("setWhereclasParam-2");
vo1.setWhereClauseParam(0,v_SalesContact);
if ((v_PartyName != null) && (!("".equals(v_PartyName.trim()))))
whereClause.append(" Party_Name like :");
whereClause.append(++bindCount);
clauseCount++;
vo1.setWhereClause(whereClause.toString());
vo1.setWhereClauseParams(null);
//vo1.setWhereClauseParam(0,v_PartyName);
vo1.setWhereClauseParam(1,v_PartyName);
System.out.println("Query is :" + vo1.getQuery()); //prints this debug msg but fails while executnig the vo
vo1.executeQuery();
Row[] rows1=vo1.getAllRowsInRange();
USSContactMainVORowImpl row = null;
for (int i = 0; i < rows1.length; i++)
System.out.println(" Rows Found "+i);
row = (USSContactMainVORowImpl)rows1;
row.setAttribute("CTSEngineer_TR",Boolean.FALSE);
//end of uneditable
It appends the 2nd parameter and prints System.out.println("Query is :" + vo1.getQuery()) without any issues but think fails when trying to execute the VO.
Error Stack :
=======
oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (SELECT hp.party_name,hp.party_number registry_id, hps.party_site_number Site_Number, hca.account_number,
hca.account_name acc_desc,
hl.address1
|| ''
|| hl.city
|| ''
|| hl.postal_code
|| ''
|| hl.state "Address",
xagv.xo2c_entering_unit "Entering_Unit",
DECODE(hou.Short_code,'USS CA OU','CA','USS USA OU','US') "Operating_Unit",DECODE('.',null,null) "CTS", DECODE(:1,'Customer Service Rep',XO2C_CUST_SERV_REP,'Account Manager',XO2C_ACCOUNT_MGR,'CTS Engineer',XO2C_CTS_ENGINEER ) "Contact Names" FROM hz_parties hp,
hz_party_sites hps,
hz_cust_accounts hca,
hz_cust_acct_sites_all hcs,
hz_locations hl,
xo2c_ship_to_sales_o_agv xagv,
hr_operating_units hou
WHERE 1 = 1
AND hp.party_id = hps.party_id
AND hp.party_id = hca.party_id
AND hcs.party_site_id = hps.party_site_id
AND hca.cust_account_id = hcs.cust_account_id
AND hps.location_id = hl.location_id
AND hcs.status = 'A'
AND xagv.party_site_id = hps.party_site_id
AND xagv.party_site_id = hcs.party_site_id
AND hou.ORGANIZATION_ID=hcs.ORG_ID) QRSLT WHERE (CTS Engineer1 Party_Name like :2)
at oracle.apps.fnd.framework.OAException.wrapperException(Unknown Source)
at oracle.apps.fnd.framework.OAException.wrapperException(Unknown Source)
at oracle.apps.fnd.framework.OAException.wrapperInvocationTargetException(Unknown Source)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(Unknown Source)
at xxuss.oracle.apps.xo2c.contactmaintenance.webui.USSContactMainCO.processFormRequest(USSContactMainCO.java:105)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at OA.jspService(_OA.java:71)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
## Detail 0 ##
java.sql.SQLException: Missing IN or OUT parameter at index:: 1
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175)
at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1566)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2996)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3043)
at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:857)
at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:666)
at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:3655)
at oracle.jbo.server.OAJboViewObjectImpl.executeQueryForCollection(Unknown Source)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQueryForCollection(Unknown Source)
at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:742)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:891)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:805)
at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:799)
at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:3575)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQuery(Unknown Source)
at xxuss.oracle.apps.xo2c.contactmaintenance.server.USSContactMainAMImpl.uneditable(USSContactMainAMImpl.java:244)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(Unknown Source)
at xxuss.oracle.apps.xo2c.contactmaintenance.webui.USSContactMainCO.processFormRequest(USSContactMainCO.java:105)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at OA.jspService(_OA.java:71)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
java.sql.SQLException: Missing IN or OUT parameter at index:: 1
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175)
at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1566)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2996)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3043)
at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:857)
at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:666)
at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:3655)
at oracle.jbo.server.OAJboViewObjectImpl.executeQueryForCollection(Unknown Source)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQueryForCollection(Unknown Source)
at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:742)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:891)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:805)
at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:799)
at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:3575)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQuery(Unknown Source)
at xxuss.oracle.apps.xo2c.contactmaintenance.server.USSContactMainAMImpl.uneditable(USSContactMainAMImpl.java:244)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(Unknown Source)
at xxuss.oracle.apps.xo2c.contactmaintenance.webui.USSContactMainCO.processFormRequest(USSContactMainCO.java:105)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at OA.jspService(_OA.java:71)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
Edited by: MyOAF on Jan 14, 2010 11:03 PM -
Error using bind variables with SQL server with SQL92 mode
I am using 2 bind variable in my VO (JDBC positional) . The mode is SQL 92 for ADF BC. I do not use the bind variable directly but in a view criteria. I see following error in the logs.
The logs show the query executed and error. I tried both ways - making bind variable required and not required. I have set -Djbo.SQLBuilder=SQLServer property. My other page works which has an updatable VO.
JDEV version is - JDEVADF_11.1.1.7.0_GENERIC_130226.1400.6493
<ViewObjectImpl> <getQueryHitCount> [4567] Estimated Row Count for ViewObject: [oracle.epm.fm.bc4j.queries.admin.UserOnSystemROVO]AdministrationAM.UserOnSystemROVO1, Query Statement:
<ViewObjectImpl> <getQueryHitCount> [4568] "SELECT count(1) FROM (SELECT * FROM (SELECT
TABLE1.SUSERNAME USERNAME,
TABLE2.SMODULENAME MODULENAME,
TABLE2.LACTIVITYCODE ACTIVITYCODE,
TABLE2.DSTARTTIME STARTTIME,
TABLE2.SSERVERNAME SERVERNAME,
TABLE2.SAPPNAME APPNAME,
TABLE2.LSESSIONID SESSIONID,
TABLE2.LSESSIONSTATUS SESSIONSTATUS,
TABLE2.LUSERID USERID,
TABLE2.DSTILLALIVETS STILLALIVETS,
TABLE2.LTASKID TASKID,
TABLE2.SACTIVITYDESC ACTIVITYDESC,
TABLE1.LUSERID USERID1,
TABLE1.SUSERDESC USERDESC
FROM
TABLE2 TABLE2,
TABLE1 TABLE1
WHERE
TABLE2.LUSERID = TABLE1.LUSERID) QRSLT WHERE ( ( ( ( UPPER(SERVERNAME) = UPPER(?) ) OR ( ? IS NULL ) ) AND ( ( UPPER(APPNAME) = UPPER(?) ) OR ( ? IS NULL ) ) ) )) ESTCOUNT"
<ViewObjectImpl> <getQueryHitCount> [4569] Bind params for ViewObject.getQueryHitCount: UserOnSystemROVO1
<ViewRowSetImpl> <doSetWhereClauseParam> [4570] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(0, null, null)
<ViewRowSetImpl> <doSetWhereClauseParam> [4571] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(1, null, null)
<ViewRowSetImpl> <doSetWhereClauseParam> [4572] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(4, null, null)
<ViewRowSetImpl> <doSetWhereClauseParam> [4573] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(5, null, null)
<ViewRowSetImpl> <doSetWhereClauseParam> [4574] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(2, null, null)
<ViewRowSetImpl> <doSetWhereClauseParam> [4575] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(3, null, null)
<ADFLogger> <addContextData> Estimated row count
<BaseSQLBuilderImpl> <bindParamValue> [4576] Binding null of type 12 for 1
<BaseSQLBuilderImpl> <bindParamValue> [4577] Binding null of type 12 for 2
<BaseSQLBuilderImpl> <bindParamValue> [4578] Binding null of type 12 for 3
<BaseSQLBuilderImpl> <bindParamValue> [4579] Binding null of type 12 for 4
<BaseSQLBuilderImpl> <bindParamValue> [4580] Binding null of type 12 for 5
<ViewObjectImpl> <getQueryHitCount> [4581] ViewObjectImpl.getQueryHitCount failed...
<ViewObjectImpl> <getQueryHitCount> [4582] java.sql.SQLException: [FMWGEN][SQLServer JDBC Driver]Invalid parameter binding(s).
at weblogic.jdbc.sqlserverbase.dda4.b(Unknown Source)
at weblogic.jdbc.sqlserverbase.dda4.a(Unknown Source)
at weblogic.jdbc.sqlserverbase.dda3.b(Unknown Source)
at weblogic.jdbc.sqlserverbase.dda3.a(Unknown Source)
at weblogic.jdbc.sqlserverbase.ddb8.a(Unknown Source)
at weblogic.jdbc.sqlserverbase.ddb9.a(Unknown Source)
at weblogic.jdbc.sqlserverbase.ddb9.setNull(Unknown Source)
at weblogic.jdbc.wrapper.PreparedStatement.setNull(PreparedStatement.java:622)
at oracle.jbo.server.BaseSQLBuilderImpl.bindParamValue(BaseSQLBuilderImpl.java:2215)
at oracle.jbo.server.BaseSQLBuilderImpl.bindParametersForStmt(BaseSQLBuilderImpl.java:3687)
at oracle.jbo.server.ViewObjectImpl.bindParametersForCollection(ViewObjectImpl.java:22684)
at oracle.jbo.server.ViewObjectImpl.getQueryHitCount(ViewObjectImpl.java:4944)
at oracle.jbo.server.ViewObjectImpl.getQueryHitCount(ViewObjectImpl.java:4857)
at oracle.jbo.server.QueryCollection.getEstimatedRowCount(QueryCollection.java:4204)
at oracle.jbo.server.ViewRowSetImpl.getEstimatedRowCount(ViewRowSetImpl.java:2677)
at oracle.jbo.server.ViewObjectImpl.getEstimatedRowCount(ViewObjectImpl.java:10632)After making all the bind variables not required, the error is no longer coming.
-
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 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 -
Host variables in SQL Developer not showing decimal places
I'm a very newbie, taking my first PL/SQL class, so please be gentle! I think this may be a SQL Developer problem, because when I run the same thing from terminal-line SQLplus on my Linux install, it works right.
I'm working with a procedure, and passing a value out to a host variable. Although the value should have a decimal portion, when I print the host variable, all that prints is the integer portion.
Here's the entire program:
set serveroutput on;
create or replace package mypkg
is
procedure myproc
(p_in in number,
p_out out number);
end;--END package mypkg
create or replace package body mypkg
is
procedure myproc
(p_in in number,
p_out out number)
is
lv_out_num number(7,2);
begin
lv_out_num := p_in / 10.0;
p_out := lv_out_num;
dbms_output.put_line('p_out is ' || to_char(p_out,'999.99' ));
end;--END procedure myproc
end;--END package body mypkg
variable myvar number
execute mypkg.myproc(33,:myvar);
print :myvarAnd here's the output:
PACKAGE mypkg compiled
PACKAGE BODY mypkg compiled
anonymous block completed
p_out is 3.30
MYVAR
3As you can see, myvar should be 3.3, but it only shows 3. However, like I said above, when I do this from sqlplus from a terminal in linux, it works fine. Thus I'm thinking its a SQL Developer thing.
Details:
Machine:
HP Pavilion dv6 notebook (Core i7) with 8 GB RAM
Windows side:
Windows 7 Home Premium SP1
Oracle 10g Express
SQL Developer 3.1.06
Linux side:
Oracle Linux 5.6 (in Virtualbox)
Oracle 11g release 1
Thanks,
AlexHi,
This issue has been previously reported on and bugged:
Re: Oracle Sql Developer prblem with variable format
Regards,
Gary -
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") -
Bind variables in SQL Editor - not remembering datatypes, values
When you execute a query with bind variables, the dialogue appears to specify value and type of bind variable. It would be a nice feature if when you re-ran the query Raptor remembered the type and previous value of the bind variable.
Mike.I would like it if there was only one window with a list of all bind variables so I can edit them in one go instead of a new window for each bind variable.
kind regards
Leon Parren -
Hide new/old value of bind variable in SQL*Plus
Hi,
I have a SQL*Plus script to create a new user. It asks for username & password and then passes these values to a SP to do some checks and finally create the user.
The output is currently the following :
New user will be created in ORCL LAB
Enter the requested username : fleet2
Enter the password for fleet2 : *****
Re-enter the password for fleet2 : *****
old 2: labadmin_cr_user('&username', '&pswd', '&pswd2');
new 2: labadmin_cr_user('fleet2', 'fleet', 'fleet');
The requested username is already in use in the database. Please choose another username.
As you can see the passwords are now exposed when the procedure is called. This is not what I want off course. I cannot do termout off as the serveroutput is not shown as well in that case. I use dbms_output to show error messages to users. (see example above in case of an existing user).
Can anybody tell me how to hide these 2 lines (old 2, new 2) without hiding my dbms_output.
Thanks!
Krisset verify offhttp://download-uk.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1013382
Maybe you are looking for
-
Actually we have 10.5.8, 10.6.8 and 10.7.2 computers. All of them share this problem.
-
Run time error after starting eclipse
Hello, after installation of the SAP Eclipse Theme Editor the following run time error is reported after each restart of eclipse: java.lang.ClassCastException: com.sap.ur.plugins.ThemeEditor32Input cannot be cast to com.sap.ur.plugins.ThemeEditorInpu
-
Can't install itunes on XP Media Center Edition 2002 SP3
The installation window appears, then a line of green bars crosses the screen and then nothing.
-
Many many many BusinessEventRetriableException errors in logs
Hi I am infuriated by the never ending error message below in my OC4J logs. They happen almost constantly and I'm now on OC4J log number 669 which is ridiculous. The error is: oracle.tip.esb.server.common.exceptions.BusinessEventRetriableException: F
-
Effect Controls Palette - Docking
Is there any way to open an existing project and have the exact window layout be the same as when you quit the project? IE, if I have multiple Effect Controls windows open when I quit a project, how do I have those same windows open when I open the p