Detail view with bind variable. TreeTable not showing all detail result.

I’m having trouble with treeTable using detail view with bind variables and where clause defined in VO definition.
Both, master and detail view objects, base on the same entity and have the same condition in where clause. The view objects also have bind variables, which are set in prepareRowSetForQuery() method.
Again, these are two different views, that get different result, based on value of one of the bind variable.
When I show results in two different tables on jsf page, where master table has "RowSelection" set on "single", all results are displayed in detail table.
But when I use treeTable, only the first result of the detail is shown.

I tested it in applicationModule and it works, but i think that's the same as two tables on a jsf page.
This is the order in which overridden methods are called in ADF BC or two tables on jsf page
when clicking on row in master table.
PrepareRowSetForQueryDetail
executeQueryForCollection_Detail user param: 2
   Object 2: class [Ljava.lang.Object;  -> print of the object2[] parameter in executeQueryForCollection
     List 0: Bind_ChildId -> viewLink parameter
     List 1: 400035313 -> viewLink parameter value
getEstimatedRowCount_Detail
count: 2
getEstimatedRowCount_Detail
count: 2 And when i click on "expand node" in tree table:
getEstimatedRowCount_Root
count: 2
PrepareRowSetForQuery_Detail
executeQueryForCollection_Detail user param: 2
   Object 2: class [Ljava.lang.Object;
     List 0: Bind_ChildId -> viewLink parameter
     List 1: 400035321
PrepareRowSetForQueryDetail
executeQueryForCollection_Detail user param: 2
   Object 2: class [Ljava.lang.Object;
     List 0: Bind_ChildId -> viewLink parameter
     List 1: 400035313
getEstimatedRowCount_Root
count: 2
getEstimatedRowCount_Root
count: 2
getEstimatedRowCount_Root
count: 2
PrepareRowSetForQueryDetail
executeQueryForCollection_Detail user param: 2
   Object 2: class [Ljava.lang.Object;
     List 0: Bind_ChildId -> viewLink parameter
     List 1: 400035313
PrepareRowSetForQueryDetail
executeQueryForCollection_Detail user param: 2
   Object 2: class [Ljava.lang.Object;
     List 0: Bind_ChildId -> viewLink parameter
     List 1: 400035321
getEstimatedRowCount_Root
count: 2
getEstimatedRowCount_Root
count: 2Values of user parameters are OK. Is there another method that i should override?
I also noticed, that if detail view doesn't have user bind variables, the tree works fine and is shown even in ADF BC (aplication module).
I guess we loose a tree, when using bind variables in detail view object.
Is there a way around it?

Similar Messages

  • View with Bind Variable and ADF table

    Hi all,
    Please note what i have noticed. I created a view with a bind parameter, overriden the prepareSession of my Application Module to set the bind parameter and execute the query. I then created a simple jsf page and included the view as an adf read-only table. When i run the page, the prepareSession is called, sets the bind parameter, however the selected record of the table is always the second record (Not the first record).
    This behaviour can be reproduced with the HR schema. Please follow the below instructions for reproducing the problem.
    1. Create a Fusion Web Application (ADF).
    2. Create business components from tables.
    3. Create a new connection with the HR schema.
    4. Import the Departments table as an entity and then click finish.
    5. Create a view based on the Departments entity.
    6. Modify the Query to include a where clause (where DDepartmentsEO.DEPARTMENT_NAME LIKE :BindParam)
    7. Provide an order by clause (DepartmentsEO.DEPARTMENT_ID DESC)
    8. Creata a bind variable named "BindParam" of type string.
    9. Create an Application Module and include the view object.
    10. Open the Application Module Class and override the prepareSession method
    11. include the following code after super.prepareSession(session):
    ViewObject myView = this.getDepartments1();
    myView.setNamedWhereClauseParam("BindParam", "%");
    myView.executeQuery();
    12. Create a jsf page
    13. Drag the view object on the page as an adf read-only table, selecting the Row Selection, Sorting and Filtering
    14. Run the page.
    You will see that instead of the first record being selected, the second record in the table is selected.
    Can anyone please help me?
    Thank you

    First of all i would like to thank you for replying to my thread.
    Secondly, i would like to inform you that the example that i have provided is just for REPRODUCTION purposes.
    The real scenario has to do with setting the where clause with the authenticated user so that the view will query for data only associated with the authenticated user.
    The only way to overcome this behaviour is to include a view action (namedWhereClause in the page definition)
    However, this is not how i want to implement this. This was working properly in 10g

  • The new value of bind variable does not show up after changed by PL/SQL

    Hi,
    I am running APEX 3.2. I use PL/SQL process to assign a new value to a bind variable, say, :P2_TEST := 123. The new value does not show up on the page although I can see it in the Session status.
    How can I make the new value to be displayed on the page immediately after the process is run?
    Kind regards,
    Tee

    Maybe you could use an ajax routine to refresh the item in your pl/sql routine?
    Thank you,
    Tony Miller
    Webster, TX

  • 10.1.3.5 Flow diagram in Bpel console does not show all details

    Hello,
    Does anybody experience this? And what would be the fix did we missed some configuration (hopefully)?
    Bpel Console-> Instances->choose instance with executed pick activity->Flow (to see diagram of the flow)
    10.1.3.5 does not show underlying activities in a picked onMessage action. However in a "Audit" all details are shown OK. In the attached example it's onAlarm - but it's happening with all of onMessages.
    http://i41.tinypic.com/2jdj1ab.jpg
    10.1.3.4 - shows underlying activities fine
    http://i43.tinypic.com/vwtys1.png
    BPEL process piece of source:
    http://i39.tinypic.com/xm0hoy.png
    thanks in advance!

    Finally found info about this seems to be a known bug:
    Patch 9162451: ACTIVITIES NESTED WITHIN PICK/ONMESSAGE/ONALARM ARE NOT DISPLAYED IN BPEL FLOW

  • User Audit Report not showing all details

    Hello,
    I've encoutered a strange problem with the users audit reports.
    After I assign a user with a few new roles I expect to get the following information in Audit Event Details:
    In the "Changes" area, there should be a table with the following columns: Attribute, Old Value, Attempted Value and New Value that indicates the changes I've made.
    Instead, I get something like this:
    "Changes Old Values=Role A, Role B, Role C. New Values = Role A, Role B, Role C, Role D..."
    Since the desciprion is too long it usualy ends with "..." and does not show the complete information.
    All Successes and All Failures are marked in the Audit Configuration.
    What else am I missing? I am using IdM 8.1.
    Regards,
    R

    It seems that there is a default limit of 4000 characters worth of Attribute changes logged. If the attribute changed string is longer than 4000 chars long it is truncated.
    If you look at the create database tables script used when you set up he repository tables BEFORE installing IdM you will see that in the logs table definition there is a comment suggesting that if 4000 chars is not enough for attribute changes, you may use a CLOB to hold the data. (we use Oracle DB)
    In my opinion this isnt really publicised well enough.
    Furthermore, It also seems that you have to modifiy a setting maxLogAcctAttrChangesLength in the RepositoryConfiguration configuration object. Again not so well known.
    To be honest, I have not been brave enough to change this AFTER we have installed IdM and have used it for a period. I have no idea what consequences there may or may not be if a database table definition is changed... instinct tells me its not good.
    GF

  • Filter view with session variable does not display value properly.

    Hi All,
    I have a very unique issue and I am not sure if anyone ran into this before.
    I have a prompt in my dashboard and a link to a report. The session variable default the value to the current value (term)
    when I click the link to the report I get the following value, on the filter view of the report: Term Code Desc is equal to NQ_SESSION.CSA_Analysis_Term
    however if I click the go button in the prompt I get the value: Term Code Desc is equal to 2030 (2011 Spring)
    does anyone have a solution to this issue
    thanks

    Hello,
    Have the same issue. Any solution. Gurus plz help.
    thanks,
    deep

  • Select list with bind variable does not work

    Hi,
    What can be wrong with a 'select list' with the a simple select
    select omschrijving o, id i
    from basiscodes b
    where domein = 'OPTIES'
    and b.id in
    (select eo.basiscode_id from evenementen_opties eo
    where eo.event_id = :P16_ID)
    The :P16_ID has a value and should give result
    But it does not work at all with 'select list'
    Using the POPUP LOV (display discription, return key value) works nice
    The select retuns less then 10 records

    Hi Flavio,
    As I explained, the P16_ID is an item of the master page (page 16)
    In Page 18 where I want to reuse that value, the item is not there, but I use it to assign
    P18_EVENT_ID with the value in P16_ID and that works fine.
    In an after submit process, I do this :
    declare
    function get_pk return varchar2
    is
    begin
    for c1 in (select EVENEMENT_INSCHRIJVING_SEQ.nextval next_val
    from dual)
    loop
    return c1.next_val;
    end loop;
    end;
    begin
    :P18_ID := get_pk;
    :P18_EVENT_ID := :P16_ID;
    :P18_CREATIE_DT := TO_CHAR(SYSDATE,'DD-MM-YYYY HH24:MI:SS');
    :P18_CREATIE_USER := APEX_APPLICATION.G_USER;
    end;
    The value P16_ID is there before I open page 18
    I made a display item that displays the value P16_ID
    If I change the LOV select in :
    select b.omschrijving o, b.id i
    from basiscodes b
    , evenementen_opties eo
    where b.domein = 'OPTIES'
    and b.id = eo.basiscode_id
    and eo.event_id = 16
    then it returns the value I want : 1 record
    You see, I'm a really new one in apex.
    Forms 6i was easier for me...
    Regards Jules
    null

  • Why selected columns not show all in result output?

    in the analysis, i select 4 columns but only 3 show up, why?

    Is that pivot table? Check ex lured section of the same.
    Need more info your before or after steps done.

  • List view not showing all podcasts

    Guys, I have the annoying problem that podcast management by itunes and the podcast app are F'ed up.
    Not too lobg ago I experienced my ipad greying out most podcasts that were downloaded and on my ipad, for no reason at all. it took me 2 days fiddling with settings and ended up having to set every sync to "on" and set donwloading to "all" and "keep all podcasts"
    Now I'm experiencing the problem that the "list" view in podcast app, is not showing all podcasts, but the "thumbnail" view is (as far as I can tell...). Why is this and how can I fix it to make sure both views show everything?
    I'm running iOS 7.0.6 and iTunes 11.1.5

    Hey there sporry,
    It sounds like your Podcasts app is not showing your library correctly in the List view but Thumbnail looks ok. I recommend the troubleshooting in the article named:
    iOS: An app you installed unexpectedly quits, stops responding, or won’t open
    http://support.apple.com/kb/ts1702
    Restart the app
    Close the app and open it again.
    Restart your device
    Turn the device off and on.
    Update your device software and your apps
    Update your device to the latest version of iOS.
    Update your apps:
    Open the App Store and tap Updates.
    If updates are available, tap Update All.
    If asked, enter your Apple ID password. The updates will download and install.
    You might need a Wi-Fi connection to update some apps.
    Install another app from the App Store
    If your installed app won't open, download and install a free app that isn't on your iOS device. This should reset your Apple ID authorization.
    Remember to use the same Apple ID that you used to download the app that you're having issues with.
    Reinstall the app
    Remove the app from your device and reinstall it. Remember that deleting an app also deletes its data.
    Delete the app.
    Press the Home button.
    Go to the App Store and download the app again.
    Wait for the app to download, then open it from the Home screen.
    If the download stops, you can resume it.
    Thank you for using Apple Support Communities.
    Cheers,
    Sterling

  • Comment View of Acrobat not showing the details of annotations

    Hi,
    We have one application in which Acrobat(8.0) is embedded in IE(7.0) Browser. And when we create annotations in the PDF file, the comment view of Acrobat is not showing any detail of it. It looks to me that, details of annotations are coming in the comment view but it is not visible.
    This problems is specific to IE 7.0 and Acrobat 8.0. Because it is working fine with IE 6.0.
    Any Idea why this problem is coming with IE7.0 ?
    Regards,
    Arvind

    Hi Leonard,
    Do you have any idea, why the above mentioned issue is coiming with IE7.0. Since I am using Adobe Acrobat 3D version 8.1.1.
    Regards,
    Arvind

  • 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

  • Why an "ORA-01006: bind variable does not exist" error when no dynamic SQL?

    Hi all,
    While running PL/SQL in SQL Developer 3.2.09, I got the following error after adding a section of code. Note that nothing I'm doing has anything to do with dynamic SQL (which is what 01006 is supposedly about).
    Error report:
    ORA-01006: bind variable does not exist
    01006. 00000 - "bind variable does not exist"
    *Cause:   
    *Action:
    After commenting out the new chunk of code that caused the error, the error persisted.
    After deleting the new code, the error went away.
    What the heck!?!? If you have any ideas, please lay 'em on me.
    Thanks so much,
    Kim
    P.S. It's a few hundred lines of code, so I didn't append it to this post and I don't see how to attach a file.

    Let's review a few facts:
    1. You post a question in the sql developer forum that has no apparent relation to sql developer. You could confirm this by doing the test using sql*plus or some other tool.
    2. You provide NO information about what database you are even using. The only clue is an ORA -xxx message that means SOME version of Oracle is involved.
    3. You provide NO information about what the four digit version of Oracle DB is being used.
    4. You provide NO information about what the code in general or what that specific section of the code is even doing. The code could be doing literally anything that Oracle is capable of doing.
    That's a bit like calling a mechanic you don't know, telling them your car is making a funny noise and asking them what the problem with your car is.
    >
    While running PL/SQL in SQL Developer 3.2.09, I got the following error after adding a section of code. Note that nothing I'm doing has anything to do with dynamic SQL (which is what 01006 is supposedly about).
    Error report:
    ORA-01006: bind variable does not exist
    01006. 00000 - "bind variable does not exist"
    *Cause:
    *Action:
    The error gives no indication of where the error occurred in the code.
    >
    Your first clue that your troubleshooting method is seriously flawed is when you make statements that aren't supported by any evidence at all but appear to be nothing but your opinion.
    Your second clue is when those statements appear to directly contradict what Oracle is telling you.
    I'm talking about these two statements you make; which you state as if they were universal truths
    >
    nothing I'm doing has anything to do with dynamic SQL
    (which is what 01006 is supposedly about).
    >
    If thoe were true then your 'unstated' conclusion appears to be that Oracle is wrong in saying 'bind variable does not exist'
    Sorry - but I would place my money on Oracle.
    I'm sure the above may sound harsh - it is intended to be. My four major rules (there are more) when troubleshooting Oracle problems.
    1. Assume that Oracle is CORRECT when it tells you there is a problem.
    2. Assume that you are WRONG if your opinion conflicts with what Oracle is telling you - see rule #1.
    3. Don't make ANY other assumptions. You can form hypotheses but don't state them as facts until they are proven.
    4. Your 'opinion' is only useful to the extent that it can help you form meaningful hypotheses - see rule #3.
    >
    To reiterate, there is no dynamic SQL in the code.
    >
    To reiterate - if, as you state, that error relates to dynamic SQL and bind variables then it can not be disputed that:
    ORACLE DOESN'T AGREE WITH YOU!
    So let's try it my way and hypothesize that Oracle is correct (see rule #1 above).
    Then by definition this statement by Oracle is correct
    >
    ORA-01006: bind variable does not exist
    >
    And that should immediately raise this question:
    1. where might there be a bind variable that does not exist?
    which leads to a prerequisite question:
    2. where are ALL of the bind variables that might be being used?
    Question #2 is where you need to start your search. Here are at least five possibilities (there are more)
    1. your code - this should be easiest to check and you state that your 'anonymous' block does not have any.
    2. a table trigger - triggers that use the :NEW, :OLD or :PARENT pseudocolumns. Those psuedocolumns are BIND variables and the trigger code that uses them is, by definition, dynamic sql.
    3. a pl/sql package/function/procedure - any of these might be being called from trigger code or a view that is involved in the transaction. Any of these could take a parameter and/or use bind variables and cause your problem if that bind variable does 'not exist'.
    4. a functional index - can also trigger code from #3 above
    5. an audit trigger that logs the audit activity that your user or your code is performing. This code could be trying to use a SYS_CONTEXT environment variable that has not been created and cause a 'bind variable does not exist' error.
    See rule #1 - Oracle is CORRECT. Until you have identified and examined ALL of the code (not just your anonymous block) being executed and ruled it out you should continue with the hypotheses that Oracle is CORRECT.
    In the (extremely) unlikely event that you can show that Oracle is NOT correct you should file a SOR with Oracle.

  • Bind variable is not defined

    Hi, it is my first attempt to modify a rdf file.
    I run into a problem while trying to add an additional user parameter in an existing rdf file. While I am successful in adding a new FREQUENCY user parameter and I am able to update the form to show this new parameter, I am not able to run the report.
    I have updated the SQL query in the report editor, under data view to use this new parameter :FREQUENCY. (select ... from table where frequency= :FREQUENCY) There was no error here.
    Whenever I run the report, I will always get an error saying:
              "REP-0730: The following bind variable is not defined: "(nothing behind this                                                             error message)
    The program will have a memory error and it exits itself.
    I had tried many methods trying to solve this problem to no avail.
    I am using Oracle 9i Reports Builder 9.0.2.0.3.
    I would appreciate any help given on this matter.
    Thank you :)
    Message was edited by:
    Leion

    In Object Navigator Under Layout ->User parameters are you able to see your bind variable FREQUENCY?

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

  • 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