Problem with bind variable in a procedure

Hi Experts,
I'm migrating forms from 5 to 6i. And in most of the forms I'm getting the error in the procedure "G$_KEY_OPT_MENU".
This is the most common error I'm getting in almost like 30 forms.
The error is:
Error 49 at line 21, column 3
bad bind variable "SELECT_ITEM"
Error 49 at line 22, column 3
bad bind variable "SELECT_ITEM"
Error 49 at line 21, column 3
bad bind variable "OPT_SEL"
Error 49 at line 21, column 3
bad bind variable "OPT_SEL"
Error 49 at line 50, column 3
bad bind variable "SELECT_ITEM"
PROCEDURE G$_KEY_OPT_MENU (ITEM_NAME_IN IN CHAR,
                           SEL_A_DESC IN CHAR,SEL_A_KEY IN CHAR,
                           SEL_B_DESC IN CHAR,SEL_B_KEY IN CHAR,
                           SEL_C_DESC IN CHAR,SEL_C_KEY IN CHAR,
                           SEL_D_DESC IN CHAR,SEL_D_KEY IN CHAR) IS
     ITM          VARCHAR2(1);
     DESC_VAR     VARCHAR2(36);
     KEY_VAR      VARCHAR2(30);
     ITEM_ID      ITEM;
BEGIN
  ITEM_ID := FIND_ITEM(NAME_IN('SYSTEM.CURSOR_BLOCK')||
               SUBSTR(NAME_IN('SYSTEM.TRIGGER_ITEM'),
               INSTR(NAME_IN('SYSTEM.TRIGGER_ITEM'),'.'),
               INSTR(NAME_IN('SYSTEM.TRIGGER_ITEM'),'_LBT')-1 -
               INSTR(NAME_IN('SYSTEM.TRIGGER_ITEM'),'.')+1));
  IF ID_NULL(ITEM_ID) THEN
     IF G$_DISPLAY_ALERT('','The Button you pressed is outside the current block') IS NOT NULL
        THEN RAISE FORM_TRIGGER_FAILURE;
     END IF;
  END IF;
  :SELECT_ITEM := '';
  :OPT_SEL := '';
  For Loop and some conditions, setting properties.
  GO_ITEM('G$_OPT_BLOCK.OPT_SEL');
  :SELECT_ITEM := ITEM_NAME_IN;
END;Edited by: user12290512 on Mar 14, 2011 2:16 PM

FRM-18108: Failed to load the following objects.Source Module:GOQOLIB
Source Object: G$_WARNING_ALERT
Source Module:GOQOLIB
Source Object: G$_OPT_BLOCK
Source Module:GOQOLIB
Source Object: G$_OPT_CANVAS
Source Module:COQOLIB
Source Object: CTRDETC_CHG_LOV
Source Module:GOQOLIB
Source Object: GUROPTM_LOV
Source Module:COQOLIB
Source Object: CTRDETC_PMT_LOV
Source Module:COQOLIB
Source Object: CBBDACC_ACCOUNT_ID_LOV
Source Module:COQOLIB
Source Object: CBBDACC_ACCOUNT_ID_RG
Source Module:COQOLIB
Source Object: CTRDETC_PMT_RG
Source Module:COQOLIB
Source Object: CTRDETC_CHG_RG
Source Module:GOQOLIB
Source Object: GUROPTM_RG
Source Module:GOQOLIB
Source Object: G$_NVA_LOV
Source Module:GOQOLIB
Source Object: G$_NVA_BUTTON_ITEM
Source Module:GOQOLIB
Source Object: G$_NVA_TEXT_ITEM
Source Module:GOQOLIB
Source Object: G$_OPT_WINDOW
And all the source objects listed above are in GOQOLIB form. >
This is "KEY" piece of information that should have been included in your original post. As you are fairly new to the Oracle Forums, you might want to take a few minutes to review the following:
<ul>
<li>Before posting on this forum please read
<li>10 Commandments for the OTN Forums Member
<li>Announcement: Forums Etiquette / Reward Points
</ul>
These threads will help you ask more thorough questions! The more information you can provide about the issue you are having the better able we (the community) are to give you a solution. ;-)
Craig B-)
Edited by: CraigB on Mar 15, 2011 9:27 AM

Similar Messages

  • Problem with Bind Variable in 11.2

    Hi
    I have a slow statement with bind Variables. With literals it works fine. Is there a way to replace the bind by literal in advanced ? I use Release 11.2.0.2.3
    Thank you

    904062 wrote:
    I have a slow statement with bind Variables. With literals it works fine. Is there a way to replace the bind by literal in advanced ? I use Release 11.2.0.2.3This specific scenario is very much an exception to the rule - and you need to back your statement up with execution plans of the SQL with bind variables and with literals, and run stats that show the difference between these two execution plans.
    See the {message:id=9360003} from the {forum:id=75} forum's FAQ for details on how to post a SQL performance tuning question.

  • Problem with bind variable in subselect

    Using the Oracle 9i JDBC Driver and a query of the form:
    select * from atable a where a.thing = ? and a.id in (select id from btable where b.something = ?)
    via a PreparedStatement, the second parameter is not being set correctly. The query executes but does not return the expected results. If I hard code the param value into the query it works fine. I think the second parameter is being set to an empty string (hence the query executes OK but no results returned). This seems to be peculiar to bind variables in sub-selects.
    Has anyone else encountered this problem?

    ps.setLong(1, along);
    ps.setString(2, astring);
    I've checked this against different driver versions. It's OK with the 10.2 driver but fails with the 10.1. So I've moved to the 10.2.

  • A problem with bind variables in a shuttle

    Hi
    After days of research I cannot come up with a solution to this problem which I hope will be easy to describe.
    I'm working on an apex.oracle.com workspace (4.02).
    I have a page with
    a) a region with tree which works well populated by a list of roles and users
    b) a region with a shuttle with the following sql
    List of values
    select SOB_DISPNAME, SOB_ID
    from VIEW_SYSTEMOBJECT
    order by SOB_DISPNAME
    Source
    SELECT SOB_ID FROM VIEW_OBJECTSECURITY_GRANTED WHERE U_ID = :P19_SELECTED_ID
    :P19_SELECTED_ID is a hidden textbox with the currently selected users id.
    The above works very well - I select a user from the tree and the shuttle lhs populates with unselected object names and the rhs with objects selected for the user. A submit button drives a page process which clears out and then inserts the selection into a the table (objectsecurity)
    So far so good.
    I added a list box to the shuttle region (:P19_SOB_TYPE_LIST) so that the data being worked on could be filtered by type, its driven by a LOV that produces a value or 'PAGE', 'REPORT' ... etc.
    I updated the above SQL to be
    List of Values
    select SOB_DISPNAME, SOB_ID
    from VIEW_SYSTEMOBJECT WHERE SOB_TYPE = :P19_SOB_TYPE_LIST
    order by SOB_DISPNAME
    and the source
    SELECT SOB_ID FROM VIEW_OBJECTSECURITY_GRANTED WHERE U_ID = :P19_SELECTED_ID AND SOB_TYPE = :P19_SOB_TYPE_LIST
    So now I would expect that if 'PAGE' is selected in the list box then only objects that are pages will be seen.
    However nothing at all appears.
    If I substitute the bind variable :P19_SOB_TYPE_LIST for 'PAGE' ... WHERE SOB_TYPE = 'PAGE' it works perfectly. So why does :P19_SELECTED_ID do it's job but not P19_SOB_TYPE_LIST ?
    I am probably making some ridiculously simple mistake but I just cannot spot it; is my syntax wrong?.
    The session state is persisting so that I can see the value of :P19_SOB_TYPE_LIST being set to PAGE
    Any help with this would be very much appreciated.

    Hi Dirk
    Thanks for that which looked promising!
    I added P19_SOB_TYPE_LIST as the Cascading LOV Parent Item and removed it from the where clauses of both SQL's and the result was that all types are shown; corresponding to my original position.
    I then added the where clause back to the LOV SQL and both shuttle boxes are blank again
    I added back to the source SQL and again both boxes empty
    Finally I removed the where clause from the LOV SQL (the only other combination) and again lhs box populated with all rows (not filtered) and rhs box blank.
    So unfortunately that doesn't seem to have fixed it.
    Many thanks for the help and any more will be greatly appreciated.
    Regards
    Charles

  • Problem with bind variable

    Hi,
    I need to get bind variables on SIEBEL to test the performance of query and my problem is on BIND :3 because it's impossible to interprete this.
    NAME     POSITION     LAST_CAPTURED     VALUE_STRING
    :1     1,00     02/17/2010 11:54:25     1-15BVYY
    :2     2,00     02/17/2010 11:54:25     
    :3     3,00     02/17/2010 11:54:25     W1B 1AH%
    :1     1,00     02/17/2010 12:48:04     1-15BVYY
    :2     2,00     02/17/2010 12:48:04     
    :3     3,00     02/17/2010 12:48:04     TQ3 3BJ%
    Thanks for your help

    I have no erros.
    I just want to get the real value of bind variable to run my query, but the problem is on bind 2.
    When i run this
    select name,position,last_captured,value_string
    from DBA_HIST_SQLBIND
    where sql_id='&SQLID'
    i obtain this
    NAME     POSITION     LAST_CAPTURED     VALUE_STRING
    :1     1,00     02/17/2010 11:54:25     1-15BVYY
    :2     2,00     02/17/2010 11:54:25     
    :3     3,00     02/17/2010 11:54:25     W1B 1AH%
    :1     1,00     02/17/2010 12:48:04     1-15BVYY
    :2     2,00     02/17/2010 12:48:04     
    :3     3,00     02/17/2010 12:48:04     TQ3 3BJ%
    What is the value of bind :2
    Thanks

  • Problem with Bind Variable not updatable.

    Hi all,
    I'm using Jdev 11.1.2.3.0. In my VO, I created a Bind Variable and set it NOT UPDATABLE. Then I created a View Criteria with some other Bind Variables.
    I use this View Criteria in a search page, but at runtime I see also an inpunt text for the variable that is set NOT UPDATABLE and I can change its value.
    Of course if I try to change the value and I do the search, I get an error.
    This is the VO source:
    <Variable
    Name="UlssVar"
    Kind="where"
    Type="java.lang.String"
    IsUpdateable="false">
    <TransientExpression><![CDATA[adf.context.current.sessionScope.get('ulss')]]></TransientExpression>
    </Variable>
    Is it a ADF bug?
    Thank in advance.

    Hi,
    try selecting the bind variable and open the Property Inspector, under UI Hints, set the "Display Hint" to hide. This should hide it (No bug for this reason)
    Frank

  • Report Performance with Bind Variable

    Getting some very odd behaviour with a report in APEX v 3.2.1.00.10
    I have a complex query that takes 5 seconds to return via TOAD, but takes from 5 to 10 minutes in an APEX report.
    I've narrowed it down to one particular bind. If I hard code the date in it returns in 6 seconds, but if I let the date be passed in from a parameter it takes 5+ minutes again.
    Relevant part of the query (an inline view) is:
    ,(select rglr_lect lect
    ,sum(tpm) mtr_tpm
    ,sum(enrols) mtr_enrols
    from ops_dash_meetings_report
    where meet_ev_date between to_date(:P35_END_DATE,'DD/MM/YYYY') - 363 and to_date(:P35_END_DATE,'DD/MM/YYYY')
    group by rglr_lect) RPV
    I've tried replacing the "to_date(:P35_END_DATE,'DD/MM/YYYY') - 363" with another item which is populated with the date required (and verified by checking session state). If I replace the :P35_END_DATE with an actual date the performance is fine again.
    The weird thing is that a trace file shows me exactly the same Explain Plan as the TOAD Explain where it runs in 5 seconds.
    Another odd thing is that another page in my application has the same inline view and doesn't hit the performance problem.
    The trace file did show some control characters (circumflex M) after each line of this report's query where these weren't anywhere else on the trace queries. I wondered if there was some sort of corruption in the source?
    No problems due to pagination as the result set is only 31 records and all being displayed.
    Really stumped here. Any advice or pointers would be most welcome.
    Jon.

    Don't worry about the Time column, the cost and cardinality are more important to see whther the CBO is making different decisions for whatever reason.
    Remember that the explain plan shows the expected execution plan and a trace shows the actual execution plan. So what you want to do is compare the query with bind variables from an APEX page trace to a trace from TOAD (or sqlplus or whatever). You can do this outside APEX like this...
    ALTER SESSION SET EVENTS '10046 trace name context forever, level 1';Enter and run your SQL statement...;
    ALTER SESSION SET sql_trace=FALSE;This will create a a trace file in the directory returned by...
    SELECT value FROM v$parameter WHERE name = 'user_dump_dest' Which you can use tkprof to format.
    I am assuming that your not going over DB links or anything else slightly unusual?
    Cheers
    Ben

  • Using Bind Variable in a procedure

    Hello all,
    Aim - I wanted to set the value of a bind variable in a procedure
    I was unsuccessful in doing so, pls help me (pls let me know if u need more info).
    I have pasted the commands I executed in a SQL
    SQL> VARIABLE x NUMBER;
    SQL> EXEC :x := 5;
    PL/SQL procedure successfully completed.
    SQL> CREATE OR REPLACE PROCEDURE p1
    2 IS
    3 BEGIN
    4 :x := 5;
    5 END;
    6 /
    Warning: Procedure created with compilation errors.
    SQL> show err
    Errors for PROCEDURE P1:
    LINE/COL ERROR
    4/5 PLS-00049: bad bind variable 'X'

    The reason why the 2nd attempt failed is that in PL/SQL declared code (unlike anonymous blocks) you need to use PL/SQL (host) variables as bind variables and not SQL*Plus (host) variables.
    To explain in more detail:
    SQL> VARIABLE x NUMBER;
    SQL> EXEC :x := 5;
    The EXEC creates and transmits the following PL/SQL anonymous block to Oracle:
    begin
      :x := 5;
    end;It also bind the SQL*Plus host variable (defined as X to the bind variable :x).
    All well. But not the procedure P1 will not work. Numerous reasons - including that when I call the P1 proc from Delphi, or Joe calls it from Java, or Jack calls it from ASP - we do not have that SQL*Plus host variable X defined. That does not exist in the context when we make our PL/SQL calls to P1.
    So how can you write P1 so that we all can use it - from any language?
    You provide an input parameter for P1. This allows all of us to bind our host variables to the P1 call. E.g.
    create or replace procedure P1( x IN OUT number ) is
    begin
      x := 5;
    end;Now when you call it from SQL*Plus, you would do the following:
    SQL> var x number
    SQL> exec P1( x=>:X )
    When I call it from Delphi, I will bind my Delphi (host) variable to the procedure call. Ditto for Joe and Jack.
    Note that PL/SQL itself can also use host and bind variables when talking to the SQL engine. E.g.
    create or replace procedure P2( nRows IN OUT number ) is
    begin
      select count(*) into nRows from all_objects;
    end;In this case, nRows in the SQL statement is a SQL bind variable. It is also the PL/SQL host variable. As you can see, this is very similar to what SQL*Plus did with its host variable.
    Bind variables (within PL/SQL) is explained in more detail in the Oracle® Database PL/SQL User's Guide and Reference guide.

  • How to use bind variables in this procedure

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

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

  • Af:query with bind variables and Saved Search

    I have a VO and view criteria(VC).
    VC has a criteria item ObsoleteDate with range specified as bindVariables "dateFrm" and "dateTo" I dragged & dropped the named criteria as af:Query with table. Table toolbar has 2 buttons in which I set & clear the bind variables. Data is fetched as per as expected based on the VC & bind variables.
    The problem is,
    If I save my search with bind variables set and swap between the saved searches , all works fine. But the moment I clear bind variables & swap between searches.. "dateFrm" is populated and "dateTo" is null and I get an Exception oracle.jbo.AttrValException: JBO-27035: Attribute Obsolete Date: is required.
    Why is this happening?? Saved search is supposed to save the VC with all the bind values set while saving and clearing bind variables shouldn't affect the saved search, right?? Or I have understood it wrong?
    I am using JDeveloper 11.1.2.3.0
    Thanks

    Try
    like ? || '%'

  • BIND VARIABLES IN STORED PROCEDURES

    I find out that the cause of the decreasing of the Shared_pool in my database is for the sql area.
    1* SELECT * FROM V$SGASTAT where name like 'sql%'
    SQL> /
    POOL NAME BYTES
    shared pool sql area 7671024
    SQL> R
    1* SELECT * FROM V$SGASTAT where name like 'sql%'
    POOL NAME BYTES
    shared pool sql area 8147424
    SQL> R
    1* SELECT * FROM V$SGASTAT where name like 'sql%'
    POOL NAME BYTES
    shared pool sql area 8262016
    I flush the shared pool and it increases fastly.
    According to my research I have to use bind variables in SQL Statement to avoid this and apart from that modify the init parameter CURSOR_SHARING.
    Somebody can help me with a simple example about how to use bind variables in Stored Procedures.
    thanks

    According to my research I have to use bind variables in SQL Statement to avoid this and apart from that modify the init parameter CURSOR_SHARING.I would not want to change the CURSOR_SHARING. As for use of bind variables in PL/SQL stored procedures, they come in naturally if you use pl/sql variables in your queries:
        l_empno EMP.EMPNO%TYPE ;
        SELECT <columns> INTO <local storage>
        FROM emp
        WHERE
            empno = l_empno ; /* pl/sql automatically binds for you here */
    .Please post a small sample of type of queries that you are submitting to the database from within these pl/sql blocks for us to see if there is a possibility of improvements.

  • ODT Query Window. Query with binding variable?

    I have the ODT 11.1.0.7.20 installed.
    In "Query Window", I execute an SQL with binding variables. But I only get ORA-01008 errors. How do I do that?
    I want to double click an SQL and load it in "Query Window". How do I do that?
    I want to right click an SQL and select "Open with Query Window". How do I do that?
    In Query Window I want to load an SQL either by drag and drop or by select a function "Open SQL". How do I do that?
    Why none of these functionalities work as you could expect?
    Thanks,
    Tobias

    Finally i found the problem..
    The problem was that i had to remove one line from the properties of my table departments, the property: selectedrowkeys, because it only passed the last selected row.
    Still, i apreciate the help and i had to replace some code in the bean.java , because of the exception error and you didn't had to do that. Maybe i did some configuration in the wrong way and it went wrong.
    Thanks for the help.
    Regards,
    Frederico.

  • Create collection from query with bind variable

    Apex 4.0.2
    Per Joel Re: Collection with bind variable the apex_collection.create_collection_from_query_b supports queries containing bind variable references (:P1_X) but I am not sure how to use this feature, the documentation doesn't have an example, just the API signature for the overloaded version has changed.
    If the query contains 2 bind variable references to session state (:P1_X and :P1_Y), can someone please show an example of what to pass in for the p_names and p_values parameters to the API?
    Thanks
    procedure create_collection_from_query_b(
        -- Create a named collection from the supplied query using bulk operations.  The query will
        -- be parsed as the application owner.  If a collection exists with the same name for the current
        -- user in the same session for the current Flow ID, an application error will be raised.
        -- This procedure uses bulk dynamic SQL to perform the fetch and insert operations into the named
        -- collection.  Two limitations are imposed by this procedure:
        --   1) The MD5 checksum for the member data will not be computed
        --   2) No column value in query p_query can exceed 2,000 bytes
        -- Arguments:
        --     p_collection_name   =  Name of collection.  Maximum length can be
        --                            255 bytes.  Note that collection_names are case-insensitive,
        --                            as the collection name will be converted to upper case
        --     p_query             =  Query to be executed which will populate the members of the
        --                            collection.  If p_query is numeric, it is assumed to be
        --                            a DBMS_SQL cursor.
        -- example(s):
        --     l_query := 'select make, model, caliber from firearms';
        --     apex_collection.create_collection_from_query_b( p_collection_name => 'Firearm', p_query => l_query );
        p_collection_name in varchar2,
        p_query           in varchar2,
        p_names           in wwv_flow_global.vc_arr2,
        p_values          in wwv_flow_global.vc_arr2,
        p_max_row_count   in number default null)
        ;

    VANJ wrote:
    Apex 4.0.2
    Per Joel Re: Collection with bind variable the apex_collection.create_collection_from_query_b supports queries containing bind variable references (:P1_X) but I am not sure how to use this feature, the documentation doesn't have an example, just the API signature for the overloaded version has changed.
    If the query contains 2 bind variable references to session state (:P1_X and :P1_Y), can someone please show an example of what to pass in for the p_names and p_values parameters to the API?Not tried it, but guessing something like
    apex_collection.create_collection_from_query_b(
        p_collection_name => 'foobar'
      , p_query => 'select f.foo_id, b.bar_id, b.baz from foo f, bar b where f.foo_id = b.foo_id and f.x = to_number(:p1_x) and b.y = :p1_y'
      , p_names => apex_util.string_to_table('p1_x:p1_y')
      , p_values => apex_util.string_to_table(v('p1_x') || ':' || v('p1_y')))

  • Query with bind variable, how can use it in managed bean ?

    Hi
    I create query with bind variable (BindControlTextValue), this query return description of value that i set in BindControlTextValue variable, how can i use this query in managed bean? I need to set this value in String parameter in managed bean.
    Thanks

    Put the query in a VO and execute it the usual way.
    If you need to, you can write a parameterized method in VOImpl that executes the VO query with the parameter and then call that method from the UI (as a methodAction binding) either through the managed bean or via a direct button click on the page.

  • SLOW report performance with bind variable

    Environment: 11.1.0.7.2, Apex 4.01.
    I've got a simplified report page where the report runs slowly compared to running the same query in sqldeveloper. The report region is based on a pl/sql function returning a query. If I use a bind variable in the query inside apex it takes 13 seconds to run, and if I hard code a string it takes only a few hundredths of a second. The query returns one row from a table which has 1.6 million rows. Statistics are up-to-date and the columns in the joins and where clause are indexed.
    I've run traces using p_trace=YES from Apex for both the bind variable and hard coded strings. They are below.
    The sqldeveloper explain plan is identical to the bind variable plan from the trace, yet the query runs in 0.0x seconds in sqldeveloper.
    What is it about bind variable syntax in Apex that is causing the bad execution plan? Apex Bug? 11g bug? Ideas?
    tkprof output from Apex trace with bind variable is below...
    select p.master_id link, p.first_name||' '||p.middle_name||' '||p.last_name||' '||p.suffix personname,
    p.gender||' '||p.date_of_birth g_dob, p.master_id||'*****'||substr(p.ssn,-4) ssn, p.status status
    from persons p
    where
       p.person_id in (select ps.person_id from person_systems ps where ps.source_key  like  LTRIM(RTRIM(:P71_SEARCH_SOURCE1)))
    order by 1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.01          0          1         27           0
    Fetch        2     13.15      13.22      67694      72865          0           1
    total        4     13.15      13.23      67694      72866         27           1
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 62  (ODPS_PRIVACYVAULT)   (recursive depth: 1)
    Rows     Row Source Operation
          1  SORT ORDER BY (cr=72869 pr=67694 pw=0 time=0 us cost=29615 size=14255040 card=178188)
          1   FILTER  (cr=72869 pr=67694 pw=0 time=0 us)
          1    HASH JOIN RIGHT SEMI (cr=72865 pr=67694 pw=0 time=0 us cost=26308 size=14255040 card=178188)
          1     INDEX FAST FULL SCAN IDX$$_0A300001 (cr=18545 pr=13379 pw=0 time=0 us cost=4993 size=2937776 card=183611)(object id 68485)
    1696485     TABLE ACCESS FULL PERSONS (cr=54320 pr=54315 pw=0 time=21965 us cost=14958 size=108575040 card=1696485)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
          1   SORT (ORDER BY)
          1    FILTER
          1     HASH JOIN (RIGHT SEMI)
          1      INDEX   MODE: ANALYZED (FAST FULL SCAN) OF
                     'IDX$$_0A300001' (INDEX)
    1696485      TABLE ACCESS   MODE: ANALYZED (FULL) OF 'PERSONS' (TABLE)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file scattered read                       1276        0.00          0.16
      db file sequential read                       812        0.00          0.02
      direct path read                             1552        0.00          0.61
    ********************************************************************************Here's the tkprof output with a hard coded string:
    select p.master_id link, p.first_name||' '||p.middle_name||' '||p.last_name||' '||p.suffix personname,
    p.gender||' '||p.date_of_birth g_dob, p.master_id||'*****'||substr(p.ssn,-4) ssn, p.status status
    from persons p
    where
       p.person_id in (select ps.person_id from person_systems ps where ps.source_key  like  LTRIM(RTRIM('0b')))
    order by 1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.02       0.04          0          0          0           0
    Execute      1      0.00       0.00          0          0         13           0
    Fetch        2      0.00       0.00          0          8          0           1
    total        4      0.02       0.04          0          8         13           1
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 62  (ODPS_PRIVACYVAULT)   (recursive depth: 1)
    Rows     Row Source Operation
          1  SORT ORDER BY (cr=10 pr=0 pw=0 time=0 us cost=9 size=80 card=1)
          1   FILTER  (cr=10 pr=0 pw=0 time=0 us)
          1    NESTED LOOPS  (cr=8 pr=0 pw=0 time=0 us)
          1     NESTED LOOPS  (cr=7 pr=0 pw=0 time=0 us cost=8 size=80 card=1)
          1      SORT UNIQUE (cr=4 pr=0 pw=0 time=0 us cost=5 size=16 card=1)
          1       TABLE ACCESS BY INDEX ROWID PERSON_SYSTEMS (cr=4 pr=0 pw=0 time=0 us cost=5 size=16 card=1)
          1        INDEX RANGE SCAN IDX_PERSON_SYSTEMS_SOURCE_KEY (cr=3 pr=0 pw=0 time=0 us cost=3 size=0 card=1)(object id 68561)
          1      INDEX UNIQUE SCAN PK_PERSONS (cr=3 pr=0 pw=0 time=0 us cost=1 size=0 card=1)(object id 68506)
          1     TABLE ACCESS BY INDEX ROWID PERSONS (cr=1 pr=0 pw=0 time=0 us cost=2 size=64 card=1)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
          1   SORT (ORDER BY)
          1    FILTER
          1     NESTED LOOPS
          1      NESTED LOOPS
          1       SORT (UNIQUE)
          1        TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF
                       'PERSON_SYSTEMS' (TABLE)
          1         INDEX   MODE: ANALYZED (RANGE SCAN) OF
                        'IDX_PERSON_SYSTEMS_SOURCE_KEY' (INDEX)
          1       INDEX   MODE: ANALYZED (UNIQUE SCAN) OF 'PK_PERSONS'
                      (INDEX (UNIQUE))
          1      TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF
                     'PERSONS' (TABLE)

    Patrick, interesting insight. Thank you.
    The optimizer must be peeking at my bind variables with it's eyes closed. I'm the only one testing and I've never passed %anything as a bind value. :)
    Here's what I've learned since my last post:
    I don't think that sqldeveloper is actually using the explain plan it says it is. When I run explain plan in sqldeveloper (with a bind variable) it shows me the exact same plan as Apex with a bind variable. However, when I run autotrace in sqldeveloper, it takes a path that matches the hard coded values, and returns results in half a second. That autotrace run is consistent with actually running the query outside of autotrace. So, I think either sqldeveloper isn't really using bind variables, OR it is using them in some other way that Apex does not, or maybe optimizer peeking works in sqldeveloper?
    Using optimizer hints to tweak the plan helps. I've tried both /*+ FIRST_ROWS */ and /*+ index(ps pk_persons) */ and both drop the query to about a second. However, I'm loath to use hints because of the very dynamic nature of the query (and Tom Kyte doesn't like them either). The hints may end up hurting other variations on the query.
    I also tested the query by wrapping it in a select count(1) from ([long query]) and testing the performance in sqldeveloper and in Apex. The performance in that case is identical with both bind variables and hard coded variables for both Apex and SqlDeveloper. That to me was very interesting and I went so far as to set up two bind variable report regions on the same page. One region wrapped the long query with select count(1) from (...) and the other didn't. The wrapped query ran in 0.01 seconds, the unwrapped took 15ish seconds with no other optimizations. Very strange.
    To get performance up to acceptable levels I have changed my function returning query to:
    1) Set the equality operator to "=" for values without wildcards and "like" for user input with wildcards. This makes a HUGE difference IF no wildcard is used.
    2) Insert a /*+ FIRST_ROWS */ hint when users chose the column that requires the sub-query. This obviously changes the optimizer's plan and improves query speed from 15 seconds to 1.5 seconds even with wildcards.
    I will NOT be hard coding any user supplied values in the query string. As you can probably tell by the query, this is an application where sql injection would be very bad.
    Jeff, regarding your question about "like '%' || :P71_SEARCH_SOURCE1 || '%'". I've found that putting wildcards around values, particularly at the beginning will negate any indexing on the column in question and slows performance even more.
    I'm still left wondering if there isn't something in Apex that is breaking the optimizer "peeking" that Patrick describes. Perhaps something in the way it switches contexts from apex_public_user to the workspace schema?

Maybe you are looking for

  • Possible video card failure?

    Screenshot: http://users.vianet.ca/dtrudel/example1.jpg I've started having problems with playing 3D video games, like the system totally freezing up and I'd have to reboot, or I'd get weird graphic things happening like in the picture above. At firs

  • Maximum disk size?

    That's the maximum disk size or volume size supported? Thanks for any insights.

  • Deploying applications w. Jar files

    I'm experiencing extreme difficulties trying to deploy my application using a jar. I use a file and an image in my app, so I want to include them in the Jar file and I want my app to use the files from the jar. So my question is: how do I do this? An

  • Passing parameters between SWF with  loadMovieNum()

    When calling one swf from another using loadMovieNum("name.swf",0) is it possible to pass parameters to the second SWF like it is done in HTML/JavaScript or using any other method?

  • Problem reinstalling Adobe Premiere CS3 PRO

    Hello,   I had some issues with Adobe Premiere Pro CS3. I uninstalled it without deactivating it. I know, bad move. When I tried to reinstall it, I got an error of incomplete installation. I tried the Adobe Cloud Cleaner and the Microsoft cleaner and