Using bind variables with sql statements

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

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

Similar Messages

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

  • Using bind variable with IN clause

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

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

  • How to use bind variables with XMLTABLE?

    I tried to use bind variables with xmltable statment. Here, my testcase:
    create or replace function wsdltest return xmltype as
    l_dummy xmltype;
    l_stt clob;
    l_name varchar2(500);
    l_xml clob;
    BEGIN
    l_xml :=
    '<definitions name="F1" targetNamespace="http://xmlns.oracle.com/orawsv/XFILES/F1" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xmlns.oracle.com/orawsv/XFILES/F1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
    <types>
    <xsd:schema targetNamespace="http://xmlns.oracle.com/orawsv/XFILES/F1" elementFormDefault="qualified">
    <xsd:element name="SVARCHAR2-F1Input">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="A-VARCHAR2-IN" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="F1Output">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="RETURN" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    </types>
    <message name="F1InputMessage">
    <part name="parameters" element="tns:SVARCHAR2-F1Input"/>
    </message>
    <message name="F1OutputMessage">
    <part name="parameters" element="tns:F1Output"/>
    </message>
    <portType name="F1PortType">
    <operation name="F1">
    <input message="tns:F1InputMessage"/>
    <output message="tns:F1OutputMessage"/>
    </operation>
    </portType>
    <binding name="F1Binding" type="tns:F1PortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="F1">
    <soap:operation soapAction="F1"/>
    <input>
    <soap:body parts="parameters" use="literal"/>
    </input>
    <output>
    <soap:body parts="parameters" use="literal"/>
    </output>
    </operation>
    </binding>
    <service name="F1Service">
    <documentation>Oracle Web Service</documentation>
    <port name="F1Port" binding="tns:F1Binding">
    <soap:address location="http://localhost:8080/orawsv/XFILES/F1"/>
    </port>
    </service>
    </definitions>';
    -- OK
    l_stt := 'select * from xmltable(XMLNAMESPACES(''http://www.w3.org/2001/XMLSchema'' AS "XSD", default ''http://schemas.xmlsoap.org/wsdl/''),
    ''//definitions/types/XSD:schema/XSD:element[@name="SVARCHAR2-F1Input"]''
    passing xmltype(:1)
    columns
    ab xmltype path ''.'' ) t';
    EXECUTE IMMEDIATE l_stt INTO l_dummy using l_xml;
    -- ERROR ORA-01006
    l_name := '"SVARCHAR2-F1Input"';
    l_stt := 'select * from xmltable(XMLNAMESPACES(''http://www.w3.org/2001/XMLSchema'' AS "XSD", default ''http://schemas.xmlsoap.org/wsdl/''),
    ''//definitions/types/XSD:schema/XSD:element[@name=:2]''
    passing xmltype(:1)
    columns
    ab xmltype path ''.'' ) t';
    EXECUTE IMMEDIATE l_stt INTO l_dummy using l_xml, l_name;
    return l_dummy;
    END;
    Any idea ?
    Thanks in advance
    Cyryl

    Why are you using dynamic SQL statements? Why not just use something like this instead in your PL/SQL. I also replaced the leading // in your Xpath with just / since you start from the root node.
    select *
      INTO l_dummy
      from xmltable(XMLNAMESPACES('http://www.w3.org/2001/XMLSchema' AS "XSD", default 'http://schemas.xmlsoap.org/wsdl/'),
                    '/definitions/types/XSD:schema/XSD:element'
                    passing xmltype(l_xml)
                    columns
                    ab xmltype path '.' ) t;Also, the above returns two rows, which I suspect is not what you want. Here is the pure SQL version for you to debug.
    select *
      from xmltable(XMLNAMESPACES('http://www.w3.org/2001/XMLSchema' AS "XSD", default 'http://schemas.xmlsoap.org/wsdl/'),
                   '/definitions/types/XSD:schema/XSD:element'
                   passing xmltype('<definitions name="F1" targetNamespace="http://xmlns.oracle.com/orawsv/XFILES/F1" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xmlns.oracle.com/orawsv/XFILES/F1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
    <types>
    <xsd:schema targetNamespace="http://xmlns.oracle.com/orawsv/XFILES/F1" elementFormDefault="qualified">
    <xsd:element name="SVARCHAR2-F1Input">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="A-VARCHAR2-IN" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="F1Output">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="RETURN" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    </types>
    <message name="F1InputMessage">
    <part name="parameters" element="tns:SVARCHAR2-F1Input"/>
    </message>
    <message name="F1OutputMessage">
    <part name="parameters" element="tns:F1Output"/>
    </message>
    <portType name="F1PortType">
    <operation name="F1">
    <input message="tns:F1InputMessage"/>
    <output message="tns:F1OutputMessage"/>
    </operation>
    </portType>
    <binding name="F1Binding" type="tns:F1PortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="F1">
    <soap:operation soapAction="F1"/>
    <input>
    <soap:body parts="parameters" use="literal"/>
    </input>
    <output>
    <soap:body parts="parameters" use="literal"/>
    </output>
    </operation>
    </binding>
    <service name="F1Service">
    <documentation>Oracle Web Service</documentation>
    <port name="F1Port" binding="tns:F1Binding">
    <soap:address location="http://localhost:8080/orawsv/XFILES/F1"/>
    </port>
    </service>
    </definitions>'
                   columns
                   ab xmltype path '.' ) t

  • 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

  • XSQL Using bind params with sql LIKE clause

    I am unable to use a bind-param with the LIKE clause in a SELECT statement.
    eg call .../temp.xsql?name=N
    XSQL query is this:
    <xsql:query max-rows="-1" bind-params="name">
    SELECT last_name
    FROM emp
    WHERE last_name LIKE '?%'
    </xsql:query>
    I have tried a few combinations so far with no success eg:
    WHERE last_name LIKE '{@name}%'
    WHERE last_name LIKE ?||%
    Any ideas?

    I highly recommend using XSQL's real bind variable feature wherever you can. You can read about it in the XSQL Online Documentation (Search for the "Using Bind Variables" section).
    Using this feature is more performant and more secure than using textual substitution variables.
    Here's what your page looks like using textual substitution:
    <page connection="UTD4" xmlns:xsql="urn:oracle-xsql">
      <xsql:query null-indicator="yes" >
        SELECT * FROM TC_HL7_SEG WHERE SEGMENT_CODE LIKE '{@code}%'
      </xsql:query>
    </page> .
    And here's what it would look like using real bind variables:
    <page connection="UTD4" xmlns:xsql="urn:oracle-xsql">
      <xsql:query null-indicator="yes" bind-params="code">
        SELECT * FROM TC_HL7_SEG WHERE SEGMENT_CODE LIKE ?||'%'
      </xsql:query>
    </page> .
    Using real bind variables allows the database to avoid reparsing the SQL statement everytime, which improves performance.
    Steve Muench
    JDeveloper/BC4J Development Team
    Author, Building Oracle XML Applications

  • 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

  • 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

  • Trying to use bind variables with a list

    I have the following dynamic SQL statement which I'm trying to convert to use pure bind variables. the variable "v_list" is a string that gets filled dynamically with a list of numbers so it can be used in an expression "IN (<expr>)". The number of elements is not constant but DB driven. I cannot simply replace it with a bind variable, I get the "Invalid number" error.
    I read up on using collection/varrays but they seem to be build for other purposes. any ideas?
    BTW this query catcehs the NO_DATA and TOO_MANY exception. basically we are interested in either found at least one record, or not.
    DECLARE
         v_list     VARCHAR2(1000);
         v_P1     INTEGER;
         v_temp     INTEGER;
         v_list := '0';
         FOR <some condition>
         LOOP
              v_list := v_list || ',' || <some-number>;
         END LOOP;
         v_String := 'SELECT pID FROM t1'
              || ' WHERE pID IN (' || v_list || ')'
              || ' AND f2 = :1 '
              || ' AND f3 = 1';
         EXECUTE IMMEDIATE v_String INTO v_temp USING v_P1;

    Tom Kyte has a discussion that will probably be useful here
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:210612357425
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Bind Variables in SQL Statement

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

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

  • Can we use repository variables in SQL statement of column prompt?

    Hi Dudes,
    Below is the query
    SELECT "- End Date"."End Fiscal Year" FROM "Consumer Sector" WHERE ("- End Date"."End Fiscal Year" = valueof (current_year)) or ("- End Date"."End Fiscal Year" = valueof (current_year) -1)
    when use this sql in criteria prompt getting error.
    Please suggest .
    thanks.sri

    Make sure your syntax is correct it should be like VALUEOF("CURRENT_YEAR")-1
    If you still have issues then VALUEOF("CURRENT_YEAR")-1 cast it to int before you subtract.
    If helps pls mark as correct else let share error message

  • Use of variables in SQL statements

    Hi,
    I am looking for for a way to set a variable which will be referenced several times within a UNION query.
    Something like:
    Var=3
    SELECT * FROM VIEW_1 WHERE FIELD_1 = Var
    UNION
    SELECT * FROM VIEW_2 WHERE FIELD_1 = Var
    UNION
    SELECT * FROM VIEW_3 WHERE FIELD_1 = Var
    Instead of something like:
    SELECT * FROM VIEW_1 WHERE FIELD_1 = 3
    UNION
    SELECT * FROM VIEW_2 WHERE FIELD_1 = 3
    UNION
    SELECT * FROM VIEW_3 WHERE FIELD_1 = 3

    I'm sure that for this you were requiring a database solution and not a sqlplus solution ? If so, then you have a couple of options:-
    1) change the Var to a function call and have the function return a packaged variable or value in a lookup table that you can set as you require [ i.e. WHERE FIELD_1 = your_function ].
    2) use an application context, such that you set an attribute within the context and use it within the view [ i.e. WHERE FIELD_1 = SYS_CONTEXT( 'your_context', 'your_attribute' ) ].
    In both methods, you will need to set the value of your variable before referencing the view. The view therefore becomes "parameterised" in this sense.
    It might be possible that your view is mergeable. By this I mean that Oracle might be able to push a predicate against the view inside it instead, such that Oracle rewrites this:-
    SELECT <cols>
    FROM your_union_view
    WHERE field_1 = 3;
    ...and takes that value of field_1 = 3 and "pushes" it into your_union_view itself, in which case you will not need to worry about any of the above solutions. You can test this out by removing the where clauses from your view definition and running an explain plan against a query of the form above. If you see a "VIEW" step in the results, then the view is not mergeable in its current form and you should revert to the methods I listed.
    Regards
    Adrian
    For this you can use application contexts

  • Using collections / Bind variables with a PL/SQL functio returning a query

    I have this code, which is supposed to assign collection variables as column names
    FOR i in 1 .. Collection_count -1
    LOOP
    SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=i;
    SELECT c002 into varholder FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=i;
    vQuery:= vQuery || 'SUM(decode(label, ''Aware'', product_'|| i || ', ''Expert'', product_' || i || ', ''Proficient'', product_' || i || ', ''Advanced(Demo)'', product_' || i || ' )) as ';
    vQuery:=vQuery || varholder || ', ' ;
    END LOOP;
    I've tried &P341_M1. , :P341_M1, ':P341_M1', varholder
    When I try '&P341_M1' it returns the whole SUM(decode... line as the label
    Basically Im having a hard time using bind variables with the PL/SQL returning a query...anybody?

    Ok so working through this problem more I have realized that the problem is using the for loop i as an index value
    This will get a value:
    SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=2;
    But this won't
    SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=i;
    I'm in the for loop, and use the i variable in other places within this loop...Is there a reason why I can't compare seq_id to i?
    My new code as follows:
    FOR i in 1 .. Collection_count -1 --apex_application.g_f01.COUNT - 1
    LOOP
    varholder:=i;
    SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=2;
    SELECT c002 into varholder FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=4;
    vQuery:= vQuery || 'SUM(decode(label, ''Aware'', product_'|| i || ', ''Expert'', product_' || i || ', ''Proficient'', product_' || i || ', ''Advanced(Demo)'', product_' || i || ' )) as f';
    vQuery:=vQuery || :P341_M1 ||i||', ' ;
    END LOOP;

  • PL SQL using bind variables

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

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

  • Use of bind variables with the oracle db - to improve library cache perform

    Dear Friends,
    We are using oracle 9.0.1.1.1 db server - the performance of the db was pathetic and upon investigation it was revealed that the library cache was over loaded with sql hard parses generated by not using bind variables. We are using vb as a front end with oracle and our connection object in vb is created using ole db for oracle provided by oracle (installed from oracle client custom - programmer option).
    I would appreciate if any body can tell how can we use bind variables in vb to connect to oracle such that the hard parses can be changed into soft parses.
    Your effort to bring some peace in my life is worth comendable and I would be very obliged for your time and help.
    Thanks a lot.
    Bye
    Take care.
    qj

    Generally, you would use bind variables by changing statements that are written like this
    select * from emp where empno=6678 and ename='Jones'
    so that they're written like
    select * from emp where empno=? and ename=?
    How you then bind these question marks to the particular values you want depends on the API you're using (ADO? OLE DB directly?, etc). If you have a support contract, there are plenty of examples for any API on metalink.oracle.com
    Justin

Maybe you are looking for

  • While activating the ODS i'm getting these errrors

    Hi All, While activating the ODS i'm getting these errrors, 1) The creation of the Export Datasource failed 2) RFC Connection to the source system is damaged --- no metadata upload 3) Error when activating ODS object What would be the reasons........

  • Replacing MacBook Pro Screen with higher resolution screen?

    I bought a MacBook Pro 15" today which has the lower end screen resolution.  I originally wanted the higher resolution screen but the guys in the shop said they didn't sell them in the shops, only online, but since I wanted one before I headed off to

  • BI - Exam Questions & Tips

    Hai Friends   I am going to take BI Certification Exam next Week. If any one has got model exam questions or tips about the exam, please write to me at [email protected] Thanks in advance A.Bharath

  • RVCTP module: Receiving Transaction Processor

    Hi, I am doing receipt using by passing ASN no as input parameter, not picking the records from interface tables. when i checked in rcv_transactions_interface table proceeing_status_code is "RUNNING" , "PENDING" . when i run the Receiving Transaction

  • Why am I now receiving error messages when I am trying to send texts?

    Why am I now receiving error messages when I am trying to send texts?  People that I have texted before I am now getting error messages and I have to click on the excalmation point and hit send as a SMS text.  What's up?