Preserve Bind values in the SQL worksheet

Hello

When you run the SQL statements with var/binding settings, SQLD can persist values entered the tool reboots?

Is there a preference that controls this?

Java (TM) Platform1.7.0_71
Oracle IDE4.0.3.16.84
Support for versioning4.0.3.16.84

Thank you

Manish

Never mind. Found, he looked at me, but I was blind.

Under the worksheet, check 'Save the Bind Variables on the disc to the output'.

Tags: Database

Similar Questions

  • How to perform the procedure in the SQL worksheet?

    Hi, anyone knows, how I can execute procedure here?

    I try to EXEC sec_roles, EXEC security_admin.sec_roles, EXECUTE - there's a SQL statement error. When I use the CALL - there is no such procedure (I have execute privileges).

    Although in SQLPlus EXEC works, but there are problems with the standard SQL commands (each of them '2' returns any content is).

    Any ideas?

    Concerning
    Krzysztof

    EXEC procedure (parameters) is a plu sql (and some others) shortcut for

    BEGIN
       procedure(parameters);
    END;
    

    So try that and then pressing / on anything in the sql worksheet that makes a statement in execution.

    Note that if your procedure has defined parameters as OUT or IN OUT, you need to provide a variable to accept the returned values.

    John

  • problem with bind variables in the SQL query view object

    Hi all

    I use JDev 11.1.2.4.0.

    I have a problem with bind variables in the SQL query view object.

    This is my original SQL

    SELECT sum(t.TIME) , t.legertype_id
    FROM LEDGER t
    WHERE t.nctuser_id = '20022' 
          AND to_char(t.insertdate,'YYYYMMDD') in ('20130930','20130929')
    group by t.legertype_id
    

    In my view .xml object query tab, I am writing this

    SELECT sum(t.TIME) , t.legertype_id
    FROM LEDGER t
    WHERE   t.nctuser_id = '20022'
        AND to_char(t.insertdate,'YYYYMMDD') in :dddd
    group by t.legertype_id
    

    Davis here is a variable of Type liaison: String, updatable and necessary.

    I try to deal with Davis as ('20130930 ', ' 20130929') hoping the view object, run as my original SQL.

    But failed. The view object retrieves 0 line after that I run.

    Why?

    Thank you! ('2original SQL0130930', '20130929') ('20130930 ', ' 20130929')

    A variable binding cannot be used as this is why you must use years table. Check decompilation binary ADF: using oracle.jbo.domain.Array with ViewCriteria to see a solution.

    Timo

  • How to get line numbers to display on the SQL worksheet?

    Dear Forum,

    I learn the SQL Developer.  I use it in my work and school.  At school, when I enter a query in the SQL worksheet, line numbers show in a column to the left of the editing area.  In my work, no line number.  I'm working on a fairly long query at my work, and the line numbers would be useful.

    I looked at tools / preferences / settings for the Code Editor, but do not find a setting for line numbers.  I looked at the other tabs in preferences and found nothing that looked useful.

    I have looked at all of the choices on the display list, but can't find anything on line numbers.

    Am I missing something obvious?  Line numbers is also available?  If so, how?

    I looked at various hits "line number" in this forum, but I've not found anything exactly the point.

    Beverly

    PS Oracle 11g, SQL Developer 3.0.04, Linux x 86-64 (don't have version)

    Tools-> preferences /-> Code Editor-> line gutter

  • How to return the value of the SQL in the text element

    Hi friends

    I need you to guide me how I can print the return value of the SQL in a text element

    Suppose it's your function
    create or replace function get_value
    return number
    is
    begin
    return 3*2;
    end;
    /
    any help that I enjoyed

    Thank you

    >

    http://i46.Tinypic.com/11l0s5h.jpg

    This is ORA-06502: PL/SQL: digital error or value.

    Check the data type and size for items of text or any other variables or fields in the service.

  • Formatting characters in the SQL worksheet in the version 2.1.1.64

    Hello

    Using the version 2.1.1.64

    When I type SQL in the SQL worksheet calculation is to show formatting characters - for example all the spaces display as a light gray and a newline character appears at the end of each line.

    Formatting characters displayed not initially when I started to use this version. I don't know how this setting is enabled, but there doesn't seem to be a preferences setting to turn it off. Any ideas?

    Tools-> preferences-> Code Editor-> display-> Show characters

    should take care of your problem.

  • How can I turn off automatic formatting while working in the SQL worksheet?

    Friends,

    Hope you can help with a quick question.

    Is it possible to stop the automatic formatting of SQL statements in the SQL worksheet?

    for example, when I type select * double it auto SELECT formats becomes * FROM DUAL when I press return.

    I use SQL Developer 2.1.1.64

    Thanks in advance

    Preferences - editor of Code - completion Insight - uncheck change case when typing

    Have fun
    K.

  • SQL Dev 1.5.3: No "feedback" in the SQL worksheet? for example "1,000 rows deleted.

    In SQL Developer 1.5.3 seems no "feedback" in the SQL worksheet when you insert, update, and delete records. So I like the timer, it is more important for users to get comments for the UPDATE and DELETE statements; for example, it is essential to know if 0, 1 or 1,000 files have been updated by a particular SQL statement - also for DELETE queries (for example when users forget the WHERE clause, feedback is an important mechanism to realize the error).

    Is it possible to turn on your comments? ("set feedback we" seems not be honored). What is this fixed point 1.5.4? Should be presented as a feature request?

    Thank you.

    Dana

    Published by: Dana N on May 18, 2009 05:06

    Blame poor analytical skills or whatever, but they managed to have 2 reports areas separated from each other.
    You've found one of the toolbar in the spreadsheet with the timings of course, but there is also one in the status bar of heads...

    Have fun
    K.

  • Impossible to delete characters on the SQL worksheet

    I am facing a noisy problem with SQL Developer (Versioning Support 1.5.5.59.69)...
    Whenever I open a SQL worksheet, I can insert characters but I can't remove them...

    What happened!

    Hello
    There is too much of a week, I had problem with strikes in the worksheets. For me has been useful tools-> preferences-> accelerators-> load Preset...
    This returned value hit in the normal state.
    Petr

  • Passing the value of the SQL query select list

    Hello

    In my application users have in their homepage to a region which has two simple things, a part of LIST SLECT lov function and a BUTTON

    There is also another page which has a normal life to report which shows the employees.


    Homepage the user can select certain number of Department in its 'SLECT-LIST' and click 'open '.


    For example: If the user has selected a DEP_NUM_5 and click on the BUTTON it will be redirected to the page of a report and gets only showed the employees belonging to the Department 5.


    The report page contains a simple SQL query, and I understand that somehow I must pass the value in the SELECT LIST, where I now have the '?


    How can I do this, where should I start?

    Of course I would really appreciate an example of code, if anyone has time to do a.

    
    select "EMP_ID", 
    "EMP_FORNAME",
    "EMP_SURNAME",
    "DEP_NUMBER"
    from EMP E
    where E.DEP_NUMBER = ????????
    
    

    Hi Sozua,

    1. create an item hidden on the page where you have the report.

    I say P2_DEPT_NO

    2 assign to that in your sql query

    select "EMP_ID",
        "EMP_FORNAME",
        "EMP_SURNAME",
        "DEP_NUMBER"
        from EMP E
        where E.DEP_NUMBER = :P2_DEPT_NO
    

    below the area source ther is also an option

    Elements of page to submit-> put this element in this.

    for example;

    Page to submit items: P2_DEPT_NO

    3. change your button

    Action: Redirecting to page of this application

    Page: 2 / / assuming that page 2 is the report page

    Place these items: P2_DEPT_NO

    with these values: & P1_SELECT_LIST.  assuming that selection list is on page 1

    Hope this helps you,

    Kind regards

    Jitendra

  • Works Datapump inside the SQL worksheet...

    Hi all

    "running the following code inside the spreadsheet and he just spits ' anonymous block completed.

    *****************************

    Set scan off

    Set serveroutput on

    escape game off

    whenever sqlerror exit

    DECLARE

    number of H1;

    errorvarchar varchar2 (100): = "ERROR";

    tryGetStatus number: = 0;

    Start

    H1: = dbms_datapump.open (operation = > 'IMPORT', job_mode = > job_name 'FULL' = > 'IMPORT_JOB_SQLDEV_73', version = > 'COMPATIBLE');

    tryGetStatus: = 1;

    dbms_datapump.set_parallel (handle = > h1, degree = > 1);

    dbms_datapump.add_file (handle = > h1, filename = > 'IMPORTtest2.LOG', directory = > 'DATA_PUMP_DIR', filetype = > 3);

    dbms_datapump.set_parameter (handle = > h1, name = > 'KEEP_MASTER', value = > 0);

    dbms_datapump.add_file (handle = > h1, filename = > ' ORAEU_COPIED.) (DMP", directory = >"DATA_PUMP_DIR", filetype = > 1);

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\APT_SYS_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/APT_SYS_DATA01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\APT_SYS_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/APT_SYS_IDX01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\DATA_MART_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATA_MART_DATA01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\DATA_MART_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATA_MART_IDX01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > UPPER ('C:\ORACLE\ORADATA\ORCL/DATA_STORE_DATA01.) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATA_STORE_DATA01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\DATA_STORE_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATA_STORE_IDX01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\RNET2_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/RNET2_DATA01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\RNET2_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/RNET2_IDX01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\DATA_AMA_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATA_AMA_DATA01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\DATA_AMA_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATA_AMA_IDX01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\DATASERVICES_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATASERVICES_DATA01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\DATASERVICES_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATASERVICES_IDX01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\ARC_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/ARC_DATA01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\MCSS_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/MCSS_DATA01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\MCSS_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/MCSS_IDX01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\IPAS_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/IPAS_DATA01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\IPAS_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/IPAS_IDX01.) DBF'));

    dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\PFIZERCMS_DATA01.)) DBF "), value = >"

    dbms_datapump.set_parameter (handle = > h1, name = > 'INCLUDE_METADATA', value = > 1);

    dbms_datapump.set_parameter (handle = > h1, name = > 'DATA_ACCESS_METHOD', value = > "AUTOMATIC").

    dbms_datapump.set_parameter (handle = > h1, name = > 'REUSE_DATAFILES', value = > 0);

    dbms_datapump.set_parameter (handle = > h1, name = > 'TABLE_EXISTS_ACTION', value = > 'REPLACE');

    dbms_datapump.set_parameter (handle = > h1, name = > 'SKIP_UNUSABLE_INDEXES', value = > 0);

    dbms_datapump. START_JOB (handle = > h1, skip_current = > 0, abort_step = > 0);

    dbms_datapump. Detach (handle = > h1);

    errorvarchar: = "NO_ERROR"

    EXCEPTION

    WHILE OTHERS THEN

    BEGIN

    IF ((errorvarchar = ' ERROR') AND (tryGetStatus = 1)) THEN

    DBMS_DATAPUMP. Detach (H1);

    END IF;

    EXCEPTION

    WHILE OTHERS THEN

    NULL;

    END;

    LIFT;

    END;

    /

    *****************

    all entries are appreciated

    Thank you

    Please let me know if you see a code problem

    What is your question has to do with Sql Developer?

    Unless you can connect you must mark ANSWERED thread and repost it in Sql and Pl/Sql forum

    the Japan Government says:

    Hi Jeff

    I expect that it runs the import at least.

    Get this error now on line 66:

    EXCEPTION

    WHILE OTHERS THEN

    BEGIN

    IF ((errorvarchar = ' ERROR') AND (tryGetStatus = 1)) THEN

    DBMS_DATAPUMP. Detach (H1);

    END IF;

    EXCEPTION---> line 66

    WHILE OTHERS THEN

    NULL;

    END;

    When you repost you should post the EXACT code you use. The code you posted is NOT valid: you must also REMOVE the WHEN of OTHER or you can expect everyone to book you to INTENTIONALLY HIDE any exceptions that occur. Why do you NOT want to know if Oracle finds problems in your code? That makes NO sense at all.

    IF ((errorvarchar = ' ERROR') AND (tryGetStatus = 1)) THEN

    There is NO SPACE after the "and" what is garbage just as far as Oracle are concerned.

    Either you have posted an incorrect code or your code has syntax errors and will not compile or run anyway.

    I suggest that correct you your syntax errors before reposting in the Sql forum. If you have pain to find their delete ALL unnecessary code to reduce the problem to the example as SIMPLE as possible, until you find the code causing errors.

  • End of the characters on the line in the SQL worksheet

    Hello

    All of a sudden end of characters on the line in the SQL in SQL Developer worksheet.

    Can someone please advice how to hide those?

    It looks like 2 ' < ' characters followed by a mathematical symbol Pi.

    Thank you
    Sagay

    Tools | Preferences | Code editor | Display | Show the white space characters

  • How can I leave echo in the sql worksheet developer sql?

    When I generate out of the script from a sql file that is loaded into the spreadsheet sqldeveloper, the statement appears in the output pane before the results of the query. This can occur because there are substitution (for example & site) variables in the query. However, I would really for Nothing of the sql statement displayed in the results - I want to save it as an output file. Is there a way to do this? 'left echo' is not recognized as a valid command.

    I know that I can export data in the results pane of query to a text as well as a csv file, etc., but I don't like how it looks - I want the data as described in the output of the script.

    Here is a portion of the script... just enough to show "set echo off" and use of the user variable.

    Thank you
    Carol
    set echo off
    select s.site_id SID,substr(s.site_name,1, 50) SITE, month.start_date_time, 
    sum(decode(sd.datatype_id,111,month.value,null)) EC,
    sum(decode(sd.datatype_id,1217,month.value,null)) PPM,
    round(sum(decode(sd.datatype_id,19,month.value,decode(sd.datatype_id,93,month.value,null))),2) CFS,
    round(sum(decode(sd.datatype_id,1216,month.value,decode(sd.datatype_id,1218,month.value,null))),0)  TOTAL_CFS,
    round(sum(decode(sd.datatype_id,20,month.value,decode(sd.datatype_id,1113,month.value,null))),0)  AF
    from hdb_site s, hdb_site_datatype sd, r_month month, ref_yao_sal_flow_site_map map
    where map.flow_site_id = &&site
    set verify off
    

    can hide variable replacements in sqlplus and sql developer

  • SQLdeveloper export to Excel - how to hide the SQL worksheet for data export

    Export to Excel - how to hide SQL worksheet for data export?

    Hello

    SQL Developer forum is here: SQL Developer

    Frank

  • Bind variables in the SQL causes slow

    We have a strange problem in our PeopleSoft system that I traced to a SELECT statement using bind variables, if hardcode us them values in SQL, it runs very fast.
    but using bindings (what the application does) a problem of efficiency. I'm going to re - write the code that is based on a view of three tables joined to go against
    the base tables and I don't think I'll have a problem. However, I would like to know why the problem exists in the first place. Here is what info I have:
    Oracle version: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

    It's the 'good' application without links:
    SELECT COUNT(*)
    FROM sysadm.PS_ERN_PROG_DESCR A
    WHERE A.ERN_PROGRAM = 'VT'
    AND A.ERNCD         = '01'
    AND EFFDT           =
      (SELECT MAX(B.EFFDT)
      FROM sysadm.PS_ERN_PROG_DESCR B
      WHERE B.ERN_PROGRAM = 'VT'
      AND B.EFFDT        <= TO_DATE('2009-10-10','YYYY-MM-DD')
      );
    And the 'good' explains the plan:
     Plan hash value: 3344976101
    
    -------------------------------------------------------------------------------------------------------------
    | Id  | Operation                              | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                       |                    |     1 |    33 |    58  (23)| 00:00:01 |
    |   1 |  SORT AGGREGATE                        |                    |     1 |    33 |            |          |
    |   2 |   NESTED LOOPS                         |                    |     1 |    33 |     3   (0)| 00:00:01 |
    |   3 |    NESTED LOOPS                        |                    |     1 |    22 |     2   (0)| 00:00:01 |
    |*  4 |     INDEX UNIQUE SCAN                  | PS_ERN_PROGRAM_DEF |     1 |    12 |     1   (0)| 00:00:01 |
    |   5 |      SORT AGGREGATE                    |                    |     1 |     9 |            |          |
    |   6 |       VIEW                             |                    |    23 |   207 |    51  (26)| 00:00:01 |
    |*  7 |        FILTER                          |                    |       |       |            |          |
    |   8 |         SORT GROUP BY                  |                    |    23 |  1748 |    51  (26)| 00:00:01 |
    |*  9 |          HASH JOIN                     |                    |  2995 |   222K|    49  (23)| 00:00:01 |
    |* 10 |           TABLE ACCESS FULL            | PS_EARNINGS_TBL    |  1913 | 24869 |    15   (7)| 00:00:01 |
    |* 11 |           HASH JOIN                    |                    | 13621 |   838K|    30  (20)| 00:00:01 |
    |  12 |            TABLE ACCESS FULL           | PS_EARNINGS_TBL    |  1913 | 42086 |    14   (0)| 00:00:01 |
    |* 13 |            HASH JOIN                   |                    |  3097 |   124K|    14  (29)| 00:00:01 |
    |* 14 |             TABLE ACCESS BY INDEX ROWID| PS_ERN_PROGRAM_TBL |     9 |   207 |     2   (0)| 00:00:01 |
    |* 15 |              INDEX RANGE SCAN          | PS_ERN_PROGRAM_TBL |    18 |       |     1   (0)| 00:00:01 |
    |* 16 |             TABLE ACCESS FULL          | PS_ERN_PROGRAM_DEF | 12035 |   211K|    10  (20)| 00:00:01 |
    |* 17 |     INDEX RANGE SCAN                   | PS_EARNINGS_TBL    |     1 |    10 |     1   (0)| 00:00:01 |
    |  18 |      SORT AGGREGATE                    |                    |     1 |    10 |            |          |
    |* 19 |       INDEX RANGE SCAN                 | PS_EARNINGS_TBL    |     1 |    10 |     2   (0)| 00:00:01 |
    |* 20 |    TABLE ACCESS BY INDEX ROWID         | PS_ERN_PROGRAM_TBL |     1 |    11 |     1   (0)| 00:00:01 |
    |* 21 |     INDEX UNIQUE SCAN                  | PS_ERN_PROGRAM_TBL |     1 |       |     0   (0)| 00:00:01 |
    -------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       4 - access("A"."ERN_PROGRAM"='VT' AND "A"."EFFDT"= (SELECT MAX("$vm_col_2") FROM  (SELECT /*+ */
                  "EFFDT" "$vm_col_1","A"."EFFDT" "$vm_col_2" FROM SYSADM."PS_EARNINGS_TBL"
                  "C",SYSADM."PS_ERN_PROGRAM_TBL" "B",SYSADM."PS_ERN_PROGRAM_DEF" "A",SYSADM."PS_EARNINGS_TBL" "D"
                  WHERE "D"."EFFDT"<="A"."EFFDT" AND "D"."ERNCD"="C"."ERNCD" AND "D"."EFFDT"<=TO_DATE(' 2009-10-10
                  00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "A"."EFFDT"="B"."EFFDT" AND
                  "A"."ERN_PROGRAM"="B"."ERN_PROGRAM" AND "A"."ERN_PROGRAM"='VT' AND "A"."EFFDT"<=TO_DATE(' 2009-10-10
                  00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "B"."EFFDT"<=TO_DATE(' 2009-10-10 00:00:00', 'syyyy-mm-dd
                  hh24:mi:ss') AND "B"."ERN_PROGRAM"='VT' AND "B"."EFF_STATUS"='A' AND "C"."ERNCD"="A"."ERNCD" GROUP
                  BY "D"."ERNCD",ROWID,ROWID,ROWID,ROWID,"A"."EFFDT","EFFDT" HAVING "EFFDT"=MAX("D"."EFFDT"))
                  "$vm_view") AND "A"."ERNCD"='01')
       7 - filter("EFFDT"=MAX("D"."EFFDT"))
       9 - access("D"."ERNCD"="C"."ERNCD")
           filter("D"."EFFDT"<="A"."EFFDT")
      10 - filter("D"."EFFDT"<=TO_DATE(' 2009-10-10 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
      11 - access("C"."ERNCD"="A"."ERNCD")
      13 - access("A"."ERN_PROGRAM"="B"."ERN_PROGRAM" AND "A"."EFFDT"="B"."EFFDT")
      14 - filter("B"."EFF_STATUS"='A')
      15 - access("B"."ERN_PROGRAM"='VT' AND "B"."EFFDT"<=TO_DATE(' 2009-10-10 00:00:00', 'syyyy-mm-dd
                  hh24:mi:ss'))
      16 - filter("A"."ERN_PROGRAM"='VT' AND "A"."EFFDT"<=TO_DATE(' 2009-10-10 00:00:00', 'syyyy-mm-dd
                  hh24:mi:ss'))
      17 - access("C"."ERNCD"='01')
           filter(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))= (SELECT
                  MAX(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))) FROM SYSADM."PS_EARNINGS_TBL" "D" WHERE
                  SYS_OP_DESCEND("EFFDT") IS NOT NULL AND SYS_OP_DESCEND("EFFDT")>=SYS_OP_DESCEND(:B1) AND
                  "D"."ERNCD"=:B2 AND SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=:B3))
      19 - access("D"."ERNCD"=:B1 AND SYS_OP_DESCEND("EFFDT")>=SYS_OP_DESCEND(:B2) AND
                  SYS_OP_DESCEND("EFFDT") IS NOT NULL)
           filter(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=:B1)
      20 - filter("B"."EFF_STATUS"='A')
      21 - access("B"."ERN_PROGRAM"='VT' AND "A"."EFFDT"="B"."EFFDT")
    Here is the 'good' autotrace:
    SQL> variable ppe_date varchar2(10)
    SQL> variable erncd varchar2(3)
    SQL> exec :ppe_date := '2009-10-10'
    SQL> exec :erncd := '01'
    SQL> SELECT COUNT(*)
      2  FROM PS_ERN_PROG_DESCR A
      3  WHERE A.ERN_PROGRAM = 'VT'
      4  AND A.ERNCD         = '01'
      5  AND EFFDT           =
      6    (SELECT MAX(B.EFFDT)
      7    FROM PS_ERN_PROG_DESCR B
      8    WHERE B.ERN_PROGRAM = 'VT'
      9    AND B.EFFDT        <= TO_DATE('2009-10-10','YYYY-MM-DD')
     10    );
    
      COUNT(*)
    ----------
             1
    
    Elapsed: 00:00:01.23
    
    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=59 Card=1 Bytes=33)
       1    0   SORT (AGGREGATE)
       2    1     NESTED LOOPS (Cost=3 Card=1 Bytes=33)
       3    2       NESTED LOOPS (Cost=2 Card=1 Bytes=22)
       4    3         INDEX (UNIQUE SCAN) OF 'PS_ERN_PROGRAM_DEF' (INDEX (UNIQUE)) (Cost=1 Card=1 Bytes=12)
       5    4           SORT (AGGREGATE)
       6    5             VIEW (Cost=52 Card=24 Bytes=216)
       7    6               FILTER
       8    7                 SORT (GROUP BY) (Cost=52 Card=24 Bytes=1824)
       9    8                   HASH JOIN (Cost=50 Card=3177 Bytes=241452)
      10    9                     TABLE ACCESS (FULL) OF 'PS_EARNINGS_TBL' (TABLE) (Cost=15 Card=1921 Bytes=24973)
      11    9                     HASH JOIN (Cost=31 Card=14488 Bytes=912744)
      12   11                       TABLE ACCESS (FULL) OF 'PS_EARNINGS_TBL' (TABLE) (Cost=14 Card=1921 Bytes=42262)
      13   11                       HASH JOIN (Cost=15 Card=3303 Bytes=135423)
      14   13                         TABLE ACCESS (FULL) OF 'PS_ERN_PROGRAM_TBL' (TABLE) (Cost=2 Card=9 Bytes=207)
      15   13                         TABLE ACCESS (FULL) OF 'PS_ERN_PROGRAM_DEF' (TABLE) (Cost=12 Card=12856 Bytes=231408)
      16    3         INDEX (RANGE SCAN) OF 'PS_EARNINGS_TBL' (INDEX (UNIQUE)) (Cost=1 Card=1 Bytes=10)
      17   16           SORT (AGGREGATE)
      18   17             INDEX (RANGE SCAN) OF 'PS_EARNINGS_TBL' (INDEX (UNIQUE)) (Cost=2 Card=1 Bytes=10)
      19    2       TABLE ACCESS (BY INDEX ROWID) OF 'PS_ERN_PROGRAM_TBL' (TABLE) (Cost=1 Card=1 Bytes=11)
      20   19         INDEX (UNIQUE SCAN) OF 'PS_ERN_PROGRAM_TBL' (INDEX (UNIQUE)) (Cost=0 Card=1)
    
    
    
    
    
    Statistics
    ----------------------------------------------------------
              0  recursive calls
              0  db block gets
            182  consistent gets
              0  physical reads
              0  redo size
            232  bytes sent via SQL*Net to client
            278  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
              1  rows processed
    
    SQL> spool off
    ===================================
    This is the 'bad' query using bindings:
    ===================================
    SELECT COUNT(*)
    FROM sysadm.PS_ERN_PROG_DESCR A
    WHERE A.ERN_PROGRAM = 'VT'
    AND A.ERNCD         = :erncd
    AND EFFDT           =
      (SELECT MAX(B.EFFDT)
      FROM sysadm.PS_ERN_PROG_DESCR B
      WHERE B.ERN_PROGRAM = 'VT'
      AND B.EFFDT        <= TO_DATE(:ppe_date,'YYYY-MM-DD')
      );
    The 'bad' explain plan
    explain plan succeeded.
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 337039962
    
    --------------------------------------------------------------------------------------------------------
    | Id  | Operation                         | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                  |                    |     1 |    33 |    20  (25)| 00:00:01 |
    |   1 |  SORT AGGREGATE                   |                    |     1 |    33 |            |          |
    |   2 |   NESTED LOOPS                    |                    |     1 |    33 |     3   (0)| 00:00:01 |
    |   3 |    NESTED LOOPS                   |                    |     1 |    22 |     2   (0)| 00:00:01 |
    |*  4 |     INDEX UNIQUE SCAN             | PS_ERN_PROGRAM_DEF |     1 |    12 |     1   (0)| 00:00:01 |
    |   5 |      SORT AGGREGATE               |                    |     1 |    63 |            |          |
    |   6 |       NESTED LOOPS                |                    |     1 |    63 |    13  (39)| 00:00:01 |
    |   7 |        NESTED LOOPS               |                    |     1 |    52 |    12  (42)| 00:00:01 |
    |*  8 |         HASH JOIN                 |                    |     4 |   168 |    12  (42)| 00:00:01 |
    |   9 |          VIEW                     | VW_SQ_1            |    88 |  2112 |     9  (45)| 00:00:01 |
    |  10 |           SORT GROUP BY           |                    |    88 |  2728 |     9  (45)| 00:00:01 |
    |  11 |            MERGE JOIN             |                    |  3087 | 95697 |     7  (29)| 00:00:01 |
    |  12 |             SORT JOIN             |                    |   643 | 11574 |     2   (0)| 00:00:01 |
    |* 13 |              INDEX RANGE SCAN     | PS_ERN_PROGRAM_DEF |   643 | 11574 |     2   (0)| 00:00:01 |
    |* 14 |             SORT JOIN             |                    |    96 |  1248 |     5  (40)| 00:00:01 |
    |* 15 |              INDEX FAST FULL SCAN | PS_EARNINGS_TBL    |    96 |  1248 |     4  (25)| 00:00:01 |
    |* 16 |          INDEX RANGE SCAN         | PS_ERN_PROGRAM_DEF |   643 | 11574 |     2   (0)| 00:00:01 |
    |* 17 |         INDEX UNIQUE SCAN         | PS_EARNINGS_TBL    |     1 |    10 |     0   (0)| 00:00:01 |
    |* 18 |        TABLE ACCESS BY INDEX ROWID| PS_ERN_PROGRAM_TBL |     1 |    11 |     1   (0)| 00:00:01 |
    |* 19 |         INDEX UNIQUE SCAN         | PS_ERN_PROGRAM_TBL |     1 |       |     0   (0)| 00:00:01 |
    |* 20 |     INDEX RANGE SCAN              | PS_EARNINGS_TBL    |     1 |    10 |     1   (0)| 00:00:01 |
    |  21 |      SORT AGGREGATE               |                    |     1 |    10 |            |          |
    |* 22 |       INDEX RANGE SCAN            | PS_EARNINGS_TBL    |     1 |    10 |     2   (0)| 00:00:01 |
    |* 23 |    TABLE ACCESS BY INDEX ROWID    | PS_ERN_PROGRAM_TBL |     1 |    11 |     1   (0)| 00:00:01 |
    |* 24 |     INDEX UNIQUE SCAN             | PS_ERN_PROGRAM_TBL |     1 |       |     0   (0)| 00:00:01 |
    --------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       4 - access("A"."ERN_PROGRAM"='VT' AND "A"."EFFDT"= (SELECT MAX("A"."EFFDT") FROM
                  SYSADM."PS_EARNINGS_TBL" "C",SYSADM."PS_ERN_PROGRAM_TBL" "B",SYSADM."PS_ERN_PROGRAM_DEF" "A",
                  (SELECT MAX(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))) "VW_COL_1","D"."ERNCD" "ERNCD",ROWID
                  "ROWID" FROM SYSADM."PS_EARNINGS_TBL" "D","PS_ERN_PROGRAM_DEF" "A" WHERE
                  "A"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD') AND "A"."ERN_PROGRAM"='VT' AND
                  SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=INTERNAL_FUNCTION("A"."EFFDT") AND
                  SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=TO_DATE(:PPE_DATE,'YYYY-MM-DD') GROUP BY
                  "D"."ERNCD",ROWID) "VW_SQ_1" WHERE "ROWID"=ROWID AND
                  "A"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD') AND "A"."ERN_PROGRAM"='VT' AND
                  "A"."EFFDT"="B"."EFFDT" AND "B"."ERN_PROGRAM"='VT' AND "B"."EFF_STATUS"='A' AND
                  "B"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD') AND
                  SYS_OP_DESCEND("EFFDT")=SYS_OP_DESCEND("VW_COL_1") AND "ERNCD"="C"."ERNCD" AND
                  "C"."ERNCD"="A"."ERNCD" AND SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))="VW_COL_1") AND
                  "A"."ERNCD"=:ERNCD)
       8 - access("ROWID"=ROWID)
      13 - access("A"."ERN_PROGRAM"='VT' AND "A"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD'))
      14 - access(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=INTERNAL_FUNCTION("A"."EFFDT"))
           filter(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=INTERNAL_FUNCTION("A"."EFFDT"))
      15 - filter(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=TO_DATE(:PPE_DATE,'YYYY-MM-DD'))
      16 - access("A"."ERN_PROGRAM"='VT' AND "A"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD'))
      17 - access("ERNCD"="C"."ERNCD" AND SYS_OP_DESCEND("EFFDT")=SYS_OP_DESCEND("VW_COL_1"))
           filter("C"."ERNCD"="A"."ERNCD" AND SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))="VW_COL_1")
      18 - filter("B"."EFF_STATUS"='A')
      19 - access("B"."ERN_PROGRAM"='VT' AND "A"."EFFDT"="B"."EFFDT")
           filter("B"."EFFDT"<=TO_DATE(:PPE_DATE,'YYYY-MM-DD'))
      20 - access("C"."ERNCD"=:ERNCD)
           filter(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))= (SELECT
                  MAX(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))) FROM SYSADM."PS_EARNINGS_TBL" "D" WHERE
                  SYS_OP_DESCEND("EFFDT") IS NOT NULL AND SYS_OP_DESCEND("EFFDT")>=SYS_OP_DESCEND(:B1) AND
                  "D"."ERNCD"=:B2 AND SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=:B3))
      22 - access("D"."ERNCD"=:B1 AND SYS_OP_DESCEND("EFFDT")>=SYS_OP_DESCEND(:B2) AND
                  SYS_OP_DESCEND("EFFDT") IS NOT NULL)
           filter(SYS_OP_UNDESCEND(SYS_OP_DESCEND("EFFDT"))<=:B1)
      23 - filter("B"."EFF_STATUS"='A')
      24 - access("B"."ERN_PROGRAM"='VT' AND "A"."EFFDT"="B"."EFFDT")
    Here's the bad autotrace:
    SQL> variable ppe_date varchar2(10)
    SQL> variable erncd varchar2(3)
    SQL> exec :ppe_date := '2009-10-10'
    SQL> exec :erncd := '01'
    SQL> SELECT COUNT(*)
      2  FROM PS_ERN_PROG_DESCR A
      3  WHERE A.ERN_PROGRAM = 'VT'
      4  AND A.ERNCD         = :erncd
      5  AND EFFDT           =
      6    (SELECT MAX(B.EFFDT)
      7    FROM PS_ERN_PROG_DESCR B
      8    WHERE B.ERN_PROGRAM = 'VT'
      9    AND B.EFFDT        <= TO_DATE(:ppe_date,'YYYY-MM-DD')
     10    );
    
      COUNT(*)
    ----------
             1
    
    Elapsed: 00:04:07.40
    
    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=20 Card=1 Bytes=33)
       1    0   SORT (AGGREGATE)
       2    1     NESTED LOOPS (Cost=3 Card=1 Bytes=33)
       3    2       NESTED LOOPS (Cost=2 Card=1 Bytes=22)
       4    3         INDEX (UNIQUE SCAN) OF 'PS_ERN_PROGRAM_DEF' (INDEX (UNIQUE)) (Cost=1 Card=1 Bytes=12)
       5    4           SORT (AGGREGATE)
       6    5             NESTED LOOPS (Cost=13 Card=1 Bytes=63)
       7    6               NESTED LOOPS (Cost=12 Card=1 Bytes=52)
       8    7                 HASH JOIN (Cost=12 Card=4 Bytes=168)
       9    8                   VIEW OF 'VW_SQ_1' (VIEW) (Cost=9 Card=88 Bytes=2112)
      10    9                     SORT (GROUP BY) (Cost=9 Card=88 Bytes=2728)
      11   10                       MERGE JOIN (Cost=7 Card=3087 Bytes=95697)
      12   11                         SORT (JOIN) (Cost=2 Card=643 Bytes=11574)
      13   12                           INDEX (RANGE SCAN) OF 'PS_ERN_PROGRAM_DEF' (INDEX (UNIQUE)) (Cost=2 Card=643 Bytes=11574)
      14   11                         SORT (JOIN) (Cost=5 Card=96 Bytes=1248)
      15   14                           INDEX (FAST FULL SCAN) OF 'PS_EARNINGS_TBL' (INDEX (UNIQUE)) (Cost=4 Card=96 Bytes=1248)
      16    8                   INDEX (RANGE SCAN) OF 'PS_ERN_PROGRAM_DEF' (INDEX (UNIQUE)) (Cost=2 Card=643 Bytes=11574)
      17    7                 INDEX (UNIQUE SCAN) OF 'PS_EARNINGS_TBL' (INDEX (UNIQUE)) (Cost=0 Card=1 Bytes=10)
      18    6               TABLE ACCESS (BY INDEX ROWID) OF 'PS_ERN_PROGRAM_TBL' (TABLE) (Cost=1 Card=1 Bytes=11)
      19   18                 INDEX (UNIQUE SCAN) OF 'PS_ERN_PROGRAM_TBL' (INDEX (UNIQUE)) (Cost=0 Card=1)
      20    3         INDEX (RANGE SCAN) OF 'PS_EARNINGS_TBL' (INDEX (UNIQUE)) (Cost=1 Card=1 Bytes=10)
      21   20           SORT (AGGREGATE)
      22   21             INDEX (RANGE SCAN) OF 'PS_EARNINGS_TBL' (INDEX (UNIQUE)) (Cost=2 Card=1 Bytes=10)
      23    2       TABLE ACCESS (BY INDEX ROWID) OF 'PS_ERN_PROGRAM_TBL' (TABLE) (Cost=1 Card=1 Bytes=11)
      24   23         INDEX (UNIQUE SCAN) OF 'PS_ERN_PROGRAM_TBL' (INDEX (UNIQUE)) (Cost=0 Card=1)
    
    Statistics
    ----------------------------------------------------------
           3820  recursive calls
             66  db block gets
        4677728  consistent gets
          80608  physical reads
              0  redo size
            232  bytes sent via SQL*Net to client
            278  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              2  sorts (memory)
              1  sorts (disk)
              1  rows processed
    
    SQL> spool off

    I think you have to hit some sort of bug in the optimizer. Do you have the histograms on the EFFDT column.

Maybe you are looking for

  • Satellite A300-24Z - windows does not detect connected sata hdd

    Hello Ago that I bought the new laptop Toshiba Satellite A300. A few days ago, I decided to plug in my old laptop HARD drive - drive is Toshiba MK1234GSX - my new laptop via sata to esata cable. Problem is that windows does not detect a new device, b

  • I pod Touch 4th generation 32 GB

    I have an ipod touch 4th generation 32 GB - the menu button located at the bottom of the unit for some strange reason seems to be stuck and I can't use it. Any suggestions on how it can be solved?

  • Pass the parameter to the functions called from a dll

    Hi all I am interfacing a motor controller for PMC - 100 through the Protocol of Performax using labwindows. I need to explicitly link the PerformaxCom.dll and call functions with him. I'm calling this function BOOL fnPerformaxComOpen (DWORD IN dwDev

  • Windows Update was disabled by your system administrator

    I was playing with a system configuration utility and decided that I didn't like it so I uninstalled. Several days passed before I noticed something wrong. Now my Update window buttons are missing from start / all programs/windows update and Internet

  • monitor goes to black screen on startup.

    My monitor has started to go to the black screen at the "start". However if I it turn on and off several times, it starts to work and then that's fine. I tried to unplug all the power cables and turn on again but the problem persists.