Bug in inline view

Hi,
Here is a reproducible bug I just meet. I tried it on 9.2.0.5 and 10.1.0.2 (AIX).
the "select *" generates duplicates !
Regards
Laurent Schneider
OCM DBA
SQL> select * from ( select distinct deptno from ( select deptno, job, min(sal) from scott.emp group by deptno, job ) where deptno = 20 );
    DEPTNO
        20
        20
        20

No problems on my Windows 10g system
SQL> /
    DEPTNO DNAME           LOC
        10 ACCOUNTING      NEW YORK
        20 RESEARCH        DALLAS
        30 SALES           CHICAGO
        40 OPERATIONS      BOSTON
SQL> select * from emp;
EMPNO ENAME     JOB         MGR HIREDATE          SAL       COMM     DEPTNO
  7369 SMITH     CLERK      7902 17-DEC-80         800                    20
  7499 ALLEN     SALESMAN   7698 20-FEB-81        1600        300         30
  7521 WARD      SALESMAN   7698 22-FEB-81        1250        500         30
  7566 JONES     MANAGER    7839 02-APR-81        2975                    20
  7654 MARTIN    SALESMAN   7698 28-SEP-81        1250       1400         30
  7698 BLAKE     MANAGER    7839 01-MAY-81        2850                    30
  7782 CLARK     MANAGER    7839 09-JUN-81        2450                    10
  7788 SCOTT     ANALYST    7566 19-APR-87        3000                    20
  7839 KING      PRESIDENT       17-NOV-81        5000                    10
  7844 TURNER    SALESMAN   7698 08-SEP-81        1500          0         30
  7876 ADAMS     CLERK      7788 23-MAY-87        1100                    20
EMPNO ENAME     JOB         MGR HIREDATE          SAL       COMM     DEPTNO
  7900 JAMES     CLERK      7698 03-DEC-81         950                    30
  7902 FORD      ANALYST    7566 03-DEC-81        3000                    20
  7934 MILLER    CLERK      7782 23-JAN-82        1300                    10
14 rows selected.
SQL> select * from ( select distinct deptno from ( select deptno, job, min(sal) from scott.emp group
by deptno, job ) where deptno = 20 );
    DEPTNO
        20
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Prod
PL/SQL Release 10.1.0.2.0 - Production
CORE    10.1.0.2.0      Production
TNS for 32-bit Windows: Version 10.1.0.2.0 - Production
NLSRTL Version 10.1.0.2.0 - ProductionJustin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • Oracle BUG (CASE + remote tables + inline view)

    Oracle 9.2.0.8
    BUG: Oracle inserts NULL when we use CASE statement in the SELECT query and we join a remote table with inline view.
    Script:
    CREATE TABLE t1 (a number(19,4)OK.
    SELECT (case when b = 1 then c else d end)
    FROM t2@Remote LEFT JOIN
    (SELECT a FROM t3@Remote) q ON (t2.a = q.a)123
    456
    789
    3 rows selected.
    INSERT INTO TABLE t1 (a)
    SELECT (case when b = 1 then c else d end)
    FROM t2@Remote LEFT JOIN
    (SELECT a FROM t3@Remote) q ON (t2.a = q.a)3 rows inserted.
    SELECT * FROM t1<null>
    <null>
    <null>
    3 rows selected
    Oracle inserts the correct values if I:
    * replace the CASE with DECODE
    * join with table not with an inline view
    * join local tables
    Someone with registration in the Metalink can post the bug.
    Best regards, Beroetz

    Oracle 9.2.0.8
    BUG: Oracle inserts NULL when we use CASE statement in the SELECT query and we join a remote table with inline view.
    Script:
    CREATE TABLE t1 (a number(19,4)OK.
    SELECT (case when b = 1 then c else d end)
    FROM t2@Remote LEFT JOIN
    (SELECT a FROM t3@Remote) q ON (t2.a = q.a)123
    456
    789
    3 rows selected.
    INSERT INTO TABLE t1 (a)
    SELECT (case when b = 1 then c else d end)
    FROM t2@Remote LEFT JOIN
    (SELECT a FROM t3@Remote) q ON (t2.a = q.a)3 rows inserted.
    SELECT * FROM t1<null>
    <null>
    <null>
    3 rows selected
    Oracle inserts the correct values if I:
    * replace the CASE with DECODE
    * join with table not with an inline view
    * join local tables
    Someone with registration in the Metalink can post the bug.
    Best regards, Beroetz

  • [SQL] inline view and order by on oracle 8.0.5

    Hi everyone.
    I am trying to sort data inside "inline view"
    on "Oracle8 Release 8.0.5.0.0 - Production".
    However, it did not work. Is this an oracle-bug?
    I got the oracle error , "ORA-00907".
    The sql script is like this:
    select ..............
    from (select ..... from .. where .... order by ...)
    where rownum <11
    However, the "exactly" same sql has no problem
    on "Oracle8i Enterprise Edition Release 8.1.7.0.0".
    Every response will be greatly appreciated.
    Thanks in advance.
    Ho.

    Order by cannot be used in a subquery while for inline view it is supported but in Oracle8i, release 8.1 and up
    Khurram

  • Query works everywhere but Flex: inline views not supported perhaps?

    EDIT2: Actually not. It turns out to be a bug in the way Adobe is treating any integer PK column, no matter how it is defined, INT, or INTEGER, as an alias for the rowid in SQlite.  This is incorrect. rowid does not always equal the PK value.  This causes joins to return the wrong values.
    EDIT: turns out to be the use of the absolute value function in the query.
    See http://forums.adobe.com/thread/516392
    My bread-and-butter query, the one that is the core of my application, uses a UNION query with inline views when doing proximity word-searches. It works beautifully in SQLite returning a resultset  in about one second from an over 300MB database, against several tables equijoined, the two biggest tables having close to 4 million rows and 300,000 rows, respectively.
    It runs fine in Visual Studio using the .NET provider for SQLite, and also in SQLite Manager 0.5.6 by Mrinal Kant and in other front-ends to SQLite. But the verbatim query returns no rows in Flex and zero rows in the SQLite Admin GUI front-end, which is built on the Flex SQL libraries.
    My first thought is that inline views might not be supported in Flex? 
    Does Flex do what in the Microsoft world is called a "pass-through" query, sending the sql intact through to the back end, or does Flex take the query statement apart and apply the WHERE clause conditions client-side, as Microsoft Access does to support so-called "heterogeneous" joins, i.e. queries that might join tables from, say, SQL Server and Oracle in the same query?

    EDIT2: Actually not. It turns out to be a bug in the way Adobe is treating any integer PK column, no matter how it is defined, INT, or INTEGER, as an alias for the rowid in SQlite.  This is incorrect. rowid does not always equal the PK value.  This causes joins to return the wrong values.
    EDIT: turns out to be the use of the absolute value function in the query.
    See http://forums.adobe.com/thread/516392
    My bread-and-butter query, the one that is the core of my application, uses a UNION query with inline views when doing proximity word-searches. It works beautifully in SQLite returning a resultset  in about one second from an over 300MB database, against several tables equijoined, the two biggest tables having close to 4 million rows and 300,000 rows, respectively.
    It runs fine in Visual Studio using the .NET provider for SQLite, and also in SQLite Manager 0.5.6 by Mrinal Kant and in other front-ends to SQLite. But the verbatim query returns no rows in Flex and zero rows in the SQLite Admin GUI front-end, which is built on the Flex SQL libraries.
    My first thought is that inline views might not be supported in Flex? 
    Does Flex do what in the Microsoft world is called a "pass-through" query, sending the sql intact through to the back end, or does Flex take the query statement apart and apply the WHERE clause conditions client-side, as Microsoft Access does to support so-called "heterogeneous" joins, i.e. queries that might join tables from, say, SQL Server and Oracle in the same query?

  • Inline View

    I am working in very important sector in Canada and using Oracle widely. There is a group of experienced managers and developer who discourage to use inline views. They have some reasons in addition to (may be misleading) information pass on by Oracle. According to them Inline views are �devils work�. It gives wrong results and poor in performance. They also refer an oracle bug, which I believe is a misleading info by Oracle (probably same guy).
    http://metalink.oracle.com/metalink/plsql/showdoc?db=Bug&id=1227266
    I have posted a question against that bug to Oracle (metalink.oracle.com) PL/SQL FORUM. I think Note:118978.1 is right and if we incorporate aliases we will never face problem. I have widely used inline views and never faced wrong results. In my opinion Inline views made life simple and easy. Its performance is excellent and save a lot of time rather to write multiple SQLs, which make the maintenance job difficult. Considering you an authority on Oracle. I want to seek expert opinion about Inline view. Please keep in mind that here we use lot of SQLs just to avoid inline views and some time convert some SQLs into real Views just to get rid of inline view. Your note could help me to convince my manager to allows us to use inline views.
    Regards,
    Amer

    I need comments from other experts using metlinks but some how not getting any response.Because it's pointless. If your managers and colleagues don't trust you why the heck should they listen to a bunch of nobodies like us> You've got Tom Kyte on your side, he's the Oracle VP of database technology, he's the biggest howitzer in the field. If they go up against him they're going to be flattened.
    Unfortunately there is no cure for human stupidity (I speak as a long term sufferer), and in my experience people with entrenched positions are rarely willing to admit that they were wrong. Particularly when any outsider can see that they are obviously wrong.
    As I see it, you have two choices:
    (1) Knuckle down, don't use inline views.
    (2) Be assertive, use inline views. When challenged demand that they both prove that your implementation is buggy and provide an adequate alternative (as performant, as easy to understand, more reliable).
    Be aware that if you take line (2) you must ensure your code is bulletproof: test it rigourously. By forcing them to look at the code, you can undermine their arguments with fact, an ounce of which is worth a ton of opinion.
    Cheers, APC

  • Passing a value to Inline View  WHERE clause through JDev...

    Hi ,
    I need to pass a value to inline view which is mentioned in below VIEW query.
    That view is created inside a view using jDev. Note that there are two WHERE clauses one in the Main query and the other in the Inline view.
    How to set the value for the innerView.
    //copied the code from Java
    view.volAlertsHistroyView.setWhereClauseParam(1, new Integer(clientId));
    Gives an error Missing IN or OUT parameter at index:: 1
    SELECT Alerts.SEND_TIME,
         Alerts.STATUS,
         Alerts.TEXT ,
         Groups.NAME,
              VolRoles.ROLE_NAME,
                   VolRoles.ID as vid,
                   Groups.ID as gid
         FROM ALERTS Alerts, ALERTS_GROUPS AlertsGroups, GROUPS Groups, VOL_ROLES VolRoles,
    --Inline view starts
    (SELECT GRP_ID, VRL_ID FROM vol_groups WHERE cli_id = :1) user_group_role
    --Inline view ends
    --Actual WHERE clause starts
         WHERE ((Alerts.ID = AlertsGroups.ALT_ID)AND (AlertsGroups.GRP_ID = Groups.ID))AND (AlertsGroups.VRL_ID = VolRoles.ID)
         AND AlertsGroups.VRL_ID = user_group_role.VRL_ID AND AlertsGroups.GRP_ID = user_group_role.GRP_ID
    Please get back to me .
    Regards
    Mohan
    [email protected]

    What happens when you change your Java code to:
    view.volAlertsHistroyView.setWhereClauseParam(0, new Integer(clientId));
    The ":1" does not directly relate to the where clause param index you use in Java. In your query you could also use a ":2" for example. In BC4J you still use "0" for the first param.
    Sascha

  • Does an inline view execute before the rest of the select?

    Hi,
    The O'Reilly book Mastering Oracle Sql defines an inline view simply as a
    subquery in a select FROM clause. This conforms to the definitions in
    the Oracle 9i and 10g docs.
    But unlike the Oracle docs, the O'Reilly book says the inline view is,
    like a WITH clause, executed before the rest of the query. I can't see
    how this can be done unless the inline view makes no reference to
    other tables joined in the FROM clause.
    Is there a species of inline view in 9i/10g that IS restricted as above -
    no refs to other tables in the FROM clause - and what is it called?
    Thanks for any help.
    Ken Quirici

    As explained above, Oracle can choose to merge the query if feasible to do so. Look at the two queries and their plans below. The plan in second query changes to creating a temporary VIEW since in that case, Oracle is unable to perform the merge:
    SQL> select *
      2          from scott.emp e,
      3                  (select * from scott.dept d where d.deptno = 10) dd
      4  where
      5          e.deptno = dd.deptno
      6  /
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO     DEPTNO DNAME          LOC
          7782 CLARK      MANAGER         7839 09-JUN-1981       2450                    10         10 ACCOUNTING     NEW YORK
          7839 KING       PRESIDENT            17-NOV-1981       5000                    10         10 ACCOUNTING     NEW YORK
          7934 MILLER     CLERK           7782 23-JAN-1982       1300                    10         10 ACCOUNTING     NEW YORK
    3 rows selected.
    Execution Plan
    Plan hash value: 3570059291
    | Id  | Operation                    | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                |     3 |   171 |     2   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS                |                |     3 |   171 |     2   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS BY INDEX ROWID| DEPT           |     1 |    20 |     1   (0)| 00:00:01 |
    |*  3 |    INDEX UNIQUE SCAN         | PK_DEPT        |     1 |       |     0   (0)| 00:00:01 |
    |   4 |   TABLE ACCESS BY INDEX ROWID| EMP            |     3 |   111 |     1   (0)| 00:00:01 |
    |*  5 |    INDEX RANGE SCAN          | IDX_EMP_DEPTNO |     3 |       |     0   (0)| 00:00:01 |
    SQL> select *
      2          from scott.emp e,
      3                  (select * from scott.dept d where d.deptno = 10 and rownum > 0) dd
      4  where
      5          e.deptno = dd.deptno
      6  /
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO     DEPTNO DNAME          LOC
          7782 CLARK      MANAGER         7839 09-JUN-1981       2450                    10         10 ACCOUNTING     NEW YORK
          7839 KING       PRESIDENT            17-NOV-1981       5000                    10         10 ACCOUNTING     NEW YORK
          7934 MILLER     CLERK           7782 23-JAN-1982       1300                    10         10 ACCOUNTING     NEW YORK
    3 rows selected.
    Execution Plan
    Plan hash value: 1670713873
    | Id  | Operation                       | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                |                |     5 |   280 |     2   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS                   |                |     5 |   280 |     2   (0)| 00:00:01 |
    |   2 |   VIEW                          |                |     1 |    19 |     1   (0)| 00:00:01 |
    |   3 |    COUNT                        |                |       |       |            |          |
    |*  4 |     FILTER                      |                |       |       |            |          |
    |   5 |      TABLE ACCESS BY INDEX ROWID| DEPT           |     1 |    20 |     1   (0)| 00:00:01 |
    |*  6 |       INDEX UNIQUE SCAN         | PK_DEPT        |     1 |       |     0   (0)| 00:00:01 |
    |   7 |   TABLE ACCESS BY INDEX ROWID   | EMP            |     5 |   185 |     1   (0)| 00:00:01 |
    |*  8 |    INDEX RANGE SCAN             | IDX_EMP_DEPTNO |     5 |       |     0   (0)| 00:00:01 |
    SQL> disconnect
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL>
    can it, in it's WHERE clause, reference other tables in the FROM clause?No. it cannot. but as said above, tha may not stop Oracle from merging the queries.
    SQL> select *
      2          from scott.emp e,
      3                  (select * from scott.dept d where d.deptno = 10 and e.sal > 1000) dd
      4  where
      5          e.deptno = dd.deptno
      6  /
                    (select * from scott.dept d where d.deptno = 10 and e.sal > 1000) dd
    ERROR at line 3:
    ORA-00904: "E"."SAL": invalid identifier
    SQL>

  • Disable inline viewing of attachments in Mavericks mail

    Dear all
    In previous version of the OS, there was an easy terminal fix to disable inline viewing of attachments in mail. Instead of bulky and cumbersome images and PDFs, I used to get nice, neat icons.
    This terminal fix doesn't seem to work in Mavericks.
    Online sources tell me to buy a separate app called Attachment Tamer to fix this.
    Just wanted to find out whether there is a way to do this without additional software.
    Thanks in advance
    Best regards
    Zam

    Sorry, that page is a description of the basic functionality that is supposed to work in Mavericks, but is entirely failing to work for me. I tried calling Apple Support on the phone, and went through many attempted fixes with the experts, but they eventually threw up their hands in despair.

  • Issue with Inline View Criteria

    Hi,
    I have a VO created on two tables that are joined by a 1:1 association(say Opportunity and Revenue). The query is specified in Expert mode because I need some aggregations performed using analytic functions. Data security predicates are applied on top of this query using a dummy View Criteria. My requirement now is that I need to filter these results using another VC. The issue is that both the tables have attributes with the same name(say Cust ID) and I need to filter based on this using an inline View Criteria. I have done the same declaratively. However, I get an error on hitting the page saying the columns have been ambiguously defined.
    On digging through the log, I discovered the test Query fails to prefix the alias before the attribute. So what I get is something similar to this
    select (o.id, r.amt, sum(), count(), avg(), o.custId) from opty o, revn r where (o.id in DATA SECURITY PREDICATE) and (custId = :bindCustId)
    Is there a way to ensure that the custId can be changed to o.custId???
    Note - The View Criteria was created on an attribute from opty table that was exposed i.e in this case, o.custId. Although the query builder shows it correctly while creating the VC declaratively, the issue persists as seen from the logs.
    Thanks,
    Manoj

    Hi experts...
    Any pointers to this issue???
    Please help!
    Regards,
    Debolina

  • [sql performance] inline view , group by , max, join

    Hi. everyone.
    I have a question with regard to "group by" inline view ,
    max value, join, and sql performance.
    I will give you simple table definitions in order for you
    to understand my intention.
    Table A (parent)
    C1
    C2
    C3
    Table B (child)
    C1
    C2
    C3
    C4 number type(sequence number)
    1. c1, c2, c3 are the key columns of tabla A.
    2. c1, c2, c3, c4 are the key columns of table B.
    3. table A is the parent table of Table B.
    4. c4 column of table b is the serial number.
    (c4 increases from 1 by "1" regarding every (c1,c2,c3)
    the following is the simple example of the sql query.
    select .................................
    from table_a,
    (select c1, c2, c3, max(c4)
    from table_b
    group by c1, c2, c3) table_c
    where table_a.c1 = table_c.c1
    and table_a.c2 = table_c.c2
    and table_a.c3 = table_c.c3
    The real query is not simple as above. More tables come
    after "the from clause".
    Table A and table B are big tables, which have more than
    100,000,000 rows.
    The response time of this sql is very very slow
    as everyone can expect.
    Are there any solutions or sql-tips about the late response-time?
    I am considering adding a new column into "Table B" in
    order to identify the row, which has max serial number.
    At this point, I am not sure adding a column is a good
    thing in terms of every aspect.
    I will be waiting for your advice and every response
    will be appreciated even if it is not the solution.
    Have a good day.
    HO.
    Message was edited by:
    user507290

    For such big sources check that
    1) you use full scans, hash joins or at least merge joins
    2) you scan your source data as less as possible. In the best case each necessary table only once (for example not using exists clause to effectively scan all table via index scan).
    3) how much time you are spending on sorts and hash joins (either from v$session_longops directly or some tool that visualises this info). If you are using workarea_size_policy = auto, probably you can switch to manual for this particular select and adjust sort_area_size and hash_area_size big enough to do as less as possible sorts on disk
    4) if you have enough free resources i.e. big box probably you can consider using some parallelism
    5) if your full scans are taking big time check what is your db_file_multiblock_read_count, probably increasing it for this select will give some gain.
    6) run trace and check on what are you waiting for
    7) most probably your problem is IO bound so probably you can do something from OS side to make IO faster
    8) if your query now is optimized as much as you can, disks are running as mad and you are using all RAM then probably it is the most you can get out of your box :)
    9) if nothing helps then you can start thinking about precalculations either using your idea about derived column or some materialized views.
    10) I hope you have a test box and at least point (9) do firstly on it and see whether it helps.
    Gints Plivna
    http://www.gplivna.eu

  • Tuning query with inline views

    Hi!
    I have a performance problem with the following query. I try to combine v1 and v2 into one inline view but because of the recursive design of the tables workflow and workflow_node it didn't work.
    Does anybody has an idea for tuning this query?
    SELECT distinct v1.u_protocol_id
       FROM ( SELECT workflow_node.workflow_id,u_protocol.u_protocol_id
                   FROM workflow_node,workflow,U_protocol
                   WHERE workflow.workflow_id=workflow_node.workflow_id
                     AND u_protocol.u_protocol_id = workflow_node.parameter_2
                  AND workflow_node.workflow_node_type_id=17
                  AND workflow.workflow_node_type_id=42
             ) v1,
             ( SELECT workflow_node.workflow_id,test_template.test_template_id
               FROM workflow_node,test_template
               WHERE test_template.test_template_id = workflow_node.template
                 AND workflow_node.order_number = 1
                 AND workflow_node.workflow_node_type_id=42
             ) v2,
             ( SELECT aliquot.aliquot_id,test_template.test_template_id
               FROM aliquot,test,test_template
               WHERE aliquot.aliquot_id = test.aliquot_id
                 AND test.test_template_id = test_template.test_template_id
             ) v3
       WHERE v1.workflow_id = v2.workflow_id
         AND v2.test_template_id= v3.test_template_id

    I have found a script (utlxplan.sql) for creating the plan_table so here it is
    SQL> @c:\utlxplan.sql;
    Table created.
    SQL> EXPLAIN PLAN FOR SELECT distinct v1.u_protocol_id
      2     FROM ( SELECT workflow_node.workflow_id,u_protocol.u_protocol_id
      3         FROM lims_sys.workflow_node,lims_sys.workflow,lims_sys.U_protocol
      4         WHERE workflow.workflow_id=workflow_node.workflow_id
      5           AND u_protocol.u_protocol_id = workflow_node.parameter_2
      6        AND workflow_node.workflow_node_type_id=17
      7        AND workflow.workflow_node_type_id=42
      8       ) v1,
      9       ( SELECT workflow_node.workflow_id,test_template.test_template_id
    10         FROM lims_sys.aliquot,lims_sys.test,lims_sys.workflow_node,lims_sys.test_template
    11         WHERE aliquot.aliquot_id = test.aliquot_id
    12           AND test.test_template_id = test_template.test_template_id
    13     AND test_template.test_template_id = workflow_node.template
    14       ) v2
    15     WHERE v1.workflow_id = v2.workflow_id
    16  /
    Explained.
    SQL> SELECT * FROM TABLE(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id  | Operation                           |  Name                           |
    Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT                    |                                 |
    PLAN_TABLE_OUTPUT
          |       |       |
    |   1 |  SORT UNIQUE                        |                                 |
          |       |       |
    |   2 |   FILTER                            |                                 |
          |       |       |
    |   3 |    NESTED LOOPS                     |                                 |
          |       |       |
    PLAN_TABLE_OUTPUT
    |   4 |     NESTED LOOPS                    |                                 |
          |       |       |
    |   5 |      NESTED LOOPS                   |                                 |
          |       |       |
    |   6 |       NESTED LOOPS                  |                                 |
          |       |       |
    |   7 |        NESTED LOOPS                 |                                 |
          |       |       |
    PLAN_TABLE_OUTPUT
    |   8 |         NESTED LOOPS                |                                 |
          |       |       |
    |   9 |          TABLE ACCESS BY INDEX ROWID| WORKFLOW                        |
          |       |       |
    |* 10 |           INDEX RANGE SCAN          | FK_WORKFLOW_WORKFLOW_NODE_TYPE  |
          |       |       |
    |  11 |          TABLE ACCESS BY INDEX ROWID| WORKFLOW_NODE                   |
    PLAN_TABLE_OUTPUT
          |       |       |
    |  12 |           AND-EQUAL                 |                                 |
          |       |       |
    |* 13 |            INDEX RANGE SCAN         | FK_WORKFLOW_NODE_WORKFLOW       |
          |       |       |
    |* 14 |            INDEX RANGE SCAN         | FK_WORKFLOW_NODE_NODE_TYPE      |
          |       |       |
    PLAN_TABLE_OUTPUT
    |  15 |         TABLE ACCESS BY INDEX ROWID | U_PROTOCOL                      |
          |       |       |
    |* 16 |          INDEX UNIQUE SCAN          | PK_U_PROTOCOL                   |
          |       |       |
    |  17 |        TABLE ACCESS BY INDEX ROWID  | WORKFLOW_NODE                   |
          |       |       |
    |* 18 |         INDEX RANGE SCAN            | FK_WORKFLOW_NODE_WORKFLOW       |
          |       |       |
    PLAN_TABLE_OUTPUT
    |  19 |       TABLE ACCESS BY INDEX ROWID   | TEST_TEMPLATE                   |
          |       |       |
    |* 20 |        INDEX UNIQUE SCAN            | PK_TEST_TEMPLATE                |
          |       |       |
    |  21 |      TABLE ACCESS BY INDEX ROWID    | TEST                            |
          |       |       |
    |* 22 |       INDEX RANGE SCAN              | FK_TEST_TEST_TEMPLATE           |
    PLAN_TABLE_OUTPUT
          |       |       |
    |  23 |     TABLE ACCESS BY INDEX ROWID     | ALIQUOT                         |
          |       |       |
    |* 24 |      INDEX UNIQUE SCAN              | PK_ALIQUOT                      |
          |       |       |
    |  25 |    INDEX UNIQUE SCAN                | PK_OPERATOR_GROUP               |
          |       |       |
    PLAN_TABLE_OUTPUT
    |  26 |    INDEX UNIQUE SCAN                | PK_OPERATOR_GROUP               |
          |       |       |
    |  27 |    INDEX UNIQUE SCAN                | PK_OPERATOR_GROUP               |
          |       |       |
    |  28 |    INDEX UNIQUE SCAN                | PK_OPERATOR_GROUP               |
          |       |       |
    |  29 |    INDEX UNIQUE SCAN                | PK_OPERATOR_GROUP               |
          |       |       |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
      10 - access("SYS_ALIAS_5"."WORKFLOW_NODE_TYPE_ID"=42)
      13 - access("SYS_ALIAS_5"."WORKFLOW_ID"="WORKFLOW_NODE"."WORKFLOW_ID")
      14 - access("WORKFLOW_NODE"."WORKFLOW_NODE_TYPE_ID"=17)
    PLAN_TABLE_OUTPUT
      16 - access("SYS_ALIAS_4"."U_PROTOCOL_ID"=TO_NUMBER("WORKFLOW_NODE"."PARAMETER
    _2"))
      18 - access("WORKFLOW_NODE"."WORKFLOW_ID"="WORKFLOW_NODE"."WORKFLOW_ID")
      20 - access("SYS_ALIAS_1"."TEST_TEMPLATE_ID"="WORKFLOW_NODE"."TEMPLATE")
      22 - access("SYS_ALIAS_2"."TEST_TEMPLATE_ID"="SYS_ALIAS_1"."TEST_TEMPLATE_ID")
      24 - access("SYS_ALIAS_3"."ALIQUOT_ID"="SYS_ALIAS_2"."ALIQUOT_ID")
    Note: rule based optimization

  • Can You Explain This SQL Query - Inline View Included

    The query is taken from "Oracle Database 10g: SQL Fundamentals II" page 3-7 (chapter 3)
    I do not fully understand the following query:
    SELECT a.last_name, a.salary, a.department_id, b.salavg
    FROM   employees a, (SELECT   department_id,
    AVG(salary) salavg
    FROM     employees
    GROUP BY department_id) b
    WHERE  a.department_id = b.department_id
    AND    a.salary > b.salavg;
    The inline view can return several records. Can you please tell me in step by step how does this work. I understand the concept of join tables and aliases, etc. I just need to know the mechanism of this code.
    Thanks

    user11164565 wrote:
    The query is taken from "Oracle Database 10g: SQL Fundamentals II" page 3-7 (chapter 3)
    I do not fully understand the following query:
    SELECT a.last_name, a.salary, a.department_id, b.salavg
    FROM   employees a, (SELECT   department_id,
    AVG(salary) salavg
    FROM     employees
    GROUP BY department_id) b
    WHERE  a.department_id = b.department_id
    AND    a.salary > b.salavg;
    The inline view can return several records. Can you please tell me in step by step how does this work. I understand the concept of join tables and aliases, etc. I just need to know the mechanism of this code.
    The query is returning the last name, salary , department and average salary of all the departments where salary is greater than the average salary.
    HTH
    Aman....

  • Using inline view with NOT IN clause

    I have a query with a NOT IN clause in the where clause that I would like to convert to an inline view. The select looks something like this:
    select uid, SYSDATE from tab1, tab2
    where tab1.uid = tab2.uid
    and ...
    and tab1.uid not in (select uid from tab3 where....)
    I've used inline queries elsewhere to great effect, but this one has me stumped. If anyone can help, it would be greatly appreciated.

    There can be problem with using not in or not exists depending on the amount of data in the tables and the relationship between them.
    I didn't got if you had problem with the existing SQL-statement, created view or both.
    Check statistics and look at explain plan for the sql-statement and the view.
    The problem can actually be some where clause that you have in the sql-statement but not in the view, but apply later when using the view.
    //Anders

  • Need help with SQL Query with Inline View + Group by

    Hello Gurus,
    I would really appreciate your time and effort regarding this query. I have the following data set.
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
    1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
    Please Ignore '----', added it for clarity
    I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
    The query should return the following data set
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
    The following is my query. I am kind of lost.
    select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    from (
    select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
    from INVOICE
    group by sequence_id,check_date, check_number, invoice_number, vendor_number
    ) A, INVOICE B
    where A.sequence_id = B.sequence_id
    Thanks,
    Nick

    It looks like it is a duplicate thread - correct me if i'm wrong in this case ->
    Need help with SQL Query with Inline View + Group by
    Regards.
    Satyaki De.

  • Problem while using inline view.

    hello everyone, i have a certain problem. i have a query where i have used 3 inline views.which is as follow.
    SELECT X.MC_ID,
    X.PROD,X.EFF,Y.PROD,Y.EFF,Z.PROD,Z.EFF
    FROM
    (SELECT A.MC_ID MC_ID,A.COARSE_FINE,DECODE(A.COARSE_FINE,'F',NVL(A.PRODUCTION,0),0) PROD,
    DECODE(A.COARSE_FINE,'F',(NVL(A.PRODUCTION,0)/NVL(A.FINE_TARGET_PROD,0))* 100,0) EFF
    FROM PR_DAILY_DOFFING_ENTRY A
    WHERE A.SHIFT = 'A'
    AND MC_ID = 24
    AND TO_CHAR(A.DOFFING_DATE,'DD/MM/RRRR') = '28/10/2004') X,
    (SELECT A.MC_ID,A.COARSE_FINE,DECODE(A.COARSE_FINE,'F',NVL(A.PRODUCTION,0),0) PROD,
    DECODE(A.COARSE_FINE,'F',(NVL(A.PRODUCTION,0)/NVL(A.FINE_TARGET_PROD,0))* 100,0) EFF
    FROM PR_DAILY_DOFFING_ENTRY A
    WHERE A.SHIFT = 'B'
    AND MC_ID = 24
    AND TO_CHAR(A.DOFFING_DATE,'DD/MM/RRRR') = '28/10/2004') Y,
    (SELECT A.MC_ID,A.COARSE_FINE,DECODE(A.COARSE_FINE,'F',NVL(A.PRODUCTION,' '),' ') PROD,
    DECODE(A.COARSE_FINE,'F',(NVL(A.PRODUCTION,' ')/NVL(A.FINE_TARGET_PROD,' '))* 100,' ') EFF
    FROM PR_DAILY_DOFFING_ENTRY A
    WHERE A.SHIFT = 'C'
    AND MC_ID = 24
    AND TO_CHAR(A.DOFFING_DATE,'DD/MM/RRRR') = '28/10/2004') Z
    Now my problem is that the view z is returning null as results in the prod and eff coloums.( well that is fine since i actually have no datas in my table against shift 'C') but inline views x and y are returning datas. but when i am selecting this -- SELECT X.MC_ID,
    X.PROD,X.EFF,Y.PROD,Y.EFF,Z.PROD,Z.EFF nothing is being returned as all the coloums are showing null values. when it should show values in (X.PROD,X.EFF,Y.PROD,Y.EFF) coloumns and null in (Z.PROD,Z.EFF) coloumns. please suggest me what to do now.
    Edited by: pari kankaria on Aug 23, 2009 11:02 PM

    is this your complete query? I guess you are missing the joining conditions if this is your complete query.
    it should be like this
    SELECT x.mc_id, x.prod, x.eff, y.prod, y.eff, z.prod, z.eff
      FROM (SELECT a.mc_id mc_id, a.coarse_fine,
                   DECODE (a.coarse_fine, 'F', NVL (a.production, 0), 0) prod,
                   DECODE (a.coarse_fine,
                           'F', (  NVL (a.production, 0)
                                 / NVL (a.fine_target_prod, 0)
                            * 100,
                           0
                          ) eff
              FROM pr_daily_doffing_entry a
             WHERE a.shift = 'A'
               AND mc_id = 24
               AND TO_CHAR (a.doffing_date, 'DD/MM/RRRR') = '28/10/2004') x,
           (SELECT a.mc_id, a.coarse_fine,
                   DECODE (a.coarse_fine, 'F', NVL (a.production, 0), 0) prod,
                   DECODE (a.coarse_fine,
                           'F', (  NVL (a.production, 0)
                                 / NVL (a.fine_target_prod, 0)
                            * 100,
                           0
                          ) eff
              FROM pr_daily_doffing_entry a
             WHERE a.shift = 'B'
               AND mc_id = 24
               AND TO_CHAR (a.doffing_date, 'DD/MM/RRRR') = '28/10/2004') y,
           (SELECT a.mc_id, a.coarse_fine,
                   DECODE (a.coarse_fine,
                           'F', NVL (a.production, ' '),
                          ) prod,
                   DECODE (a.coarse_fine,
                           'F', (  NVL (a.production, ' ')
                                 / NVL (a.fine_target_prod, ' ')
                            * 100,
                          ) eff
              FROM pr_daily_doffing_entry a
             WHERE a.shift = 'C'
               AND mc_id = 24
               AND TO_CHAR (a.doffing_date, 'DD/MM/RRRR') = '28/10/2004') z
    WHERE x.mc_id = y.mc_id AND y.mc_id = z.mc_id     ----something like this should be there change it according to your conditionNOTE : NOT TESTED
    Edited by: Qwerty on Aug 24, 2009 11:46 AM

Maybe you are looking for

  • Acrobat 9 Pro: Open all documents in same window - don't want!!

    In Acrobat 7 there was a setting under Edit/Preferences/Documents that said "Show each document in its own window" I had this unchecked. I can't find this setting in 9, there is no such option (at least what I can find). I don't want all documents in

  • Total in graphs

    Hello every one, I have a query in WAD and Im doing a graph based on the query, the problem is that the users want the graph to show the values based on percentage, and I did that, bue they also want the result to show at top of the graph, the proble

  • How to remove From My Mac calendar

    I have calendars on my iPhone that I do not want, and they are listed under "From my Mac"  I cannot find how to delete them. Any suggestions?

  • Error in Query Activation from Business Content

    Hi Gurus, I'm having problems when I'm activating Query 0FIGL_VC1_Q0001 (Financial Statement and P&L: Actual/Actual Comparison) under Virtual Cube (0FIGL_VC1). Everytime I activate it, it displays these errors 1. Error when activating element 2GXNYXW

  • [Solved]Grow an XFS partition

    I have /dev/system/home which has been enlarged by 20GB to 60GB, the XFS partition on it is 40GB in size. When I view the help section I don't know what option to use: [root@JORDAN-CD3CDA3B jordanwb]# xfs_growfs --help Usage: xfs_growfs [options] mou