Select time from view

i have a doubt as will a select based on a view will take more time than a select on 2 tables with a union.
View will be:-
create view1 as
select column1 from table1
union
select column1 from table2
so, will a
select * from view1
take more time than a
select column1 from table1
union
select column1 from table2
Please help in solving the doubt as it is urgent.
regards.

If it's that urgent why didn't you just rustle up a test case for yourself? You could have done that in the time it took you to post, let alone wait for my slow fingers to type one up and compose this reply. We are all volunteers here and there's no SLA.
Here is a test case. Obviously the stats are different, that's because of the data in the buffer cache, but the EXPLAIN PLAN is identical (except for the VIEW bit), so the two queries should execute in a similar timeframe.
Cheers, APC
SQL> SET autotrace TRACEONLY
SQL> SELECT col1 FROM t_10K
  2  UNION
  3  SELECT col1 FROM t_5k1
  4  /
10000 rows selected.
Execution Plan
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=43 Card=15000 Bytes=
          60000)
   1    0   SORT (UNIQUE) (Cost=43 Card=15000 Bytes=60000)
   2    1     UNION-ALL
   3    2       INDEX (FAST FULL SCAN) OF 'T10K_PK' (UNIQUE) (Cost=3 C
          ard=10000 Bytes=40000)
   4    2       TABLE ACCESS (FULL) OF 'T_5K1' (Cost=3 Card=5000 Bytes
          =20000)
Statistics
        750  recursive calls
          0  db block gets
        213  consistent gets
         71  physical reads
          0  redo size
     132870  bytes sent via SQL*Net to client
       7825  bytes received via SQL*Net from client
        668  SQL*Net roundtrips to/from client
         16  sorts (memory)
          0  sorts (disk)
      10000  rows processed
SQL> CREATE VIEW v1 AS
  2  SELECT col1 FROM t_10K
  3  UNION
  4  SELECT col1 FROM t_5k1
  5  /
View created.
SQL> SELECT * FROM v1
  2  /
10000 rows selected.
Execution Plan
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=43 Card=15000 Bytes=
          195000)
   1    0   VIEW OF 'V1' (Cost=43 Card=15000 Bytes=195000)
   2    1     SORT (UNIQUE) (Cost=43 Card=15000 Bytes=60000)
   3    2       UNION-ALL
   4    3         INDEX (FAST FULL SCAN) OF 'T10K_PK' (UNIQUE) (Cost=3
           Card=10000 Bytes=40000)
   5    3         TABLE ACCESS (FULL) OF 'T_5K1' (Cost=3 Card=5000 Byt
          es=20000)
Statistics
         19  recursive calls
          0  db block gets
         54  consistent gets
          0  physical reads
          0  redo size
     132870  bytes sent via SQL*Net to client
       7825  bytes received via SQL*Net from client
        668  SQL*Net roundtrips to/from client
          3  sorts (memory)
          0  sorts (disk)
      10000  rows processed
SQL>

Similar Messages

  • Select data from  view ( V_T856 ).

    Hi All,
    i need to download transaction type and text from V_T856 ,  but the data is not selected from V_T856 view.
    how to select data from a view, is there any special conditions.
    i declared V_T856 in tables statement, even though select statement not exicuted.
    pls suggest me with relevant information..
    thank you
    Regards
    Ramesh.

    hi ramesh,
    using Select statement you cannot retrieve the data from view.
    use the FM - VIEW_GET_DATA.
    call function 'VIEW_GET_DATA'      " func. mod to get data from maintenance view.
        exporting
          view_name = view
        tables
          data      = gt_data.
    Regards,
    Sakthi.

  • Select problem from view.

    Hi everyone,
    <br><br>
    I have constructed the following view,
    <br><br>
    SELECT b.eml_id
         , a.email "FROM"    
         , to_address.name
         , to_address.role
         , to_address.email "TO"
         , to_address.subject
         , to_address.header
         , to_address.footer   
      FROM mySchema.sct_parties a    
         , mySchema.sct_email_notify b
         , mySchema.sct_assign_email_notify c
         , (SELECT e.eml_id
                 , c.name "ROLE"
                 , initcap(a.first || ' ' || a.last) "NAME"            
                 , a.email
                 , e.subject
                 , e.header
                 , e.footer
              FROM mySchema.sct_parties a
                 , mySchema.sct_assign_roles b
                 , mySchema.sct_roles c
                 , mySchema.sct_assign_email_notify d
                 , mySchema.sct_email_notify e
             WHERE a.par_id = b.par_id
               AND b.rle_id = c.rle_id
               AND c.rle_id = d.rle_id
               AND d.eml_id = e.eml_id
               AND d.rle_id = 6
               AND e.status = 'CURRENT') to_address
    WHERE a.par_id = b.par_id
       AND to_address.eml_id = b.eml_id
       AND b.eml_id = 1
       AND b.status = 'CURRENT'When I do a
    <br><br>
    select * from viewName
    <br><br>
    no worries I get the record returned as expected, but when I
    <br><br>
    select a.to from viewName a I get the following error
    <br><br>
    Error starting at line 1 in command:
    SELECT a.to
      FROM mySchema.viewName a
    Error at Command Line:1 Column:9
    Error report:
    SQL Error: ORA-01747: invalid user.table.column, table.column, or column specification
    01747. 00000 -  "invalid user.table.column, table.column, or column specification"
    *Cause:   
    *Action:<br><br>
    Could someone tell me what the problem is.
    <br><br>
    Ben

    Double quotes may be confusing if the case is not consistent. Also, Oracle will use upper case in the data dictionary, by default, unless you use double quotes.
    SQL> create table t("col1" number, col2 number)
    Table created.
    SQL> insert into t(col1) values (1)
    ORA-00904: "COL1": invalid identifier
    SQL> insert into t(col2) values (2)
    1 row created.
    SQL> select col1 from t
    ORA-00904: "COL1": invalid identifier
    SQL> select col2 from t
          COL2
             2
    1 row selected.
    SQL> select column_name from user_tab_columns
    where table_name = 'T'
    and column_name like 'COL%'
    COLUMN_NAME                  
    COL2                         
    1 row selected.

  • How to select data from view V_TCURR

    Hi all,
    how to fetch data from view V_TCURR.
    I have to fetch 2 fieds:   kursp  and   *tfact
    (what does this * indicates in field name   *tfact)

    The view is a maintenance view and it doesn't even have field tfact available.
    Just select from the table directly
    PARAMETERS: p_kursp for tcurr-kurst,
                p_fcurr for tcurr-fcurr,
                p_tcurr for tcurr-tcurr,
                p_date  for tcurr-gdate.
    SELECT SINGLE
           kursp
           tfact
           INTO ( lv_kursp, lv_tfact )
           FROM tcurr
           WHERE kurst eq p_kurst
           AND   fcurr  eq p_fcurr
           AND   tcurr  eq p_tcurr
           AND   gdatu le p_date. 
    Hope that helps,
    Michael

  • ORA-01446 when selecting ROWID from View with Union

    I have a View that uses a Union to select from 3 tables. I would like the View to return the ROWID for the record that is returned so that I can update it in my form. The View compiles fine but when I select from the View I get ORA-01446 error.
    Example of my view:
    SELECT ROWID, col_a, col_b, col_c
    FROM tab_a
    UNION ALL
    SELECT ROWID, col_a, col_b, col_c
    FROM tab_b
    UNION ALL
    SELECT ROWID, col_a, col_b, col_c
    FROM tab_c
    I need the ROWID because my tables do not contain UNIQUE/PRIMARY key constraints. In my form I want to update the view with an underlying INSTEAD OF database trigger.
    Any suggestions?

    I think it will work if you give the column an alias (ie a name after the first rowid) and select that instead.
    You will probably also need another column in your view indicating which table the row came from if you want to update it.

  • ORA-01446: cannot select ROWID from view with DISTINCT, GROUP BY, etc.

    Hi,
    I have created view by joining two tables...And it is like this...
    Create view Test_Data as
    Select t.column1, t.column2, t.rowid from table1 t
    union s.column1,s.column2, s.rowid from table2 s
    with read only...
    Now I executed the following stmt...
    Select * from Test_Data where rowid = objid_ where I am passing the objid_ value...But it gave me the above error...can not I run this select stmt using the rowid ?
    Any input is highly appreciated...
    Thanks And Best Regards,
    /Dinesh...
    Hi All Again,
    I created the view in the following way...Just to check...
    CREATE VIEW my_view AS
    SELECT t.col1 col1,
    t.col2 col2,
    t.rowid objid
    FROM table1 t
    WHERE rownum < 400
    UNION
    SELECT q.col1 col1,
    q.col2 col2,
    q.rowid objid
    FROM table2 q
    WITH read only;
    Then I executed the following stmt...
    Select * from my_view where rowid = objid_
    Then I did not get that Oracle Error ORA-01446, Does anybody have any clue regarding this matter, i.e. how the use of rownum solve this prob...
    Thanks And Best Regards,
    /Dinesh...
    Edited by: user521478 on Aug 9, 2010 4:46 PM

    Check this:
    SQL> create view my_view as select rowid rd from dual;
    View created.
    SQL> select * from my_view;
    RD
    AAAACsAABAAAAGiAAA
    SQL> select * from my_view where rd = 'AAAACsAABAAAAGiAAA';
    RD
    AAAACsAABAAAAGiAAA
    SQL> So your create view statement should be:
    Create view Test_Data as
    Select t.column1, t.column2, t.rowid rd from table1 t
    union s.column1,s.column2, s.rowid from table2 s
    with read onlyThen try:
    Select * from Test_Data where rd = objid;Edited by: AP on Jul 28, 2010 2:19 AM

  • Select time from sysdate

    Hi Experts,
    I have to concatenate a date(not sysdate) with the system time and store it in a column having datatype as DATE...
    So I tried like this....
       SELECT
                  TO_CHAR (C_DATE, 'DD-MON-YYYY')
               || ' '
               || TO_CHAR (SYSDATE, 'HH:MI:SS PM')
        FROM   DUAL;
    But while inserting the output of the above query in my table it throws error like this...
    ORA-01830: date format picture ends before converting entire input string
    Is there any possibility to achieve this....
    Thanks in advance.

    Hi,
    The || operator produces a string.  Don't use a string where a DATE is expected; use a DATE instead.  For example
    INSERT INTO  new_table (c_date)
    SELECT  TRUNC (SYSDATE) + (c_date - TRUNC (c_date))
    FROM    old_table;

  • Select time from date type without to_char

    I have table T(myDate date, + about 15 columns). When I insert values into it, i also insert the time of a date.
    If I wanna see all the data in the table, I need to call to_char on column myDate. So need to write all the 15 column names in the select.
    I'd like to simply write a select * from T, but see the time for myDate as well. Is this possible?
    Thanks

    You can use alter session in a SQLPlus session
    See this example:
    SQL>
    SQL> select * from emp
      2  where rownum <=2;
         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
    SQL>
    SQL> alter session set nls_date_format='DD-MON-YYYY HH24:MI:SS';
    Session altered.
    SQL>
    SQL> select * from emp
      2  where rownum <=2;
         EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-1980 00:00:00        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-1981 00:00:00       1600        300         30Regards.
    Al

  • End of communication channel when select from view

    We are using DB 10.0.2.0.2 and when we run select statement from view it gives End of communication channel error but when we run the query by using the sql in the view it works fine.
    Please advise what may be wrong.

    Like other poster suggested, please post some sample code, query your used to build the view (you can scramble the real table/column name as your wish) and the actual screen capture of the error.
    This will help others to help you. Right now you are only describing symptoms while no one has idea what it really is.

  • HT2128 I am on Mac Lion. I about 36 photos frodownloadedm a friends storage place online.? I usually select about 10 at a time and view in preview (default) to make my selections. But Lion is saying blahblah.jpg is an application downloaded from the inter

    I am on Mac Lion. I downloaded about 36 photos from a friends storage place online.?
    I usually select about 10 at a time and view in preview (default) to make my selections. But Lion is saying "blahblah.jpg is an application downloaded from the internet.  Are you sure you want to open it?" These are files not applications (jpg's)
    Is there no way to change this and not get the question every time? I will have to do it for every picture one at a time- what a pain. The older operating system did not do this.

    It's possible, but not recommended unless you're an advanced user who understands the risk. Install the free application "TinkerTool" (not "TinkerTool System"), select the Applications tab, and check the box labeled "Don't show quarantine warnings for downloaded files." Log out and log back in. This action will disable the built-in protection against malware. You've been warned.

  • Performance issue in selecting data from a view because of not in condition

    Hi experts,
    I have a requirement to select data in a view which is not available in a fact with certain join conditions. but the fact table contains 2 crore rows of data. so this view is not working at all. it is running for long time. im pasting query here. please help me to tune it. whole query except prior to not in is executing in 15 minutes. but when i add not in condition it is running for so many hours as the second table has millions of records.
    CREATE OR REPLACE FORCE VIEW EDWOWN.MEDW_V_GIEA_SERVICE_LEVEL11
       SYS_ENT_ID,
       SERVICE_LEVEL_NO,
       CUSTOMER_NO,
       BILL_TO_LOCATION,
       PART_NO,
       SRCE_SYS_ID,
       BUS_AREA_ID,
       CONTRACT,
       WAREHOUSE,
       ORDER_NO,
       LINE_NO,
       REL_NO,
       REVISED_DUE_DATE,
       REVISED_QTY_DUE,
       QTY_RESERVED,
       QTY_PICKED,
       QTY_SHIPPED,
       ABBREVIATION,
       ACCT_WEEK,
       ACCT_MONTH,
       ACCT_YEAR,
       UPDATED_FLAG,
       CREATE_DATE,
       RECORD_DATE,
       BASE_WAREHOUSE,
       EARLIEST_SHIP_DATE,
       LATEST_SHIP_DATE,
       SERVICE_DATE,
       SHIP_PCT,
       ALLOC_PCT,
       WHSE_PCT,
       ABC_CLASS,
       LOCATION_ID,
       RELEASE_COMP,
       WAREHOUSE_DESC,
       MAKE_TO_FLAG,
       SOURCE_CREATE_DATE,
       SOURCE_UPDATE_DATE,
       SOURCE_CREATED_BY,
       SOURCE_UPDATED_BY,
       ENTITY_CODE,
       RECORD_ID,
       SRC_SYS_ENT_ID,
       BSS_HIERARCHY_KEY,
       SERVICE_LVL_FLAG
    AS
       SELECT SL.SYS_ENT_ID,
                 SL.ENTITY_CODE
              || '-'
              || SL.order_no
              || '-'
              || SL.LINE_NO
              || '-'
              || SL.REL_NO
                 SERVICE_LEVEL_NO,
              SL.CUSTOMER_NO,
              SL.BILL_TO_LOCATION,
              SL.PART_NO,
              SL.SRCE_SYS_ID,
              SL.BUS_AREA_ID,
              SL.CONTRACT,
              SL.WAREHOUSE,
              SL.ORDER_NO,
              SL.LINE_NO,
              SL.REL_NO,
              SL.REVISED_DUE_DATE,
              SL.REVISED_QTY_DUE,
              NULL QTY_RESERVED,
              NULL QTY_PICKED,
              SL.QTY_SHIPPED,
              SL.ABBREVIATION,
              NULL ACCT_WEEK,
              NULL ACCT_MONTH,
              NULL ACCT_YEAR,
              NULL UPDATED_FLAG,
              SL.CREATE_DATE,
              SL.RECORD_DATE,
              SL.BASE_WAREHOUSE,
              SL.EARLIEST_SHIP_DATE,
              SL.LATEST_SHIP_DATE,
              SL.SERVICE_DATE,
              SL.SHIP_PCT,
              0 ALLOC_PCT,
              0 WHSE_PCT,
              SL.ABC_CLASS,
              SL.LOCATION_ID,
              NULL RELEASE_COMP,
              SL.WAREHOUSE_DESC,
              SL.MAKE_TO_FLAG,
              SL.source_create_date,
              SL.source_update_date,
              SL.source_created_by,
              SL.source_updated_by,
              SL.ENTITY_CODE,
              SL.RECORD_ID,
              SL.SRC_SYS_ENT_ID,
              SL.BSS_HIERARCHY_KEY,
              'Y' SERVICE_LVL_FLAG
         FROM (  SELECT SL_INT.SYS_ENT_ID,
                        SL_INT.CUSTOMER_NO,
                        SL_INT.BILL_TO_LOCATION,
                        SL_INT.PART_NO,
                        SL_INT.SRCE_SYS_ID,
                        SL_INT.BUS_AREA_ID,
                        SL_INT.CONTRACT,
                        SL_INT.WAREHOUSE,
                        SL_INT.ORDER_NO,
                        SL_INT.LINE_NO,
                        MAX (SL_INT.REL_NO) REL_NO,
                        SL_INT.REVISED_DUE_DATE,
                        SUM (SL_INT.REVISED_QTY_DUE) REVISED_QTY_DUE,
                        SUM (SL_INT.QTY_SHIPPED) QTY_SHIPPED,
                        SL_INT.ABBREVIATION,
                        MAX (SL_INT.CREATE_DATE) CREATE_DATE,
                        MAX (SL_INT.RECORD_DATE) RECORD_DATE,
                        SL_INT.BASE_WAREHOUSE,
                        MAX (SL_INT.LAST_SHIPMENT_DATE) LAST_SHIPMENT_DATE,
                        MAX (SL_INT.EARLIEST_SHIP_DATE) EARLIEST_SHIP_DATE,
                        MAX (SL_INT.LATEST_SHIP_DATE) LATEST_SHIP_DATE,
                        MAX (
                           CASE
                              WHEN TRUNC (SL_INT.LAST_SHIPMENT_DATE) <=
                                      TRUNC (SL_INT.LATEST_SHIP_DATE)
                              THEN
                                 TRUNC (SL_INT.LAST_SHIPMENT_DATE)
                              ELSE
                                 TRUNC (SL_INT.LATEST_SHIP_DATE)
                           END)
                           SERVICE_DATE,
                        MIN (
                           CASE
                              WHEN TRUNC (SL_INT.LAST_SHIPMENT_DATE) >=
                                      TRUNC (SL_INT.EARLIEST_SHIP_DATE)
                                   AND TRUNC (SL_INT.LAST_SHIPMENT_DATE) <=
                                          TRUNC (SL_INT.LATEST_SHIP_DATE)
                                   AND SL_INT.QTY_SHIPPED = SL_INT.REVISED_QTY_DUE
                              THEN
                                 100
                              ELSE
                                 0
                           END)
                           SHIP_PCT,
                        SL_INT.ABC_CLASS,
                        SL_INT.LOCATION_ID,
                        SL_INT.WAREHOUSE_DESC,
                        SL_INT.MAKE_TO_FLAG,
                        MAX (SL_INT.source_create_date) source_create_date,
                        MAX (SL_INT.source_update_date) source_update_date,
                        SL_INT.source_created_by,
                        SL_INT.source_updated_by,
                        SL_INT.ENTITY_CODE,
                        SL_INT.RECORD_ID,
                        SL_INT.SRC_SYS_ENT_ID,
                        SL_INT.BSS_HIERARCHY_KEY
                   FROM (SELECT SL_UNADJ.*,
                                DECODE (
                                   TRIM (TIMA.DAY_DESC),
                                   'saturday',   SL_UNADJ.REVISED_DUE_DATE
                                               - 1
                                               - early_ship_days,
                                   'sunday',   SL_UNADJ.REVISED_DUE_DATE
                                             - 2
                                             - early_ship_days,
                                   SL_UNADJ.REVISED_DUE_DATE - early_ship_days)
                                   EARLIEST_SHIP_DATE,
                                DECODE (
                                   TRIM (TIMB.DAY_DESC),
                                   'saturday',   SL_UNADJ.REVISED_DUE_DATE
                                               + 2
                                               + LATE_SHIP_DAYS,
                                   'sunday',   SL_UNADJ.REVISED_DUE_DATE
                                             + 1
                                             + LATE_SHIP_DAYS,
                                   SL_UNADJ.REVISED_DUE_DATE + LATE_SHIP_DAYS)
                                   LATEST_SHIP_DATE
                           FROM (SELECT NVL (s2.sys_ent_id, '00') SYS_ENT_ID,
                                        cust.customer_no CUSTOMER_NO,
                                        cust.bill_to_loc BILL_TO_LOCATION,
                                        cust.early_ship_days,
                                        CUST.LATE_SHIP_DAYS,
                                        ord.PART_NO,
                                        ord.SRCE_SYS_ID,
                                        ord.BUS_AREA_ID,
                                        ord.BUS_AREA_ID CONTRACT,
                                        NVL (WAREHOUSE, ord.entity_code) WAREHOUSE,
                                        ORDER_NO,
                                        ORDER_LINE_NO LINE_NO,
                                        ORDER_REL_NO REL_NO,
                                        TRUNC (REVISED_DUE_DATE) REVISED_DUE_DATE,
                                        REVISED_ORDER_QTY REVISED_QTY_DUE,
                                        --   NULL QTY_RESERVED,
                                        --    NULL QTY_PICKED,
                                        SHIPPED_QTY QTY_SHIPPED,
                                        sold_to_abbreviation ABBREVIATION,
                                        --        NULL ACCT_WEEK,
                                        --      NULL ACCT_MONTH,
                                        --    NULL ACCT_YEAR,
                                        --  NULL UPDATED_FLAG,
                                        ord.CREATE_DATE CREATE_DATE,
                                        ord.CREATE_DATE RECORD_DATE,
                                        NVL (WAREHOUSE, ord.entity_code)
                                           BASE_WAREHOUSE,
                                        LAST_SHIPMENT_DATE,
                                        TRUNC (REVISED_DUE_DATE)
                                        - cust.early_ship_days
                                           EARLIEST_SHIP_DATE_UnAdj,
                                        TRUNC (REVISED_DUE_DATE)
                                        + CUST.LATE_SHIP_DAYS
                                           LATEST_SHIP_DATE_UnAdj,
                                        --0 ALLOC_PCT,
                                        --0 WHSE_PCT,
                                        ABC_CLASS,
                                        NVL (LOCATION_ID, '000') LOCATION_ID,
                                        --NULL RELEASE_COMP,
                                        WAREHOUSE_DESC,
                                        NVL (
                                           DECODE (MAKE_TO_FLAG,
                                                   'S', 0,
                                                   'O', 1,
                                                   '', -1),
                                           -1)
                                           MAKE_TO_FLAG,
                                        ord.CREATE_DATE source_create_date,
                                        ord.UPDATE_DATE source_update_date,
                                        ord.CREATED_BY source_created_by,
                                        ord.UPDATED_BY source_updated_by,
                                        ord.ENTITY_CODE,
                                        ord.RECORD_ID,
                                        src.SYS_ENT_ID SRC_SYS_ENT_ID,
                                        ord.BSS_HIERARCHY_KEY
                                   FROM EDW_DTL_ORDER_FACT ord,
                                        edw_v_maxv_cust_dim cust,
                                        edw_v_maxv_part_dim part,
                                        EDW_WAREHOUSE_LKP war,
                                        EDW_SOURCE_LKP src,
                                        MEDW_PLANT_LKP s2,
                                        edw_v_incr_refresh_ctl incr
                                  WHERE ord.BSS_HIERARCHY_KEY =
                                           cust.BSS_HIERARCHY_KEY(+)
                                        AND ord.record_id = part.record_id(+)
                                        AND ord.part_no = part.part_no(+)
                                        AND NVL (ord.WAREHOUSE, ord.entity_code) =
                                               war.WAREHOUSE_code(+)
                                        AND ord.entity_code = war.entity_code(+)
                                        AND ord.record_id = src.record_id
                                        AND src.calculate_back_order_flag = 'Y'
                                        AND NVL (cancel_order_flag, 'N') != 'Y'
                                        AND UPPER (part.source_plant) =
                                               UPPER (s2.location_code1(+))
                                        AND mapping_name = 'MEDW_MAP_GIEA_MTOS_STG'
                                      --  AND NVL (ord.UPDATE_DATE, SYSDATE) >=
                                      --         MAX_SOURCE_UPDATE_DATE
                                        AND UPPER (
                                               NVL (ord.order_status, 'BOOKED')) NOT IN
                                               ('ENTERED', 'CANCELLED')
                                        AND TRUNC (REVISED_DUE_DATE) <= SYSDATE) SL_UNADJ,
                                EDW_TIME_DIM TIMA,
                                EDW_TIME_DIM TIMB
                          WHERE TRUNC (SL_UNADJ.EARLIEST_SHIP_DATE_UnAdj) =
                                   TIMA.ACCOUNT_DATE
                                AND TRUNC (SL_UNADJ.LATEST_SHIP_DATE_Unadj) =
                                       TIMB.ACCOUNT_DATE) SL_INT
                  WHERE TRUNC (LATEST_SHIP_DATE) <= TRUNC (SYSDATE)
               GROUP BY SL_INT.SYS_ENT_ID,
                        SL_INT.CUSTOMER_NO,
                        SL_INT.BILL_TO_LOCATION,
                        SL_INT.PART_NO,
                        SL_INT.SRCE_SYS_ID,
                        SL_INT.BUS_AREA_ID,
                        SL_INT.CONTRACT,
                        SL_INT.WAREHOUSE,
                        SL_INT.ORDER_NO,
                        SL_INT.LINE_NO,
                        SL_INT.REVISED_DUE_DATE,
                        SL_INT.ABBREVIATION,
                        SL_INT.BASE_WAREHOUSE,
                        SL_INT.ABC_CLASS,
                        SL_INT.LOCATION_ID,
                        SL_INT.WAREHOUSE_DESC,
                        SL_INT.MAKE_TO_FLAG,
                        SL_INT.source_created_by,
                        SL_INT.source_updated_by,
                        SL_INT.ENTITY_CODE,
                        SL_INT.RECORD_ID,
                        SL_INT.SRC_SYS_ENT_ID,
                        SL_INT.BSS_HIERARCHY_KEY) SL
        WHERE (SL.BSS_HIERARCHY_KEY,
               SL.ORDER_NO,
               Sl.line_no,
               sl.Revised_due_date,
               SL.PART_NO,
               sl.sys_ent_id) NOT IN
                 (SELECT BSS_HIERARCHY_KEY,
                         ORDER_NO,
                         line_no,
                         revised_due_date,
                         part_no,
                         src_sys_ent_id
                    FROM MEDW_MTOS_DTL_FACT
                   WHERE service_lvl_flag = 'Y');
                   thanks
    asn

    Also 'NOT IN' + nullable columns can be an expensive combination - and may not give the expected results. For example, compare these:
    with test1 as ( select 1 as key1 from dual )
       , test2 as ( select null as key2 from dual )
    select * from test1
    where  key1 not in
           ( select key2 from test2 );
    no rows selected
    with test1 as ( select 1 as key1 from dual )
       , test2 as ( select null as key2 from dual )
    select * from test1
    where  key1 not in
           ( select key2 from test2
             where  key2 is not null );
          KEY1
             1
    1 row selected.Even if the columns do contain values, if they are nullable Oracle has to perform a resource-intensive filter operation in case they are null. An EXISTS construction is not concerned with null values and can therefore use a more efficient execution plan, leading people to think it is inherently faster in general.

  • Select data from all the table names in the view

    Hi,
    "I have some tables with names T_SRI_MMYYYY in my database.
    I created a view ,Say "Summary_View" for all the table names
    with "T_SRI_%".
    Now i want to select data from all the tables in the view
    Summary_View.
    How can i do that ? Please throw some light on the same?
    Thanks and Regards
    Srinivas Chebolu

    Srinivas,
    There are a couple of things that I am unsure of here.
    Firstly, does your view definition say something like ...
    Select ...
    From "T_SRI_%"
    If so, it is not valid. Oracle won't allow this.
    The second thing is that your naming convention for the
    tables suggests to me that each table is the same except
    that they store data for different time periods. This would be
    a very bad design methodology. You should have a single
    table with an extra column to state what period is referred to,
    although you can partition it into segments for each period if
    appropriate.
    Apologies if i am misinterpreting your question, but perhaps
    you could post your view definition and table definitions
    here.

  • Error when selecting from view created by OLAP_TABLE

    Hi all,
    I used OWB 10.2.0.4 to create a MOLAP datawarehouse.
    I created a view with this:
    CREATE OR REPLACE VIEW sales_view AS
    SELECT *
    FROM TABLE(OLAP_TABLE(
    'dw duration session',
    'MEASURE samt AS number(16,0) FROM SALES_SAMT
    DIMENSION cust_code AS varchar2(30) FROM cust
    DIMENSION prod_code AS varchar2(30) FROM prod
    DIMENSION sman_code AS varchar2(30) FROM sman
    DIMENSION time_id AS varchar2(30) FROM time
    DIMENSION orgn_code AS varchar2(30) FROM orgn'));
    and I try to run the following:
    select count(*) from sales_view;
    and I got the following error:
    Error starting at line 1 in command:
    select count(*) from sales_view
    Error report:
    SQL Error: ORA-29400: data cartridge error
    ORA-00600: internal error code, arguments: [xsvaluekeyget: type], [114], [], [], [], [], [], []
    29400. 00000 - "data cartridge error\n%s"
    *Cause:    An error has occurred in a data cartridge external procedure.
    This message will be followed by a second message giving
    more details about the data cartridge error.
    *Action:   See the data cartridge documentation
    for an explanation of the second error message.
    Can somebody give me some idea?
    Many thanks!
    - Andrew

    Brijesh,
    Really appreciate your help!
    With your hint (#2), I found my problems.
    I had 2 problems:
    1) I'm missing the 'Model' clause at the end of my view creation (in bold )
    2) I shouldn't do a count on all rows (e.g. I get result if I select with parameters)
    Here's my working view:
    CREATE OR REPLACE VIEW SALES_VIEW2
    AS
    SELECT * FROM TABLE(OLAP_TABLE(
    'DW DURATION SESSION',
    MEASURE SAMT FROM SALES_SAMT1
    DIMENSION PROD_CODE FROM PROD
    DIMENSION SMAN_CODE FROM SMAN
    DIMENSION TIME_CODE FROM TIME
    DIMENSION CUST_CODE FROM CUST
    DIMENSION ORGN_CODE FROM ORGN
    MODEL
    DIMENSION BY(PROD_CODE, CUST_CODE, SMAN_CODE, TIME_CODE, ORGN_CODE)
    MEASURES(SAMT)
    RULES UPDATE SEQUENTIAL ORDER();
    -----

  • Is select from view faster then select from table..???

    Hello Gurus,
    I want to query some data from two tables, both of table have many columns (attributes) and many rows...
    I use several where clauses to retrieve data from those tables..
    witch one is faster, I create a view or I just "select" from those tables???
    Regards.
    Nia...

    riedelme wrote:
    3360 wrote:
    riedelme wrote:
    Selecting through a view almost never helps performance and frequently hurts.Views do not affect performance.
    Views are simply queries and like queries there are fast and slow ones.I disagree.
    First of all, to use a view you are executing a query to get a result set, then accessing the data from that result set - a built-in extra step to perform to get data.First of all that entire explanation of how views work is not correct. The optimizer will rewrite the query to make the view go away if possible.
    SQL> create or replace view v as select * from dual;
    View created.
    SQL> explain plan for select * from dual where dummy = 'X';
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 272002086
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |     2 |     2   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("DUMMY"='X')
    13 rows selected.
    SQL> explain plan for select * from v where dummy = 'X';
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 272002086
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |     2 |     2   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("DUMMY"='X')
    13 rows selected.Exactly the same.
    >
    Second, when accessing the data from the view the result sets don't have indexes for fast lookups and efficient joins on later steps.This is also known as just making stuff up and is not how the database works. care to share any references at all for any of this?
    >
    Third, the systems I've seen that use views extensively - I am looking at one now - tend to perform joins on views using the same tables with the same data over and over. This is a design issue and not specifically a problem with views but they lend themselves to this misuse much too easilyCorrect as I said a view is just a query, and just like queries there are good fast views and bad slow views
    >
    I'll concede that the problem is not specifically with views themselves but as I just said they lend themselves to misuse. Tuning views of views and views joined to views is difficultYes, queries can be misused as can almost all SQL functions and functionality.
    As I said - Views are simply queries and like queries there are fast and slow ones.
    Nothing that you have posted that is accurate changes that.

  • How to get the latest Change date and time of a M.O. from View VIAUFKST

    Hi All,
    I want to get the latest date and time of a M.O. from view
    VIAUFKST. I have written the query like this...
      SELECT AUFNR
             AEDAT  " Changed Date
             AEZEIT " Changed Time
        FROM VIAUFKST
        INTO TABLE I_VIAUFKST
       WHERE AEDAT >= W_LASTRUN_DATE
       ORDER BY AEDAT DESCENDING.
    but its not giving me right results... Pls help me out on this or suggest me the right approach to achieve the same...As this is very critical issue...
    Advance Thanks and Points Gauranteed...
    Suresh

    > SELECT AUFNR
    >          AEDAT
    >          AEZEIT
    >     FROM VIAUFKST
    >     INTO TABLE I_VIAUFKST
    >    WHERE AEDAT >= W_LASTRUN_DATE.  
    >
    >   IF NOT I_VIAUFKST[] IS INITIAL.
    >    SORT I_VIAUFKST BY AEDAT AEZEIT DESCENDING.
    >    READ TABLE I_VIAUFKST INDEX 1.
    >   ENDIF.
    >
    > The above statement is giving me different results...
    > such as...
    >
    >  1. 30/11/2005 19:20:11
    >  2. 29/11/2005 22:10:09
    >  3. 30/11/2005 20:56:09
    >  4. 28/11/2005 23:10:09
    >
    > by using the above SORT statement i am getting the
    > fourth record as the latest, where as it should give
    > me the third record....
    >
    > Please advise,
    > Suresh.
    Hi Suresh,
    The reason why you are getting this result is because the system is interpreting the DESCENDING only for AEZEIT not for both. Change it to
    SORT I_VIAUFKST BY AEDAT DESCENDING AEZEIT DESCENDING

Maybe you are looking for

  • HT5500 How do I get all my facebook friends OUT of my icloud contacts?

    This is a HUGE problem for me.  I don't know what setting I change to ull my facebook friend info into my icloud contacts files on all devices, but I want to reverse it and make them gone!!!!  GONE I say.  If someone thought this was a good idea and

  • Looking to buy a refurbished MacBook Pro for video editing. Need suggestions on what to look for.

    Hey Everyone, I already own a 2012 Mac Pro Desktop. I do some pretty advanced video editing on it, using FCPX and After Effects, with FXFactory and many other plugins. I need to invest in a MacBook Pro so I can transfer my projects and edit at differ

  • Can't associate .pdf files as Acrobat, opens Distiller instead

    I can't associate .pdf files as Adobe Acrobat 8 Professional. Instead, opens it opens Acrobat Distiller. When I go to the file association in the Control Panel, it doesn't even show Adobe Acrobat as a program. So I browse & find it & select the Adobe

  • Set outgoing account based on address book group

    Hello -- I am looking for a way to automatically set the account of new outgoing messages based on the address book group membership of the email recipient. For example, a script or rule that works something like: If [any recipient] belongs to group

  • Syncing BB Q10 with Mac

    I am trying to sync my MacBook Pro with my BB Q10. I downloaded the Blackberry Desktop software and received this message -- HELP "This blackberry device is running the BB 10OS. Blackberry Desktop Softwear donesn't support the BB 10 OS . Visit BB sup