Selection from 3 tables

Hi,
I have select-options: s_matnr for mchb-matnr &
s_pradh for mara-pradh & s_wdatu for lqua-wdatu.
I want to select records from mchb(matnr,wekrs,lgort)
, mara(matnr,pradh) and lqua(matnr,wdatu)
can any one tell me how do i achieve this?
points guaranteed..
cheers
kaki

Hi,
Here is my program...
I have five select-options...
s_matnr,s_werks,s_lgort,s_wdatu,s_prdha.
So end user can select any of this options.Iam trying to write select statements based on this.
REPORT  YMINVAGE  no standard page heading
        line-size 145
        line-count 65
        message-id Z1.
tables : mchb,                         "Batch Stocks
         mara,                         "Material Master
         mseg,
         lqua,                         "Storage bin location
         mvke.
data: begin of t_mchb occurs 0,
       matnr like zpartcnv-zzpartfj,
        matnr like mara-matnr,
        werks like mchb-werks,
        lgort like mchb-lgort,
        ersda like mchb-ersda,     " creation date
        charg like mchb-charg,     " Batch Number
        clabs like mchb-clabs,     " unrestricted quantity
        cspem like mchb-cspem,     " Blocked stock
        prdha like mara-prdha,     " product hierarchy
        wdatu like lqua-wdatu,     " gr date
        qty type i,
        price(8) type p decimals 2,
        amount(8) type p decimals 2,
      end of t_mchb.
data: begin of t_qty occurs 0,
       matnr like mchb-matnr,
       werks like mchb-werks,
       lgort like mchb-lgort,
       wdatu like lqua-wdatu,
       clabs like mchb-clabs,
       cspem like mchb-cspem,
       charg like mchb-charg,
       price(8) type p decimals 2,
       qty30  like mchb-clabs,
       qty60  like mchb-clabs,
       qty90  like mchb-clabs,
       qtyful like mchb-clabs,
       amt30 like mseg-dmbtr,
       amt60 like mseg-dmbtr,
       amt90 like mseg-dmbtr,
       amtful like mseg-dmbtr,
      end of t_qty.
data: begin of t_coll occurs 0,
         matnr like mchb-matnr,
         werks like mchb-werks,
         lgort like mchb-lgort,
         clabs like mchb-clabs,
         cspem like mchb-cspem,
         charg like mchb-charg,
         amount(8) type p decimals 2,
         date30 type d,
         date60 type d,
         date90 type d,
         fdate type d,
      end of t_coll.
data: begin of t_mara occurs 0,
        matnr like mara-matnr,
        prdha like mara-prdha,
      end of t_mara.
data : zukurs type p decimals 3,
       zffact like tcurr-ffact,
       ztfact like tcurr-tfact.
selection-screen begin of block sel with frame title text-001.
select-options : s_matnr for mchb-matnr.
select-options : s_prdha for mara-prdha.
select-options : s_werks for mchb-werks.
select-options : s_lgort for mchb-lgort.
select-options : s_wdatu for lqua-wdatu.
selection-screen end of block sel.
selection-screen begin of block sel1 with frame title text-002.
parameters: p_actstk radiobutton group g1 default 'X',
            p_blkstk radiobutton group g1.
selection-screen end of block sel1.
call function 'Z_FILL_MATNR_SELTAB'
  TABLES
    s_matnr = s_matnr.
start-of-selection.
  perform get_data.
  perform process_data.
  perform display_data.
top-of-page.
  perform set_page_header.
*&      Form  process_data
      text
form get_data.
  select matnr prodh from mvke into table t_mara where
                                         matnr in s_matnr and
                                         prodh in s_prdha.
select * into corresponding fields of table t_mchb
           from mchb
                 inner join mara
                     on mchbmatnr = maramatnr
                 inner join lqua
                     on mchbmatnr = lquamatnr
                    and mchbwerks = lquawerks
                             where mchb~matnr in s_matnr
                               and mara~prdha in s_prdha
                               and lqua~wdatu in s_wdatu.
  loop at t_mara.
    CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
      EXPORTING
        INPUT  = t_mara-matnr
      IMPORTING
        OUTPUT = t_mara-matnr.
    modify t_mara.
  endloop.
CHECK NOT t_mara[] IS INITIAL.
  if p_actstk = 'X'.
    select matnr werks lgort ersda charg clabs
    into corresponding fields of table t_mchb from mchb
               FOR ALL ENTRIES IN t_mara
                            where matnr = t_mara-matnr and
                                     werks in s_werks and
                                     lgort in s_lgort and
                                     clabs > 0.
  else.
    select matnr werks lgort ersda charg clabs
  into corresponding fields of table t_mchb from mchb
             FOR ALL ENTRIES IN t_mara
                          where matnr = t_mara-matnr and
                                   werks in s_werks and
                                   lgort in s_lgort and
                                   cspem > 0.
  endif.
  loop at t_mchb.
for date of goods receipt
    select single * from lqua where matnr = t_mchb-matnr and
                                    werks = t_mchb-werks and
                                    charg = t_mchb-charg and
                                    wdatu in s_wdatu.
    t_mchb-wdatu = lqua-wdatu.
    if sy-subrc = 0.
      modify t_mchb.
      clear t_mchb.
    endif.
  endloop.
  loop at t_mchb.
for unit price
    select single * from mseg where matnr = t_mchb-matnr and
                                    charg = t_mchb-charg and
                                    werks = t_mchb-werks.
    clear zukurs.
    perform get_usd.
    if zukurs <> 0.
      t_mchb-price = ( mseg-dmbtr / mseg-menge ) / ( zukurs / 100 ).
    else.
      t_mchb-price = ( mseg-dmbtr / mseg-menge ) / '1.6'.
    endif.
    if sy-subrc = 0.
      modify t_mchb.
      clear t_mchb.
    endif.
  endloop.
  if sy-subrc ne 0.
    message i016.
    leave list-processing.
  endif.
  loop at t_mchb.
    t_coll-matnr = t_mchb-matnr.
    t_coll-werks = t_mchb-werks.
    t_coll-lgort = t_mchb-lgort.
    append t_coll.
    clear t_coll.
  endloop.
  sort t_coll.
  delete adjacent duplicates from t_coll.
endform.                    "get_data
*&      Form  process_data
      text
form process_data.
  data:age type d.
  data: g_qty30 type i,
        g_qty60 type i,
        g_qty90 type i,
        g_qtyful type i,
        g_amt30 like t_qty-amt30,
        g_amt60 like t_qty-amt30,
        g_amt90 like t_qty-amt30,
        g_amtful like t_qty-amt30.
  loop at t_coll.
    loop at t_mchb where matnr = t_coll-matnr
                        and werks = t_coll-werks
                        and lgort = t_coll-lgort.
      age = t_mchb-wdatu.
      if age lt 31.
        if p_actstk = 'X'.
          g_qty30 = g_qty30 + t_mchb-clabs.
        else.
          g_qty30 = g_qty30 + t_mchb-cspem.
        endif.
      elseif age gt 30 and age lt 61.
        if p_actstk = 'X'.
          g_qty60 = g_qty60 + t_mchb-clabs.
        else.
          g_qty60 = g_qty60 + t_mchb-cspem.
        endif.
      elseif age gt 60 and age lt 91.
        if p_actstk = 'X'.
          g_qty90 = g_qty90 + t_mchb-clabs.
        else.
          g_qty90 = g_qty90 + t_mchb-cspem.
        endif.
      else.
        if p_actstk = 'X'.
          g_qtyful = g_qtyful + t_mchb-clabs.
        else.
          g_qtyful = g_qtyful + t_mchb-cspem.
        endif.
      endif.
    endloop.
for amount calculation
   if t_mchb-price = '0.00'.
     t_mchb-price = '1'.
   endif.
    g_amt30 = g_qty30 * t_mchb-price.
    g_amt60 = g_qty60 * t_mchb-price.
    g_amt90 = g_qty90 * t_mchb-price.
    g_amtful = g_qtyful * t_mchb-price.
    t_qty-amt30 = g_amt30.
    t_qty-amt60 = g_amt60.
    t_qty-amt90 = g_amt90.
    t_qty-amtful = g_amtful.
    t_qty-matnr = t_mchb-matnr.
    t_qty-werks = t_mchb-werks.
    t_qty-lgort = t_mchb-lgort.
    t_qty-wdatu = t_mchb-wdatu.
    t_qty-clabs = t_mchb-clabs.
    t_qty-cspem = t_mchb-cspem.
    t_qty-price = t_mchb-price.
*for quantities
    t_qty-qty30  =  g_qty30.
    t_qty-qty60  =  g_qty60.
    t_qty-qty90  =  g_qty90.
    t_qty-qtyful =  g_qtyful.
    if g_qty30 ne 0 or g_qty60 ne 0
        or g_qty90 ne 0 or g_qtyful ne 0.
      append t_qty.
    endif.
    clear t_qty.
    clear: g_qty30, g_qty60, g_qty90, g_qtyful,
           g_amt30, g_amt60, g_amt90, g_amtful.
  endloop.
  sort t_qty by wdatu.
endform.                    "process_data
*&      Form  display_data
      text
form display_data.
  data: count type i.
  data: l_ind value '1'.
  loop at t_qty.
    count = count + 1.
    if l_ind = '1'.
      l_ind = '0'.
      format color col_total intensified off .
    else.
      l_ind = 1.
      format color col_normal.
    endif.
    write:/1(24) t_qty-matnr color 2,
      24(4) t_qty-werks,
      32(4) t_qty-lgort.
    WRITE:41(1) SY-VLINE NO-GAP.
    WRITE:68(1) SY-VLINE NO-GAP.
    WRITE:95(1) SY-VLINE NO-GAP.
    WRITE:119(1) SY-VLINE NO-GAP.
   if age < 31.
    write: 42(13) t_qty-qty30,
           55(13) t_qty-amt30.
   elseif age < 61.
    write: 69(11) t_qty-qty60,
           84(11) t_qty-amt60.
   elseif age < 91.
    write: 96(11) t_qty-qty90,
           108(11) t_qty-amt90.
   else.
    write: 120(11) t_qty-qtyful,
          131(12) t_qty-amtful.
   endif.
  endloop.
  uline.
write count.
endform.                    "display_data
*&      Form  GET_USD
      text
form get_usd.
  call function 'READ_EXCHANGE_RATE'
       exporting
            date             = lqua-wdatu
            foreign_currency = 'USD'
            local_currency   = 'SGD'
            type_of_rate     = 'M'
       importing
            exchange_rate    = zukurs
            foreign_factor   = zffact
            local_factor     = ztfact
        valid_from_date  =
       exceptions
            no_rate_found    = 1
            no_factors_found = 2
            no_spread_found  = 3
            others           = 4.
endform.                               " GET_USD
*&      Form  set_page_header
      text
FORM set_page_header.
call function 'Z_REPORT_TITLE'
   EXPORTING
     line_size       = sy-linsz
     sy_title        = 'Inventory Aging Report'
     uline           = 'X'
     first_page_only = ' '.
  write:/1(145) space color 1.
  write :1(20)  'Material'            color col_heading,
         23(9) 'Plant'                color col_heading,
         31(15) 'Str.loc'           color col_heading,
         51(18) '0  - 30 days'        color col_heading,
         76(18) ' 31 - 60 days '      color col_heading,
         100(15) ' 61 - 90 days '      color col_heading,
         125(14) '  > 91 days   '     color col_heading.
  write:/1(145) space color 1.
  write:48(11) 'Qty'          color col_heading,
         58(10) 'Amnt(USD)'   color col_heading.
  write:73(10) 'Qty'          color col_heading,
        82(10) 'Amnt(USD)'    color col_heading.
  write:98(10) 'Qty'          color col_heading,
        108(10) 'Amnt(USD)'    color col_heading.
  write:122(10) 'Qty'          color col_heading,
        132(10) 'Amnt(USD)'    color col_heading.
  uline.
endform.                    "set_page_header

Similar Messages

  • Html form for select * from table a

    Hi all,
    I m looking for report on header/footer part from one apex pages
    which will display context from table a, like sql statement
    select * from table a, written in html.
    Is any examples in java script/html select from tables
    (and same insert into table A (...) select * from table b)
    thanks,
    Gordan

    Hello Gordan,
    Do you want to show the whole report or just some data of it?
    If it's for ex just the name and address you could create two items and have a process or computation to fill it with your select statement.
    If it's the whole report, just create the report and put it in for ex. Region 1. In your page template you can specify that Region 1 needs to come into the footer.
    Regards,
    Dimitri
    -- http://dgielis.blogspot.com/
    -- http://apex-evangelists.com/
    -- http://apexblogs.info/

  • Xmlgen.getxml("select * from table") returns null pointer exception

    I am running oracle 8i on solaris server and clinet on windows
    NT and i am this select statement
    select xmlgen.getxml("select * from table") from dual ,its
    returning null pointer exception,i have tried it through
    jdbc,even then its returning xml as
    <?xml version = '1.0'?>
    <ERROR>java.lang.NullPointerException</ERROR>
    can any body tell me the error.Help will be really appreciated.I
    need an urgent response,if some one can guide me please.
    My email is [email protected],if you can give me a quick
    response on this email,your effot will be appreciated.
    thanks
    Masood

    What is actually throwing the NullPointerException? rs.getMetaData() or table.setModel()?

  • How do I do SELECT * FROM TABLE WHERE KEY IN ({list})?

    The title says it all really.
    Is there a reasonable performant way to perform the query
    SELECT * FROM TABLE WHERE KEY IN ({list})where {list} is String []?
    I am currently creating a PreparedStatement with a for loop like this   StringBuffer sb = new StringBuffer ("SELECT * FROM TABLE WHERE ID IN (");
      for (int ii=0;ii<keys.length;ii++) {
        sb.append (keys [ii]);
        if (ii != keys.length-1) sb.append (",");
      sb.append (")");but this means that the prepared statement is created each time I call my method and so I'm not sure that the optimizer will find it easy to cope with. Is there a construction that I'm missing along the lines of SELECT * FROM TABLE WHERE KEY = ? where I can create the PreparedStatement once and just call setObject or something on it when the values in {list} change?

    but this means that the prepared statement is created
    each time I call my method and so I'm not sure that
    the optimizer will find it easy to cope with.You are right, the optimizer won't find that easy to deal with (presuming that is even relevant for your driver/database.) But most optimizers won't do anything with statements that change and that is what you are doing.
    You could create several prepared statements which have a common number of bind variables. For example 10 statements with from 1 to 10 bind values. This will work if most of the queries use those.

  • Select from table containing clob

    If i try to select from table containing clob column in SQL PLus it gives error.
    Tab1 contains 3 clob columns and 1 blob column
    select * from tab 1;
    SP2-0678: Column or attribute type can not be displayed by SQL*Plus
    The same statement works in SQL Developer and I am able to see the result.
    Actually i am writing the queries and they will be used by Java developers in their JSP page.
    So what happens here? Can Java use these select statements or will it throw error like SQL Plus?

    BLOB column content can't be displayed in SQL*Plus:
    SQL> create table t_blob (b blob);
    Table created.
    SQL> edit
    Wrote file afiedt.buf
      1* insert into t_blob values('01')
    SQL> /
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from t_blob;
    SP2-0678: Column or attribute type can not be displayed by SQL*PlusBlob and clob columns content can be processed using DBMS_LOB
    package procedures and functions or using client's language (like Java)
    methods. See JDBC specification.
    Rgds.

  • Select * from table not working with Oracle OBDC driver

    Hello,
    In our web development we have been using the MS ODBC for Oracle
    driver to connect to our Oracle db. We decided to try the
    Oracle ODBC driver because it supports the commandTimeout
    property in ASP which the MS driver does not. The problem I'm
    running into now is that all of our select * from table
    statements appear not to be working. The Oracle ODBC driver
    version we are using is ver 8.00.05.00. Is there something that
    I'm not doing properly? If I take the same select * from table
    statement and name the columns, I dont get any error. Otherwise
    I'm getting a Subscript out of range error. It seems strange to
    me that this driver would not support a select * from table
    statement (which I''m told is the case by another developer
    here).
    Is there something I'm missing?
    Thanks,
    Pete

    I'm positive I have a connection. Otherwise I wouldn't get a
    response when I name the columns instead of using *.
    There must be something else that I'm missing or doing wrong.
    I've actually been looking into alternative ODBC drivers to see
    if I have the same problems but none that I have found support
    commandTimeout.
    Any other ideas?

  • Performace Which is better ?  : Bapi inside a loop OR Select from Tables

    Hi Gurus,
    I have a report which displays purchase info records.
    If I am selecting from tables i need to use EINA, EINE, EORD and some other tables.
    There is a BAPI which gets all purchase info records specific to a vendor , material , purchasing organisation.
    QUESTION: Performace wise which is the better Approach, either selecting from tables or BAPI for Purchase info records
    Regards
    Avi.

    Whether it using BAPI or select. you need to check the performance. If you have full key for these tables EINA, EINE, EORD  then mak a select outside of the loop and within loop use READ TABLE statement with binary search. of if you want multiple records within loop then use loop insdie loop.
    Your final objective is to minimise the database hits . If you use bapi inside loop then your database hits will be more
    select from EINA
    select from EINE
    select from EORD
    loop at itab,
      read table EINA
      read table EINE
      read table EORD
    endloop

  • Special Grant to use "Select * from Table(cast..."??

    Hi,
    I've recently created the types and function to use the Table(Cast(funtion) as type)). It works fine, and gives me the correct result. I've granted execute on the types and on the function to a role that is enabled for a user, but when the user tries to use the "select * from table(cast(function) as type))", he gets a "ORA-01031: Insufficient Privileges" error message. Is there any other grant that must be given to the role, so that the user can execute the select?
    Thanks in advance!
    Daniel

    Hi Kamal,
    I'm not sure what anonymous PL/SQL block means. When I (or the user) try to run the select, I enter all the information, i.e., the owners for the type and function: "select * from table(cast(a.my_function(my_argument) as a.my_type))". I'm trying to use SQLPlus at this time, and I have Oracle 8i.
    I didn't to explicitly grant execute to the user because that would go against some rules I have to follow... I'll se if I give it a try though!
    Thanks!

  • Expression Framework / SELECT * FROM TABLE(CAST(...

    Hello!
    Is it possible to build the following with Toplink Expression Framework?
    Example:
    CREATE TYPE TY_OB_TEST AS OBJECT
    ( SYSTOP_NR NUMBER(5,0)
    SYS_NR NUMBER(5,0)
    IM_SYS_NAME VARCHAR2(80) ) ;
    CREATE TYPE TY_TB_TEST AS TABLE OF TY_OB_TEST;
    Package1.FUNCTION1 returns Type TY_TB_TEST.
    SQL:
    select * from TABLE(CAST(PACKAGE1.FUNCTION1(42)) AS TY_TB_TEST ));
    thank you!
    Harald.

    Nope, just use SQL.
    - Don

  • Insert into table a (select * from table b) - need pk?

    Hi there.
    I'm going to insert into table FINAL (select * from table STAGING) - same structure but in STAGING the ID column has nulls.
    Do I need to provide the ID (primary key) for table FINAL or will it get created based on sequence/trigger?
    If I were doing this in a loop I'd get the next val from the sequence but on a simple insert, I'm curious.
    thanks!

    hmm.. what is ?
    it didn't like it.
    Error(11,4): PLS-00103: Encountered the symbol "[" when expecting one of the following:     begin case declare exit for goto if loop mod null pragma    raise return select update while with <an identifier>    <a double-quoted delimited-identifier> <a bind variable> <<    close current delete fetch lock insert open rollback    savepoint set sql execute commit forall merge    <a single-quoted SQL string> pipe
    9i, sqldeveloper                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Select * from table as of Scn fails in powercenter

    Hi all, I have written the below query in SQL override of a Powercenter mapping. This fails with 'FROM keyword not found where expected' error. Can you please suggest how else I can fetch last committed data from my source?Select * from table AS OF SCN <Scn no>

    Hi All, I have multiple flat files which i need to load in a single table.I did that using indirect option at session level.But need to dig out on how to populate substring of header in name column in target table. i have two columns Id and Name. in all input file I have only one column 'id' with header like H|ABCD|Date. I need to populate target like below example. File 1                                    File2     H|ABCD|Date.                      H|EFGH|Date.1                                            42                                            5  3                                            6 Target tale: Id    Name1     ABCD2     ABCD3     ABCD4     EFGH5     EFGH6     EFGH can anyone help on what should be the logic to get this data in a table in informatica.

  • How to achieve that "SELECT * FROM table WHERE age BETWEEN 18 AND 23 AND n"

    How to achieve the SQL like that "SELECT * FROM table WHERE age BETWEEN 18 AND 23 AND name = 'Will' " with BDB C-API
    The primary key in the primary database is 'age' ,and the secondary key in the secondary index is 'name' ,in a lot of examples ,there are all simple , but how to do that complex one.thx~

    but this means that the prepared statement is created
    each time I call my method and so I'm not sure that
    the optimizer will find it easy to cope with.You are right, the optimizer won't find that easy to deal with (presuming that is even relevant for your driver/database.) But most optimizers won't do anything with statements that change and that is what you are doing.
    You could create several prepared statements which have a common number of bind variables. For example 10 statements with from 1 to 10 bind values. This will work if most of the queries use those.

  • Can I simulate SELECT * FROM TABLE WHERE ROW IN (1111,2222) using SQLJ

    I have a fct like
    public void fct(String inStr) {
    String str = "SELECT * FROM TABLE WHERE ROW IN" + inStr;
    // then I xecute the query using JDBC connection
    But I want to do the same thisn using SQLJ like:
    public void fct(String inStr) {
    #sql [nctx] iter = { SELECT * FROM TABLE WHERE ROW IN :inStr}
    When I run the second version and give a parameter like "(1111,2222)" it gives
    ORA-01722: invalid number error.
    Is there a way to give parameters to in clauses of SQLJ statements.
    Thanks in regard.

    This is a SQLJ FAQ. You can find the FAQ at:
    http://technet.oracle.com/tech/java/sqlj_jdbc/htdocs/faq.html
    Your question is addressed in the following section:
    http://technet.oracle.com/tech/java/sqlj_jdbc/htdocs/faq.html#variablesizevaluelist
    Note that that section has a typo. The lines:
    ? // populate mynumbers
    #sql { SELECT * FROM tab WHERE col in (:(a[0]),:(a[1]),?};
    should read:
    ... // populate mynumbers
    #sql { SELECT * FROM tab WHERE col in (:(a[0]),:(a[1]),...};
    By the way, with the next release SQLJ will support pasting in of dynamic SQL fragments. Then you'll be able to do pretty much what you are trying to accomplish here (albeit with slightly different syntax). Until then you'd have to use the workarounds from the FAQ.

  • Reason behind this query ,SELECT * FROM table WHERE 1 0

    HEllo,
    I would like to know the reason behind using this query ,
    SELECT * FROM <table> WHERE 1 < 0
    before executing the actual SQL query.
    Is there any special reason or the JDBC receiver side is configured like that.
    Is there any option to overcome this process like, can we remove this option or stop using this.
    Why the JDBC adapter basically sending this query on the DB?
    Thanks,
    Soorya,

    Hi,
    if you run this query, you wont be able to see any records of the table.
    SELECT * FROM <table> WHERE 1 < 0
    if you run this query you will see all records
    SELECT * FROM <table> WHERE 0 < 1
    same with SELECT * FROM <table> WHERE 1=1
    So you can check this out that whats happening in your code before executing actual query. just try to co-relate.
    regards
    Aashish Sinha
    PS : reward points if helpful

  • Select * from table where rownum 5; no rows returned? why is it so?

    select from table where rownum > 5;*
    no rows returned. why is it so?
    can anyone explain me?

    Hi,
    rownum is pseudo column, and it is based on the sort order.
    For ex, if you want to get the first 5 employees who get the least salary, you use,
    select ename,sal from
        (select ename, sal
         from emp
         order by sal )
        where rownum<=5
    ENAME      SAL                   
    SMITH      800                   
    ALLEN1     890                   
    JAMES      951                   
    TURNER     998                   
    ADAMS      1100Suppose, if you want to use highest salary, you change the order by and not the rownum. So, it becomes,
    select ename,sal from
        (select ename, sal
         from emp
         order by sal desc)
        where rownum<=5
    ENAME      SAL                   
    KING1      5000                  
    FORD       3000                  
    SCOTT      3000                  
    JONES      2975                  
    BLAKE      2850 So, its not the rownum you would want to change, but the order by.
    -Arun

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

Maybe you are looking for