Bind variable documentation

Hi,
Developpers about my project don't use bind variable.
I would like to find a good documentation to convince them to use bind variable.
But where can find a french documentation about bind variable ?
Thanks in advance for your help,
Nicolas.

Have you looked to see if either of Tom Kyte's books have been translated into French? They both have excellent explanations of the utility of bind variables.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • Bind Variables in SPARQL Queries

    Hi,
    I am interested in bind variables and their use between queries, however while I see the concept behind the example given in the documentation (http://docs.oracle.com/cd/E11882_01/appdev.112/e25609/sem_jena.htm#autoId15) I am not able to grasp how to exactly pass the results of a query_1 for an ?x variable to another query query_2.
    Would it be possible to offer a more detailed explanation and a working simple code about how to do this using Jena Adapater.
    Thank you.

    Hi,
    I am using the Java API to run SPARQL update queries, this is an example of what I am trying to achieve :
    public static void runTestUpdateBinding() throws SQLException {
        String[] modelNames = new String[] { };
        String[] rulebases = new String[] { };
        OracleDataSource ods = new OracleDataSource();
        ods.setURL("ORACLE CONNECTION STRING");
        OracleConnection oc = (OracleConnection)ods.getConnection();
        Oracle oracle = new Oracle(oc);
        Attachment attachment =
            Attachment.createInstance(modelNames, rulebases, InferenceMaintenanceMode.NO_UPDATE, QueryOptions.ALLOW_QUERY_INVALID_AND_DUP);
        GraphOracleSem graph = new GraphOracleSem(oracle, "in_oracle", attachment, true);
        ModelOracleSem model = new ModelOracleSem(graph);
        //Insert few triples
        String updateQuery = "INSERT DATA {                                        " +
                             "  <http://sub/a>  <http://pred/a>  <http://obj/a> .\n" +
                             "  <http://sub/b>  <http://pred/b>  <http://obj/b> .\n" +
                             "  <http://sub/c>  <http://pred/c>  <http://obj/c>    " +
        UpdateAction.parseExecute(updateQuery, model);
        //Run the update query
        updateQuery = "PREFIX    ORACLE_SEM_UEAP_NS:    <http://oracle.com/semtech#s$RDFVID%20IN(ORACLE_ORARDF_RES2VID(?),ORACLE_ORARDF_RES2VID(?))> \n" +
                      "PREFIX    ORACLE_SEM_UEPJ_NS:    <http://oracle.com/semtech#s$RDFVID> \n" +
                      "PREFIX    ORACLE_SEM_UEBV_NS:    <http://oracle.com/semtech#http%3A%2F%2Fsub%2Fa,http%3A%2F%2Fsub%2Fc> \n" +
                      "INSERT { <http://sub/UPDATED_SUBJECT>    ?p    ?o } \n" +
                      "WHERE  { ?s    ?p    ?o }";
        UpdateAction.parseExecute(updateQuery, model);
        model.close();
    Basically, I am expecting only "<http://sub/a>  <http://pred/a>  <http://obj/a>" and "<http://sub/c>  <http://pred/c>  <http://obj/c>" to match, however, "<http://sub/b>  <http://pred/b>  <http://obj/b>" also matches as you can see from the following results
    | s                            | p               | o              |
    ===================================================================
    | <http://sub/c>               | <http://pred/c> | <http://obj/c> |
    | <http://sub/UPDATED_SUBJECT> | <http://pred/c> | <http://obj/c> |
    | <http://sub/b>               | <http://pred/b> | <http://obj/b> |
    | <http://sub/UPDATED_SUBJECT> | <http://pred/b> | <http://obj/b> |
    | <http://sub/a>               | <http://pred/a> | <http://obj/a> |
    | <http://sub/UPDATED_SUBJECT> | <http://pred/a> | <http://obj/a> |
    Also, in the underlying generated SQL, there is no restriction on s$RDFVID as in SELECT queries (i.e: ...where (s$RDFVID IN(ORACLE_ORARDF_RES2VID(?),ORACLE_ORARDF_RES2VID(?))) )

  • Dynamic view object loses bind variables after passivation

    I am creating a view object definition/view object programmatically in Jdev 11.1.1.2.0. The query requires a named bind parameter. All was working fine but now I am testing with app module pooling disabled and the bind variable is not being restored after passivation -- it's like the definition has disappeared or something.
    Here is my VO creation code:
    ViewObject vo = findViewObject("FinalistsWithEvalDataVO");
    if (vo != null){
    vo.remove();
    ViewDefImpl voDef = new ViewDefImpl("FinalistsWithEvalDataVODef");
         // I add a bunch of viewAttrs here...
    voDef.setQuery(fullQuery);
    voDef.setFullSql(true);
    voDef.setBindingStyle(SQLBuilder.BINDING_STYLE_ORACLE_NAME);
    voDef.resolveDefObject();
    voDef.registerDefObject();
    vo = createViewObject("FinalistsWithEvalDataVO", voDef);
    vo.defineNamedWhereClauseParam("Bind_SchlrAyId", null, new int[] {0});
    vo.setNamedWhereClauseParam("Bind_SchlrAyId", new Number(1)); //For testing
    vo.executeQuery();
    The query executes fine right there and then the VO seems to passivate fine. I even see the bind var in passivation:
    <exArgs count="1">
    <arg name="Bind_SchlrAyId" type="oracle.jbo.domain.Number">
    <![CDATA[1]]>
    </arg>
    </exArgs>
    But then when it reactivates prior to rendering the page, it invariably throws a missing parameter exception and this in the log:
    <ViewUsageHelper><createViewAttributeDefImpls> [7409] *** createViewAttributeDefImpls: oracle.jdbc.driver.OraclePreparedStatementWrapper@1af78e1
    <ViewUsageHelper><createViewAttributeDefImpls> [7410] Bind params for ViewObject: [FinalistsWithEvalDataVO]AwardViewingServiceAM.FinalistsWithEvalDataVO
    <ViewUsageHelper><createViewAttributeDefImpls> [7411] ViewUsageHelper.createViewAttributeDefImpls failed...
    <ViewUsageHelper><createViewAttributeDefImpls> [7412] java.sql.SQLException: Missing IN or OUT parameter at index:: 1
    I have worked on this for hours and can't see anything wrong. Like I said, it works fine when not forcing passivation...
    Any help would be appreciated.
    Thanks.
    -Ed

    @Jobinesh - Thanks for the suggestions. I have read all the documentation I can find. Everything works fine without passivation. Everything still breaks with passivation. I have given up on trying to get the bind variable to restore after passivation and am currently just building the query with all values embedded in the query rather than bind variables. This is bad practice but avoids the problem. However, now that I avoided that obstacle, I'm on to the next issue with passivation of this dynamic view object, which is that the current row primary key apparently cannot be reset after activation. I get the following error:
    <Key><parseBytes> [7244] Key(String, AttributeDef[]): Invalid Key String found. AttributeCount:1 does not match Key attributes
    <DCBindingContainer><reportException> [7254] oracle.jbo.InvalidParamException: JBO-25006: Value 00010000000A30303033383133343734 passed as parameter String to method Constructor:Key is invalid: {3}.
         at oracle.jbo.Key.parseBytes(Key.java:537)
         at oracle.jbo.Key.<init>(Key.java:179)
         at oracle.jbo.server.IteratorStateHolder.getCurrentRowKey(IteratorStateHolder.java:34)
         at oracle.jbo.server.ViewRowSetIteratorImpl.activateIteratorState(ViewRowSetIteratorImpl.java:3877)
    I've been trying various workarounds for over a day now with no luck. Very frustrating.
    Thanks for trying to help.
    -Ed

  • Oracle BI Publisher - Passing multiple wildcard search to a bind variable

    Hi,
    Please help me in resolving the below mentioned issue:
    I have developed a report in oracle BI Publisher with a SQL query.
    While scheduling the report to run I used to pass mutilple parameters like CGAMSVC08,RLCSVC51
    If the pass the parameter with wildcard search like C% it works.
    When I pass two or more parameter values with wildcard search like C%,R% its not working.
    Could you please let me know how should I give the bind variable in the SQL query. Currently I'm paramater like the one shown below for passing multiple paramaters:
    Where (',' || :PRMRETRID || ',' like '%,'||RL.RETROFIT_ID|| ',%')
    Edited by: user1101445 on May 23, 2012 2:02 AM

    HI Tyler.
    Well, here's the latest.
    I found this little gem in the BIEE 10.1.3.3.3 Release Notes Documentation...
    This issue applies to Versions 10.1.3.3, 10.1.3.3.1, 10.1.3.3.2, and 10.1.3.3.3.
    Reports that use the BI Publisher data template as the data model may fail with the
    following error: "Data not defined."
    This error will occur if you defined a parameter in your data template but you do not
    pass a value to it via the user interface. If you do not specify this parameter in the "Parameters" section of the report definition that you created using the BI Publisher Edit Report interface, then you will receive the error.
    To work around this issue, either define the parameter in the Edit Report interface or remove the parameter from the data template.
    That bit is now working.
    Having set this up and using your guide it works if my SOAP parameters declaration passes a single value like this...
    <parameterNameValues>
    <item>
    <name>P_INVOICE_ID</name>
    <multiValuesAllowed>true</multiValuesAllowed>
    <values>
    <item>16641</item>
    </values>
    </item>
    </parameterNameValues>
    But if I try and pass two or more like this...
    <parameterNameValues>
    <item>
    <name>P_INVOICE_ID</name>
    <multiValuesAllowed>true</multiValuesAllowed>
    <values>
    <item>16641,18421</item>
    </values>
    </item>
    </parameterNameValues>
    BIP states "java.sql.SQLException: ORA-01722: invalid number"
    My SQL where clause is..
    <sqlStatement name="Q1">
    <![CDATA[select * from vw_invoice_summary
                   where invoice_summary_id IN (:P_INVOICE_ID)]]>
    </sqlStatement>
    And the BIP error records the parameter value as P_INVOICE_ID 16641,18421 (which are legit invoice IDs)
    In summary, works if I pass one invoice ID, fails if I pass two or more.
    Any ideas? Or do you reckon this is now a post for the BIP forum?
    Kind regards.
    Simon

  • XSU doesn't support bind variables - how dumb is that?

    I am using XSU to generate XML from a SQL statement using class OracleXMLQuery. Either I am blind or stupid or there is no support for bind variables in this class! I have used DBMS_xmlquery in PL/SQL before and this does support bind variables, I naturally assumed the Java equivalent would also have this. The lack of bind variable support means a huge performance hit as every single SQL statement will be treated as unique and will require hard parsing on the server!
    Is there another Java XML utility I can use for generating XML from a SQL statement that does support bind variables? I have trawled through the Oracle documentation and I am getting very confused and lost.
    Thanks,
    Steve

    makaidog,
    Read get rid of community toolbar: Apple Support Communities.

  • Not able to clear bind variable following Fusion Dev Guide Document Steps.

    Dear All,
    I am having trouble following the Fusion Developer Guide specifically the items on below link
    http://docs.oracle.com/cd/E23943_01/web.1111/b31974/bcquerying.htm#CHDDHIHJc
    1.     (Request begins and application module is acquired)
    2.  Call setWhereClause(null) to clear WHERE clause
    3.  Call setWhereClauseParam(null) to clear the WHERE clause bind variables
    4.  Call setWhereClause() that references n bind variables
    5.  Calling setWhereClauseParam() to set the n values for those n bind variables
    6.  Calling executeQuery()
    7.  (Application module is released)I wanted to actually clear all my bind variables including the bind variable that I have set in the query.
    SELECT Persons.PERSON_ID,
           Persons.PRINCIPAL_NAME,
           Persons.TITLE,
           Persons.FIRST_NAME,
           Persons.LAST_NAME,
           Persons.PERSON_TYPE_CODE,
           Persons.SUPPLIER_ID,
           Persons.PROVISIONED_FLAG,
           Persons.PRIMARY_ADDRESS_ID,
           Persons.REGISTERED_DATE,
           Persons.MEMBERSHIP_ID,
           Persons.EMAIL,
           Persons.CONFIRMED_EMAIL,
    FROM PERSONS Persons
    WHERE Persons.PERSON_TYPE_CODE = :PERSON_TYPE_CODE_PARAMStep 3 is where I am having problem. I cant find in the API regarding setWhereClauseParam(null) that accepts String but
    it only has setWhereClauseParam(int, String)
    Not sure if I am running on some documentation bug.
    JDEV 11G PS5

    This look like a documentation bug to me.
    The right method to call is
    setWhereClauseParams(null); //note the 's' in Params!Timo

  • 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

  • EA3/EA2/EA1 - Bind Variables in PL/SQL

    EA1 seems to have taken a backward step when it comes to supporting bind variables in PL/SQL.
    Back in 1.1.3, according to the bugs fixed list, we apparently fixed bug 5884935 (BINDS IN A PL/SQL STATEMENT HAS "NOT ALL VARIABLES BOUND" ERROR), although this was only ever when running as scripts (as per Bind variables in PLSQL bug not fixed?
    Now according to the 1.2 documentation, bind variables are not supported in the script runner (section 1.7.2) and the SQL*Plus variable command is not supported (section 1.7.1). However, I can run the following code "successfully" (no errors reported but the substitution text entered does not appear in the dbms_output):
    variable bind_text varchar2(30);
    declare
    l_text varchar2(30);
    begin
    :bind_text := '&sub_text';
    dbms_output.put_line('Bind text: "' || :bind_text || '"');
    end;
    Now in EA1, running this as a script results in "ORA-01006: bind variable does not exist"
    Running the variable statement results in "ORA-00900: Invalid SQL Statement" and running the PL/SQL results in "ORA-1008: not all variables bound".
    Can someone from the SQL Developer team please comment on the intended support for bind variables in PL/SQL?
    Thanks,
    theFurryOne

    I know that the variable command isn't supported (as I said above), but that was also the case in 1.2, where it did actually sort of work.
    I am not talking about local PL/SQL variables declared within the PL/SQL - I am trying to get user entered values into the PL/SQL in the same way as prompting for bind variable values in SQL.
    So using SQL Developer bind variables inside PL/SQL is my end goal - preferably when running anonymous PL/SQL blocks as statements in the worksheet.
    However, as there have been "fixed" bugs to enable bind variables in PL/SQL, which require the use of SQL Plus commands that are not supported in SQL Developer (ie variable), I am trying to work out what the development team think the intended support for bind variables in PL/SQL is. Then I will know if what I want needs to be reported as a bug or logged as an enhancement request.
    theFurryOne

  • "Partition For" with a bind variable

    Does anyone know if a bind variable can be used with the "partition for" syntax? For example,
    select max(col1) into myvar from t partition for (mydate);where t is an interval-partitioned table.
    I couldn't find any documentation specifically on this and all the ways I've tried it have failed :-(
    Edit: version 11.2

    The table has an interval partition on a date column so that all records for a particular day are stored in the same partition. The query is actually the equivalent of
    select max(col1) into myvar from t
    where date_col >= trunc(mydate) and date_col < trunc(mydate+1);but I'd rather use the shorter statement if possible.

  • Bad bind variable 'NEW.SYS_NC_ROWINFO$

    Hi
    in order to assist in error resolution when inserting XML data into a XMLTYPE table I have attempted to create a trigger on the table as
    SQL> CREATE or replace TRIGGER VALIDATE_PersonAlert3
    2 before insert on pa_tab3
    3 for each row
    4 declare
    5 XMLDATA xmltype;
    6 begin
    7 XMLDATA := :new.sys_nc_rowinfo$;
    8 xmltype.schemavalidate(XMLDATA);
    9 end;
    10 /
    Warning: Trigger created with compilation errors.
    and get the following
    SQL> show errors
    Errors for TRIGGER VALIDATE_PERSONALERT3:
    4/19 PLS-00049: bad bind variable 'NEW.SYS_NC_ROWINFO$'
    SQL> spool off
    Anyone know the answer ?
    The Trigger example was based on the Oracle 9i XML Developers Guide.
    Is there more to adding XDB to database than running catqm.sql ?

    Hi
    To install XDB you should also run catxdbj.sql (in the XDB manual, page A-3, you can find more info...).
    I had no problem to create a trigger accoring to the documentation...
    Chris

  • Bind variables in jena WLS SPARQL Queries

    Dear all,
    We have read about the possibilities of the jena support for bind variables in the documentation (http://docs.oracle.com/cd/E11882_01/appdev.112/e25609/sem_jena.htm#RDFRM248). In the following topic of jun 14 2014 (Bind Variables in SPARQL Queries) the problem was already addressed. However we are facing some other problems.
    We are using:
    * WLS 12.1.3.0.0
    * jena adapter 2.11.1.
    * Joseki 3.4.4.
    * ARQ 2.9.2.
    We try to run the following query on the joseki end-point.
    PREFIX foaf: <http://xmlns.com/foaf/0.1/>
    PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
    PREFIX ORACLE_SEM_FS_NS: <http://oracle.com/semtech#no_fall_back,ALLOW_DUP=T,ODS=6,s2s>
    PREFIX ORACLE_SEM_HT_NS: <http://oracle.com/semtech#monitor>
    PREFIX ORACLE_SEM_UEAP_NS: <http://oracle.com/semtech#f$RDFVID%20in(?)>
    PREFIX ORACLE_SEM_UEPJ_NS: <http://oracle.com/semtech#f$RDFVID>
    PREFIX ORACLE_SEM_UEBV_NS: <http://oracle.com/semtech#1264839720472151591>
    SELECT ?f ?g
    WHERE
    { graph ?g { ?p vcard:N ?vn .
                  ?vn vcard:Family ?f .
                   ?p foaf:title "Sen." .}
    The result we get back is however not using the bind variable. It returns the whole list without UEAP/UEPJ/UEBV.
    Is there something I missed in the documentation or do I need to set some variables for the use of bind variables?
    Kind regards,
    Max

    Dear Zhe,
    The solution provided works! However setting this property was not straight forward for me (but this is more related to WLS).
    Setting this JVM property in the arguments of the weblogic server (Server Start) does not work. I've looked through the files for any sign of the property but did not find any. Manually adding this line in setDomainEnv.sh
    (adding the variable JAVA_PROFILE = "-Doracle.spatial.rdf.client.jena.allowAP=true") does work though.
    Kind regards,
    Max

  • DB links, Bind variables & APEX reports performance

    Hello,
    So the problem is simply that I have two databases:
    A : Has table T1
    B : (APEX database)
    I have an APEX report that simply does the following
    Select col1, col2.. from A@dblink
    This is abviously straighforward, however, I start having considrable performance issues if I have any filters applied to this query using APEX items ( bind variables) :
    Select col1, col2.. from T1@dblink_A_B
    where col1 > :PX_item
    I ran the explain plan and noticed that using the bind variables forces the query to be done on database B, not A which is causing the performance issues.
    I am sure that many of you ran into this issue before, but does anyone know how to resolve this issue ? I am thinking about using Pipelined functions, but am not sure if that will work well if I have a lot of records returned by the query or if this will resolve the issue at all.... your thoughts are appreciated..
    Thanks,
    Sam

    I've always been able to work around my DB link issues in Apex. As suggested, driving_site hint should be tried. Oracle documentation on it isn't great, but I follow this:
    - don't bother including other hints together with driving_site, as they get stripped out when your sql is passed to the remote DB (as per driving_site hint).
    - if you have have subqueries - specifiy driving_site hint in that section of the SQL too. I don't have any proof that this is really required - but it doesnt hurt.
    - include driving_site hint even if all tables are remote. Careful of refs to pseudo cols like sysdate, user etc. I think they are taken as local refs - not remote. I havent tested this properly to confirm.
    - dumb down your test case to eliminate refs to sysdate, subqueries etc.
    - remember that items are text, so you'd need to do to_number(), to_date() on them where appropriate on them in your SQL at the least.
    Seeing as you control the content of your items, SQL injection is a reduced risk. Assuming that's not your top concern anyway, don't get carried away with the bind-variable vs literals debate. Apex does lots of nasty inefficient stuff like IR searches. I'd never use an IR in something that really needs to be scalable anyway. Soo... construct SQL with littlerals based on your items (assuming item refs are the cause of your issue).
    region type=SQL Query (PL/SQL function body returning SQL query)
    begin
      return 'SELECT /*+ DRIVING_SITE(a) */ a.empno,a.ename,a.job,a.mgr,a.loc
            FROM emp@MY_DBLNK A
           WHERE  a.empno = '||:P123_EMPNO||'
           ORDER BY 1,2,3';
    end;Assuming your queries are expensive to execute (local or remote) and dont return too many records (else collection table can get really big), then caching the resultset in a collection gives you nice fast pagination, when using a PPR report. Keep a watch on the size of the collection table - truncate it manually if you accidentally populate it with a big cartesean product etc, else performance could degrade.
    Do main query to populate collection before header. PPR pagination doesnt reload the page, so before-header process only runs once. In my case it works like:
    -- reload button to re-load page, to force a query re-run. The html_Submit_Progress thing loads an 'busy processing' image.
    <input type="button" value="Run query" onclick="javascript:this.disabled=true;this.value='Running...';html_Submit_Progress(this);"  id="SUBMIT"  />
    -- On Load - before header process to populate collection (call in a regular region to see errors, until ironed out)
    declare
      q varchar2(4000);
      v_t0   PLS_INTEGER := DBMS_UTILITY.get_time;
    begin
       :P0_QSEC := '0';
      IF APEX_COLLECTION.COLLECTION_EXISTS(P_COLLECTION_NAME=> 'Q1')
      THEN
        APEX_COLLECTION.DELETE_COLLECTION(P_COLLECTION_NAME=>'Q1');
      END IF;
      if (:P0_DBLNK is not null) then
        q:= 'SELECT /*+ DRIVING_SITE(a) */ a.empno,a.ename,a.job,a.mgr,a.loc
            FROM emp@'||:P0_DBLNK||' a
           WHERE a.job like "M%"
            AND a.empno = #EMPNO#
           ORDER BY 1,2,3';
        q:= replace(q, '"', '''');
        q:= replace(q, '#EMPNO#', :P123_EMPNO);
        -- bulk
        APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY_B(
            P_COLLECTION_NAME => 'Q1',
            P_QUERY => Q);
       -- record count
       -- APEX_COLLECTION.collection_member_count
      end if;
      -- display in page footer or whatever
      :P0_QSEC := TO_CHAR ((DBMS_UTILITY.get_time - v_t0) / 100, '000.00') || ' sec';
    exception
      when others then
      raise_application_error(-20501, :P0_DBLNK||'< br >'||sqlerrm||'< br >'||q );
    end;
    -- then PPR report is just like
    Select C001, C002, C003, C004, C005
    From apex_collections
    Where collection_name = 'Q1'
    order by seq_id;Edited by: maceyah on Sep 7, 2011 9:26 AM
    Useful link on bind variables for CREATE_COLLECTION_FROM_QUERY_B ==> https://forums.oracle.com/forums/thread.jspa?threadID=2305634&tstart=0
    Edited by: maceyah on Mar 2, 2012 3:18 PM

  • Identify bind variable data type 121?

    Looks like the OCI forum is not popular. Reposting here with hopes of better luck... Or perhaps I wasn't specific enough for the forum? OK, this is obviously a binary data type. The problem is that I want to know exactly which of them it is. Or I'd like to know if someone has improperly coded an OCI application. Here's the original post.
    I received a level 12 SQL trace file that referenced data type 121 for a bind variable value. I have searched unsuccessfully for documentation in many places. Can anyone tell me what data type this is? Following is the relevant excerpt from the trace file.
    bind 18: dty=121 mxl=4000(4000) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=4000 offset=0
    bfp=022c1e80 bln=4000 avl=2196 flg=15
    value=
    Dump of memory from 0x22C1E80 to 0x22C2714
    22C1E80 01A214BC 022C1E88 022F1F88 01E0A954 [.....,.../.....T]

    Hi
    The following are the internal datatypes used by oracle related to 121.
    KOTAD, KOTMD, KOTMI, KOTTB, KOTTD
    Not sure about their exact use but these datatypes might be used internally for LOB's.
    Hope it helps.
    Diwakar

  • Undocumented bind variable data type

    I received a level 12 SQL trace file that referenced data type 121 for a bind variable value. I have searched unsuccessfully for documentation in many places. Can anyone tell me what data type this is? Following is the relevant excerpt from the trace file.
    bind 18: dty=121 mxl=4000(4000) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=4000 offset=0
    bfp=022c1e80 bln=4000 avl=2196 flg=15
    value=
    Dump of memory from 0x22C1E80 to 0x22C2714
    22C1E80 01A214BC 022C1E88 022F1F88 01E0A954 [.....,.../.....T]

    Hi
    The following are the internal datatypes used by oracle related to 121.
    KOTAD, KOTMD, KOTMI, KOTTB, KOTTD
    Not sure about their exact use but these datatypes might be used internally for LOB's.
    Hope it helps.
    Diwakar

  • Setting bind variables in dependant LoV's : How?

    Hi
    I'm trying to create an LoV dependant upon the value selected in a previous Lov.
    I have created an LoV with a bind variable which executes correctly when run independantly of a form
    When I attach the loV to a form I get prompted to :-
    "Set the binding(s) for the bind variable(s) defined in the lov"
    How do I do this ?
    All replies gratefully recieved, thanks in advance
    Andy

    Examples of using a bind variable LOV are located in the "Building Portals" manual. On technet, click the Documentation tab, then open the "Building Portals" PDF.
    null

Maybe you are looking for

  • Error in BO Webi using Authorization analysis in Bex with hierarchy display

    Hi Experts , When we run the WEBI report created on bex query which has 0comp_code restricted with characteristic variable  of processing type Authorization and Not ready for input. The hierarchy display is active in Bex (as we want to see L01, L02..

  • Passive graphics card for 2-monitor setup

    I am looking for a graphics card for use with 2 monitors in a dual monitor configuration that has: Passive cooling 1 x DVI port 1 x DisplayPort I'm aware that CS6 can  make use of some of the more advanced graphics card features, such as Open CL, but

  • BAPI/FM for Change Park Document

    Hi Experts, Is there any BAPI or FM to change PARK document (remove payment block). Please suggest, Regards, Kaustubh.

  • HCM Process & Form - QISR1

    Hi, I creaed a form and have attached to a process. Now for the process, I have to do some ABAP development for defaulting input values. For this I created a new implementation for QISR1 and set the filter value (the ISR scenario for the form). But t

  • E-books

    Post Author: smartcoder CA Forum: .NET Do you want to Learn Sharepoint ???Learn Share Point freelyhttp://hotsoftwareslist.blogspot.com/2007/10/learn-sharepoint-freely.html Download EBooks Freely in .pdf,.chm formats and ready for interview questions.