[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

Similar Messages

  • Difference between inline view and WITH

    All,
    What is the difference between an inline view and a query using 'with' keyword...? (scenario / example will be more helpful)

    Thank-you ajay. below section was really helpful, in the above link.
    big_table@ORA920> set echo on
    big_table@ORA920> set autotrace on statistics
    big_table@ORA920>
    big_table@ORA920> with owners
    2 as
    3 ( select distinct owner username from all_objects )
    4 select count(*)
    5 from all_objects, owners
    6 where all_objects.owner = owners.username
    7 union all
    8 select count(*)
    9 from dba_objects, owners
    10 where dba_objects.owner = owners.username
    11 /
    COUNT(*)
    30537
    30977
    2 rows selected.
    Statistics
    4 recursive calls
    7 db block gets
    302441 consistent gets
    1 physical reads
    520 redo size
    418 bytes sent via SQL*Net to client
    499 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    3 sorts (memory)
    0 sorts (disk)
    2 rows processed
    big_table@ORA920>
    big_table@ORA920> select count(*)
    2 from all_objects, (select distinct owner username from all_objects ) owners
    3 where all_objects.owner = owners.username
    4 union all
    5 select count(*)
    6 from dba_objects, (select distinct owner username from all_objects ) owners
    7 where dba_objects.owner = owners.username
    8 /
    COUNT(*)
    30537
    30977
    2 rows selected.
    Statistics
    28 recursive calls
    0 db block gets
    442058 consistent gets
    0 physical reads
    0 redo size
    418 bytes sent via SQL*Net to client
    499 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    4 sorts (memory)
    0 sorts (disk)
    2 rows processed
    big_table@ORA920> set autotrace off
    Edited by: sikander on Sep 9, 2010 12:39 AM
    Edited by: sikander on Sep 9, 2010 12:40 AM

  • Difference between INLINE view and WITH clause

    Can anyone plz explain me about the performance difference between the below queries?
    Query using INLINE view:
    SELECT e.ename AS employee_name,
    dc.dept_count AS emp_dept_count
    FROM emp e,
    (SELECT deptno, COUNT(*) AS dept_count
    FROM emp
    GROUP BY deptno) dc
    WHERE e.deptno = dc.deptno;
    Query using WITH clause:
    WITH dept_count AS (
    SELECT deptno, COUNT(*) AS dept_count
    FROM emp
    GROUP BY deptno)
    SELECT e.ename AS employee_name,
    dc.dept_count AS emp_dept_count
    FROM emp e,
    dept_count dc
    WHERE e.deptno = dc.deptno;

    Here's another one:
    http://www.oracle-base.com/articles/misc/WithClause.php
    And, here on this forum you will see that the WITH-clause is heavily used by all of us in order to generate some sample data (when OP's don't care to post CREATE TABLE + INSERT INTO statements).
    The WITH clause enables you as well to 'pretend' you have a table and demonstrate a solution very quickly, without doing actual DDL .
    As for the performance difference:
    We would need to know your database version and many other things.
    See:
    HOW TO: Post a SQL statement tuning request - template posting
    for step by step instructions you can (and should) explore yourself.

  • Materialized view and Order by clause

    Hi all. I'd like to have some information regarding the order by clause used in a materialized view.
    I'm using Oracle 9.2 and Win2003 server. I have a common view (my_common_view) on which a materialized view is based (my_materialized_view). Materialized view is built for fast refresh and is created in this way:
    create materialized view my_materialized_view as
    select * from my_common_view
    order by 1,2,3;
    My question is: if I query this materialized view without adding an order by clause in the statement, I will obtain always an ordered result set? So, is it useful to include the order by clause in the materialized view script or the order by has to be include in the statement used for quering the materialized view (for example like this: select * from my_materialized view order by ...)?
    Thank you very much.
    Ste.

    SQL> create table t
      2  (x int)
      3  /
    Table created.
    SQL> create view vw
      2  as
      3  select *
      4    from t
      5   order by x
      6  /
    View created.
    SQL> select *
      2    from v$version
      3  /
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    PL/SQL Release 9.2.0.7.0 - Production
    CORE    9.2.0.7.0       Production
    TNS for IBM/AIX RISC System/6000: Version 9.2.0.7.0 - Production
    NLSRTL Version 9.2.0.7.0 - Production
    SQL>

  • Inline views and parallelism

    On Oracle 11.2, our application uses a "lot" of inline views.
    Not knowing much about the benefits or advantages to using inline views, I wondered a few things about the use of them.
    First, When I look in OEM, SQL Monitoring, I noticed that queries on inline views that have tables with parallelism set, the queries on inline views do not appear to be using parallelism on the inner query. Or, perhaps they are, but I'm not able to see that they are. How can I tell if they are?
    If they are not, would it be necessary to use a hint to use parallelism?
    So what are the advantages of using inline views?
    I would assume they would use more PGA and/or temp tablespace, but that doesn't seem to be the case in our database (or at least it is not causing any impact that I can tell).

    974632 wrote:
    So what are the advantages of using inline views?
    I would assume they would use more PGA and/or temp tablespace, but that doesn't seem to be the case in our database (or at least it is not causing any impact that I can tell).A critical point is whether the inline view can be merged into the calling query. As a general rule, if the view can be merged then the query will be more efficient than if it cannot be. A non-mergeable view has to be instantiated as a memory structure before the calling query can run against it. consider these examples:orcl>
    orcl> set autot on exp
    orcl> select count(ename) from (select ename from emp);
    COUNT(ENAME)
              14
    Execution Plan
    Plan hash value: 2083865914
    | Id  | Operation                  | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT           |      |     1 |     6 |     4   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE            |      |     1 |     6 |            |          |
    |   2 |   TABLE ACCESS STORAGE FULL| EMP  |    14 |    84 |     4   (0)| 00:00:01 |
    orcl> select count(ename) from (select distinct ename from emp);
    COUNT(ENAME)
              14
    Execution Plan
    Plan hash value: 1851925981
    | Id  | Operation                    | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |      |     1 |     7 |     5  (20)| 00:00:01 |
    |   1 |  SORT AGGREGATE              |      |     1 |     7 |            |          |
    |   2 |   VIEW                       |      |    14 |    98 |     5  (20)| 00:00:01 |
    |   3 |    HASH UNIQUE               |      |    14 |    84 |     5  (20)| 00:00:01 |
    |   4 |     TABLE ACCESS STORAGE FULL| EMP  |    14 |    84 |     4   (0)| 00:00:01 |
    orcl>The first query was merged, the second was not: the DISTINCT makes merging impossible, because Oracle cannot be certain that there are no duplicate names. But if I add a unique and not null constraints:orcl> alter table emp add constraint ename_uk unique(ename);
    Table altered.
    orcl> alter table emp modify ename not null;
    Table altered.
    orcl>  select count(ename) from (select distinct ename from emp);
    COUNT(ENAME)
              14
    Execution Plan
    Plan hash value: 1457629042
    | Id  | Operation        | Name     | Rows  | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT |          |     1 |     1   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE  |          |     1 |            |          |
    |   2 |   INDEX FULL SCAN| ENAME_UK |    14 |     1   (0)| 00:00:01 |
    orcl>now the inline view is merged (and happens to use the index). This trivial example illustrates how important it is to know and understand your data. If there are no duplicates or no nulls, tell Oracle this. And one of my pet hates: lazy programmers who use aggregations or distinct because they don't know if there are duplicates, and so don't bother to handle them properly.
    John Watson
    Oracle Certified Master DBA
    http://skillbuilders.com

  • View and order by

    Hi,
    I am working on oracle 10G.
    i've read that we can't use order by clause with a view query.
    but in 10G i am able to do this.
    please tell me its oracle 10g's new feature or i have a misconception ?
    thanks

    SQL> create table t
      2  (x int)
      3  /
    Table created.
    SQL> create view vw
      2  as
      3  select *
      4    from t
      5   order by x
      6  /
    View created.
    SQL> select *
      2    from v$version
      3  /
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    PL/SQL Release 9.2.0.7.0 - Production
    CORE    9.2.0.7.0       Production
    TNS for IBM/AIX RISC System/6000: Version 9.2.0.7.0 - Production
    NLSRTL Version 9.2.0.7.0 - Production
    SQL>

  • Issue with materialized view and fast refresh between Oracle 10g and 11g

    Hi all,
    I've hit a problem when trying to create a fast-refreshable materialized view.
    I've got two databases, one 10.2.0.10, another 11.2.0.1.0, running on 32-bit Windows. Both are enterprise edition, and I'm trying to pull data from the 10g one into the 11g one. I can happily query across the database link from 11g to 10g, and can use complete refresh with no problem except the time it takes.
    On the 10g side, I've got tables with primary keys and m.v. logs created, the logs being of this form ...
    CREATE MATERIALIZED VIEW LOG ON table WITH PRIMARY KEY INCLUDING NEW VALUES
    On the 11g side, when I try to create an m.v. against that ...
    CREATE MATERIALIZED VIEW mv_table REFRESH FAST WITH PRIMARY KEY AS SELECT col1, col2 FROM table@dblink;
    ... I get an ORA-12028 error (materialized view type is not supported by master site).
    After running the EXPLAIN_MVIEW procedure it shows this;
    REFRESH_FAST_AFTER_INSERT not supported for this type mv by Oracle version at master site
    A colleague has managed to build a fast-refresh m.v. from the same source database, but pulling to a different one than I'm using; his target is also 10g, like the (common) source, so I've no idea why I'm getting the 'not supported' message whilst he isn't.
    I've been able, on previous projects, to do exactly what I'm trying to achieve but on those someone with more knowledge than me has configured the database!
    I'm now stumped. I'm also no DBA but despite that it's been left to me to install the new 11g database on the 32-bit Windows server from scratch, so there are probably a couple of things I'm missing. It's probably something really obvious but I don't really know where to look now.
    If anyone can give me any pointers at all, I'd be really grateful. This question is also duplicated in the Replication forum but hasn't had any replies as yet, so I'm reproducing it here in hope!
    Thanks in advance,
    Steve

    Hi Steve,
    You should have a look at metalink, Doc ID 1059547.1
    If that does not help, there may be something else in Mater note ID 1353040.1
    Best regards
    Peter

  • Microsoft SQL Server DB and Utilities VS. Oracle and Utilities

    I have a pretty extensive background in Microsoft SQL Server and have just started a consulting gig at an Oracle client site. We actually had a meeting this morning regarding some reporting and I know what the solution would be for Microsoft SQL Server and am just wondering what might exists that is similar on the Oracle platform.
    Is Data Replication possible in Oracle??? I know in a previous Microsoft SQL Server site, we used to have database replication for a reporting server that we maintained. Just wondering if something is similar to that on the Oracle platform. 9i I believe.
    Also, Does the Oracle platform have a product similar to Microsoft SQL Server Reporting Services???
    Thanks for your time to reveiw and Thanks in advance for any replies.
    PSULionRP

    Hello,
    Here is official link to Oracle 9i Docs
    http://www.oracle.com/technology/documentation/oracle9i.html
    Concepts
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96524/toc.htm
    List of Oracle 9i books (Documentation)
    http://www.oracle.com/pls/db92/db92.docindex?remark=homepage
    Hope this helps
    Regards
    Edited by: OrionNet on Apr 20, 2009 1:59 PM

  • In Word 2010, can I track changes in both Inline views and the balloon area?

    Hi All,
    I was working with a user and she wanted to be able to track changes both inline, and on the right balloon as well. Is this possible in Work 2010? Thank you for your help!

    You can't have both balloons and inline tracking at the same time, but you can switch between them at any time.
    Stefan Blom, Microsoft Word MVP

  • 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

  • Improve performance of  an inline view query

    All,
    I have a unique situation where I have to limit the number of rows based on group. so I created an Inline view and applied a limit on it.
    ex:
    SELECT col_A, col_B FROM ( SELECT col_a, count(*) FROM tab_a WHERE col_a = 'XXX' GROUP BY col_a) ROWNUM <-10.
    but this design was rejected, because it seems to have a great impact on performance due to inline view.
    Also I cant set a rowlimit directly on the query because GROUP BY clause is used in the select.
    When the rownum is directly applied in the WHERE, first it limits the rows and then it makes a GROUP, so when user asks to retrieve 10 records, it may show less than 10 rows because of the grouping.
    please help to find a alternative solution which helps to get the expected result set and same time without loosing performance.

    Hi,
    The sql you gave us is not valid. There is no "col_b" in your inline view, there is no "where" before "rownum<10", and the inline view returns only one row.
    Try to produce a reproducible scenario with scott.emp and scott.dept generated by $ORACLE_HOME/rdbms/admin/utlsampl.sql
    Regards
    Laurent

  • Regarding download customer.fmb and order.fmb

    Hello,
    Can you please let me know from where can i download customer.fmb and order.fmb for oracle forms 6i.
    Please explain that when do we use set_BLOCK_PROPERTY, i have gone through documents there are few examples and explaination of syntax but still i'm unable to understand when it to be use in menu or forms.
    Thanks

    Then we need to know what document you are reading so we know what files it references. If the document is a propietary document, you may have to go to the author of the document to get the files. For example, if you are studying from a copy of an Oracle Training book, you will need to contact Oracle to get copies of the sample forms. i got the pdf from internet the name of document is "*Oracle Forms Developer Build Internet Applications 2-Volume 1 Instructor Guide.PDF 40034GC10 Production 1.0 May 2000 M011398*" and here is no link to attach the file so i'm unable to send you that document.
    In above document, i'm going through " *Practice 1 and 1 Create a new menu module.*"
    some following details are given below:-
    1 Create a new menu module.
    a Using the following screenshot as a guideline, create a new menu
    module called M_SUMMITXX where XX is your student course
    number.
    here is figure regarding with menu editor, we have to followup to that figure
    File Menu and given property of file menu like below but it is in tabular form so i'm unable to copy paste here exactly the same:-
    Label_Menu     Item_Type      Command_Type      Menu_Item_Code      Visible_in_Menu       Visible_in_Horiz._ Menu_Toolbar       icon_Filename
    Save Plain PL/SQL DO_KEY(’COMMIT_FORM’); Yes Yes Save
    Clear Plain PL/SQL DO_KEY(’CLEAR_FORM’); Yes Yes Abort
    Null1 Separator Null Yes Yes
    Exit Plain PL/SQL DO_KEY(’EXIT_FORM’); Yes Yes Exit
    Null2 Separator Null No Yes
    like above the all property is given for all menu items and then after some instruction is given like below:-
    b Save as M_SUMMIT and compile the menu module.
    c Attach the menu module to the ORDERS form.
    d Save and compile the form module as ORDGXX where XX is your
    student course number.
    e Run and test your ORDERS form.
    *2* Add pop-up menus to the CUSTOMERS form.
    a Open the CUSTOMERS form module. Save as CUSTGXX where
    XX is your student course number.
    b Copy the EDIT_MENU menu from your M_SUMMIT menu
    module to your CUSTOMERS form. Attach this pop-up menu to the
    Comments item.
    c Save and compile the form module. Deploy your form to the Web to
    test.
    In this example, the SET_BLOCK_PROPERTY built-in is setting the ORDER_BY property of the S_ORD data block so that records displayed in the block are ordered by the SALES_REP_ID column (block item).
    For more information about the SET_BLOCK_PROPERTY search the Forms Help system; click the Index Tab and then type SET_BLOCK_PROPERTY and open the "SET_BLOCK_PROPERTY built-in" topic. As you review this help article it is helpful to have the property pallet open for a data block. Then you can select a property and press F1 to get detailed information about the property.i want to ask that when do we need to use SET_BLOCK_PROPERTY. in which case, because i also read to forms6i.pdf *"Form Builder Reference, Volume 1 Part No: A73074-01"* but i'm unable to understand that how to use and when to use.
    there is syntax given only but not given the situation.
    NOTE : Please let me know how to attach document then i can send to you, what document currently i'm following or please let me know your mailid so i'll email to you.
    Thanks

  • Inline views information

    tell me the difference between inline views and simple view
    try to answer with example
    thanks

    tell me the difference between inline views and
    simple view
    try to answer with example
    Sounds like a coursework question to me.
    Why don't you tell us what you think the differences are with examples and we'll tell you where you are misunderstanding.

  • Improve Performance on Inline view Query

    All,
    I have a unique situation where I have to limit the number of rows based on group. so I created an Inline view and applied a limit on it.
    ex:
    SELECT col_A, col_B FROM ( SELECT col_a, count(*) FROM tab_a WHERE col_a = 'XXX' GROUP BY col_a) ROWNUM <-10.
    but this design was rejected, because it seems to have a great impact on performance due to inline view.
    Also I cant set a rowlimit directly on the query because GROUP BY clause is used in the select.
    When the rownum is directly applied in the WHERE, first it limits the rows and then it makes a GROUP, so when user asks to retrieve 10 records, it may show less than 10 rows because of the grouping.
    please help to find a alternative solution which helps to get the expected result set and same time without loosing performance

    but this design was rejected, because it seems to have a great impact on performance due to inline view.What proof was offered that this query performed badly. There is nothing inherently non-performant about in-line views. I would demand to see some evidence that this query uses an unreasonable amount of system resource.
    However, you could try this:
    SELECT t.col1, avg(t.col2)
    FROM   t1 t
    WHERE  t.col1 IN ( SELECT DISTINCT x.col1
                       FROM   t1 x
                       WHERE  col3 = 'XXX'
                       AND    rownum <=10 )
    GROUP  BY t.col1
    /I assume your example is not derived from your real code (otherwise the WHERE clause would restrict the inline query to one returned row - problem solved!)
    Cheers, APC

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

Maybe you are looking for

  • Optimizing more than one photo at a time for captivate?

    I'm creating half hour training modules that use roughly 100 slides with more than 100 photos/images during the 100 slides. The file works just fine but the IT department would like the download time to be quicker (was set to 75% downloaded to view a

  • How do i know if my ipad3 is 3g or 4g version

    hi good day

  • Scripts not showing up in console

    Hi all I have put my folder scripts in the correct location as far as I know but I can't get any scripts to show up. See the screenshot below Any Ideas? Trevor

  • How to use Lightroom in general?

    Hi! I'm new to Lr. I've been using RawShooter for years. I'm trying to use Lr 3, but I keep getting frustrated: from RawShooter, I'm used to the following workflow: 1.) Point to the source directory 2.) Develop images 3.) Pick up developed images fro

  • POJO Subreport Linking Problem w/ CR XI

    I am having issues linking a POJO sourced subreport into a linked-table-based main report.  Both reports run fine alone, and in fact, when I include the subreport in the main report with no link, I can get all of the data.  However, when I link the s