Select query on two Database views

Hi all,
Can i fetch the data by writing a select query on two DATABASE VIEWS
Because i am able to fetch data by writing a selct query on ONE DATABASE VIEW and ON TRANSPARANT TABLE
but i am not able to fetch data by writing a query on TWO DATABASE VIEWS
Query which i am able to fetch data is
select * from CSKS where OBJNR = COVJ-OBJNR
Query which i am NOT able to fetch data is
Select * from COAS where OBJNR = COVJ-OBJNR
Here
COVJ is a DATABASE VIEW
CSKS is a Transparant Table
COAS is a DATABASE VIEW
Thanks in advance
Regards
Ajay

Hi
I tried with code and I am able to fetch data from view COAS
DATA:it_coas TYPE STANDARD TABLE OF coas.
SELECT * FROM coas INTO TABLE it_coas.
IF sy-subrc IS INITIAL.
  WRITE:/ 'Sucess'.
ENDIF.
I think in your case COAS view does not have a value for COVJ-OBJNR.
Regards
Srilaxmi

Similar Messages

  • How an INDEX of a Table got selected when a SELECT query hits the Database

    Hi All,
    How an Index got selected when a SELECT query hits the Database Table.
    My SELECT query is as ahown below.
        SELECT ebeln ebelp matnr FROM ekpo
                       APPENDING TABLE i_ebeln
                       FOR ALL ENTRIES IN i_mara_01
                       WHERE werks = p_werks      AND
                             matnr = i_mara_01-matnr AND
                             bstyp EQ 'F'         AND
                             loekz IN (' ' , 'S') AND
                             elikz = ' '          AND
                             ebeln IN s_ebeln     AND
                             pstyp IN ('0' , '3') AND
                             knttp = ' '          AND
                             ko_prctr IN r_prctr  AND
                             retpo = ''.
    The fields in the INDEX of the Table EKPO should be in the same sequence as in the WHERE clasuse?
    Regards,
    Viji

    Hi,
    You minimize the size of the result set by using the WHERE and HAVING clauses. To increase the efficiency of these clauses, you should formulate them to fit with the database table indexes.
    Database Indexes
    Indexes speed up data selection from the database. They consist of selected fields of a table, of which a copy is then made in sorted order. If you specify the index fields correctly in a condition in the WHERE or HAVING clause, the system only searches part of the index (index range scan).
    The primary index is always created automatically in the R/3 System. It consists of the primary key fields of the database table. This means that for each combination of fields in the index, there is a maximum of one line in the table. This kind of index is also known as UNIQUE. If you cannot use the primary index to determine the result set because, for example, none of the primary index fields occur in the WHERE or HAVING clause, the system searches through the entire table (full table scan). For this case, you can create secondary indexes, which can restrict the number of table entries searched to form the result set.
    reference : help.sap.com
    thanx.

  • Select Query Between two dates...

    Hi Guru's,
    I need a Select Query between two dates, also if the record not found for any in between date then it should return NULL or 0 ...
    for Example
    1. I am having two records in DB for date 2-10-2008 & 4-10-2008
    2. Now suppose I have given Query for date between 1-10-2008 to 5-10-2008
    Then it should return me 5 records with valid values for 2 & 4 and NULL for other 1,3,5
    Thanks.

    Try like this:
    with
      t as
          select date '2008-10-02' as dt, 'Record #1 (in DB)' as str from dual union all
          select date '2008-10-04' as dt, 'Record #2 (in DB)' as str from dual
    select v.dt, t.str
      from (
             select date '2008-10-01' + level - 1 as dt
               from dual
             connect by level <= (date '2008-10-05' - date '2008-10-01') + 1
           ) v
      left join t
        on v.dt = t.dt
    order by 1

  • How to Export/Import specific/selected table columns (can database view be

    All,
    I like to export and import some selected columns and rows of a table from one oracle database to another database.
    For example, I like to export the following SQL's result data to another oracle database.
    select ename, sal from emp where dno = 100;
    Can I create a database view based on the above SQL and export the view with data (I don't think data will be exported along with database view?)
    I know, I can do this either with SQL*Loader or by creating DBLink between databases and using insert-select statement.
    Please let me know if this is possible in exp/imp.
    Appreciate your help.
    Thanks
    Kumar

    Hello,
    You can Query and table option to export and import and i recommend you to create parameter file to use query option
    parfile.par
    file=myexport.dmp
    tables=table1,table2,table3
    query="where dno=2"
    ..Conventional export/import, you can also consider using datapump if you are using 10g.
    exp username/password parfile=parfile.par log=myexport.log
    imp username/password file=myexport.dmp tables=table1,table2,table3 log=myimport.logRegards

  • SELECT data from two databases

    I have two databases that I need to select data from in a
    single SELECT. Using DWs Advanced window for creating the select I
    don't see any way to select more than 1 Connection. Both databases
    have unique user and passwords but reside on the same server. Any
    idea how I can write a single SELECT to get data from both dbs. I
    assumed it would be similar to selecting data from multiple tables
    within the same db but the connection part is stumping me. Any
    ideas would be greatly appreciated.

    TouchstonePress wrote:
    > Page 48, Developing a Web Database Application . . .
    speaks about making a
    > database with two related TABLES each with the same
    PRIMARY KEY column with
    > which to identify a customer using their unique number.
    That's the basic technique for joining two tables in the same
    database.
    The original poster has tables in different databases that
    have
    different user accounts and passwords.
    Although it's possible to join two databases, you cannot do
    it unless
    you have one user account with the same privileges on both
    databases.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Select Query Using Two Tables

    Friends,
       I need to select some fields from two different tables which doesnot contain any field in common.How to Get this using a select query..
       But there is a field X in table 1 which is equalient to eight char of another field y in table 2.I tried using offset but it is giving error.
    Thanks in Advance
    Regards
    Yamini

    Hello,
    You can use a subquery
    SELECT * FROM SFLIGHT AS F INTO WA_SFLIGHT
        WHERE SEATSOCC < F~SEATSMAX
          AND EXISTS ( SELECT * FROM SPFLI
                        WHERE CARRID = F~CARRID
                           AND CONNID = F~CONNID
                           AND CITYFROM = 'FRANKFURT'
                           AND CITYTO = 'NEW YORK' )
          AND FLDATE BETWEEN '19990101' AND '19990331'.
      WRITE: / WA_SFLIGHT-CARRID, WA_SFLIGHT-CONNID,
               WA_SFLIGHT-FLDATE.
    ENDSELECT.
    or simply query the first table and then the second table with select endselect.
    select * from table a.
       select * from table b into output_table
                     where b-field1 eq a-field2.
    endselect.
    or read the data into one internal table loop at it and then query the other table.
    Regards,
    Shekhar Kulkarni

  • SELECT query from multiple databases

    Hi,
    Is it possible to run a SELECT query using multiple DBs' tables, like outer joining them. One of the DBs is Sybase.
    Thanks in advance

    A TopLink session can span multiple databases if they can be accessed through a single connection. A single select would require the database to handle the aggregation as mentioned in the other post.
    Alternatively TopLink's session broker will support making a single session present persistent types from multiple independent databases. This approach will not support a single SELECT spanning the databases though.
    Doug

  • DIfferent perfromance of same query on two database

    We have our DEV database of 11.2.0.2 on Redhat 5.2, and our production database is a two node RAC of the same version on same ype of servers. Recently, we noticed that when run the same query on the two server, the DEV is 300 to 1000 times faster than on production, while the exec plan cost of DEV is one third of that of PRD. The query is SELECT PERSON_X_IDTY.PERSON_ID AS Facet_ID,1.0 AS Facet_Rank
    FROM (IDTY INNER JOIN PERSON_X_IDTY ON ((IDTY.IDTY_ID = PERSON_X_IDTY.IDTY_ID)))
    WHERE (((IDTY.IDTY_NAME_FIRST IS NOT NULL AND LOWER(IDTY.IDTY_NAME_FIRST) = LOWER('DAVID'))
    AND (IDTY.IDTY_NAME_LAST IS NOT NULL AND LOWER(IDTY.IDTY_NAME_LAST) = LOWER('MILLER'))
    AND (IDTY.IDTY_BIRTH_DATE IS NOT NULL
    AND (IDTY.IDTY_BIRTH_DATE BETWEEN TO_DATE('1981-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS')
    AND TO_DATE('2000-12-31 23:59:59','YYYY-MM-DD HH24:MI:SS')))
    AND (IDTY.IDTY_GENDER IS NOT NULL AND IDTY.IDTY_GENDER = 'M'))) AND ROWNUM<= 300 I know the query looks stupid, but that is generated and we are not to change it.
    The exec plan show indexes are used for both table, but cost on PRD are heavier for index RANGE SCAN or BY INDEX ROWID. The index used for table IDTY is a functional index on IDTY.IDTY_NAME_LAST. I rebuild the indexes used but there is no improvement.
    What parameters or configuration of database I need to check to find the reason for this case?
    Thanks.

    Thank you for all your replies. I did found some difference in init parameters and I restarted Oracle on PRD with a parameter file that is most copied from DEV and make the two as the same as possible. Not solve the problem. After noted that both tables involved are set to PARALLEL 4, I did SQL> alter table IDTY parallel 1;
    SQL> alter table PERSON_X_IDTY patallel 1; The query plan got worse, but the query returned in a time comparable with DEV. THen I re-set parallelism back to 4 SQL> alter table IDTY parallel 4;
    SQL> alter table PERSON_X_IDTY patallel 4; Query performance remained being good.
    Now I have a work around, but hope can got an explaination? The parameters related to parallellism areNAME1                           VALUE_PRD                   VALUE_DEV                  
    fast_start_parallel_rollback    LOW                         LOW                        
    parallel_adaptive_multi_user    TRUE                        TRUE                       
    parallel_automatic_tuning       FALSE                       FALSE                      
    parallel_degree_limit           CPU                         CPU                        
    parallel_degree_policy          MANUAL                      MANUAL                     
    parallel_execution_message_size 16384                       16384                      
    parallel_force_local            FALSE                       FALSE                      
    parallel_io_cap_enabled         FALSE                       FALSE                      
    parallel_max_servers            160                         160                        
    parallel_min_percent            0                           0                          
    parallel_min_servers            0                           0                          
    parallel_min_time_threshold     AUTO                        AUTO                       
    parallel_server                 TRUE                        FALSE                      
    parallel_server_instances       2                           1                          
    parallel_servers_target         64                          64                         
    parallel_threads_per_cpu        2                           2                          
    recovery_parallelism            0                           0    

  • One query on two databases acts differently.

    Hi - this is a doozy. I'd Ask Tom but I think he's busy...
    Database-A = PRODUCTION
    Database-B = TEST
    Both databases run 9.2.0.8, the parameter files in use are the same (so all optimizer settings etc are equal). The table spaces were created equally.
    One difference is that 'A' uses an overloaded SAN and 'B' is on a different one with plenty of bandwidth - though the problem sounds to me like a database optimizer issue, anyway...
    'B' schema was created from export/import of 'A'.
    The schemas have both been analyzed the same way (and both do each night).
    The problem is here that on 'B' the query uses the PK index on one of the tables whereas on 'A' the same query does not use the PK index.
    Note: There are slightly fewer rows in 'B' as 'A' is prod and getting updated.
    Already ruled out:
    optimizer_index_cost_adj: this is set to 100 on both databases and dropping it to 50, 10, 5 and 1 on 'A' does not make the optimizer favour the index.
    Stored outlines may not be an option for this query as we cannot alter the application code and the query changes....
    Any ideas where should I look next?
    Ta!

    Thanks to both the above comments.
    I did think about the data clustering but I kept
    coming back to why the optimizer on 'A' said "I want
    a full table scan" and 'B' says, "oh hey, there's an
    index, I'll use that".This has nothing to do with clustering data.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_1069.htm#i1578369 - look for 'Clustering Factor'
    Also see Note:39836.1
    IN a nutshell - it tells the system how bad an index could be when considering the organization of the table. A table (not index) reorg could easily change the clustering factor, give the same index for the same table with exactly the same data (but different row order) a completely different value.

  • Restrict user SELECT query time on a particular VIEW

    Hi - I am trying to restrict user SELECT statemnet time on a particular view.There is a user called ABC and he is accessing many objects in database.All SELECT statments are fine execept when he query a particular VIEW.That view SELECT causing performance problem.So I am trying to restrict the SELECT query time on a VIEW.
    Can you please help me to achive this task through some SQL command like ALTER USER etc...
    Thanks for your help.

    user2538196 wrote:
    Hi - I am trying to restrict user SELECT statemnet time on a particular view.There is a user called ABC and he is accessing many objects in database.All SELECT statments are fine execept when he query a particular VIEW.That view SELECT causing performance problem.So I am trying to restrict the SELECT query time on a VIEW.
    Can you please help me to achive this task through some SQL command like ALTER USER etc...
    Thanks for your help.It sounds like you are really trying to solve a performance problem with the view. I agree with Justin that the solution to restrict access to the view dynamically sounds unwieldy.
    Consider tuning the view, or perhaps the query using the view. Post the view and see if anyone can help you tune it.

  • What does it mean when the usecounts of Parse Tree for a view is incrementing when a select query is issued against the view?

    I'm using SQL Server 2008 R2 (10.50.4033) and I'm troubleshooting an issue that a select query against a specific view is taking more than 30 seconds consistently.   The issue just starts happening this week and there is no mass changes in data.  
    The problem only occur if the query is issued from an IIS application but not from SSMS.  One thing I noticed is that sys.dm_exec_cached_plans is returning 2 Parse Tree rows for the view -  one created when the select query is issued
    1st time from the IIS application and another one created when the same select query is issued 1st time from SSMS.   The usecounts of the Parse Tree row for the view (the IIS one) is increasing whenever the select query is issued.  The
    usecounts of the Parse Tree row for the view (the SSMS one) does not increase when the select query is issued again. 
    There seems to be a correlation between the slowness of the query and the increasing of the usecounts of the Parse Tree row for the view.  
    I don't know why there is 2 Parse Tree rows for the view.  There is also 2 Compiled Plan rows for the select query.  
    What does the Parse Tree row mean especially the usecounts column?

    >> The issue just starts happening this week and there is no mass changes in data.  
    There might be a mass changes in the execution plan for several reason without mass changes in data
    If you have the old version and a way to check the old execution plan, and compare to the new one, that this should be your starting point. In most cases you don't have this option and we need to monitor from scratch.
    >> The problem only occur if the query is issued from an IIS application but not from SSMS.
    This mean that we know exactly what is the different and you can compare both execution plan. once you do it, you will find that they are no the same. But this is very common issue and we can know that it is a result of different SETting while connecting
    from different application. SSMS is an external app like any app that you develop in Visual studio but the SSMS dose not use the Dot.Net default options.
    Please check this link, to find the full explanation and solutions:
    http://www.sommarskog.se/query-plan-mysteries.html
    Take a look at sys.dm_exec_sessions for your ASP.Net application and for your SSMS session.
    If you need more specific help, then we need more information and less stories :-)
    We need to see the DDL+DML+Query and both execution plans
    >> What does the Parse Tree row mean
    I am not sure what you mean but the parse tree represents the logical steps necessary to execute the query that has been requested. you can check this tutorial about the execution plan: https://www.simple-talk.com/sql/performance/execution-plan-basics/ or
    this one: http://www.developer.com/db/understanding-a-sql-server-query-execution-plan.html
    >> regarding the usecount column or any other column check this link:
    https://msdn.microsoft.com/en-us/library/ms187404.aspx?f=255&MSPPError=-2147217396.
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • How to dynamically add field name in where clause of select query in web dynpro?

    Hello,
    Can any body tell me how i can use select query with dynamic wheere condition.
    i have a requirement like there are multiple input fields  and i want to select data from two database
    and condition may vary .

    Hi
    In the where clause you need to write like
    WHERE NAME LIKE 'DE%'
    Regards
    Sudheer

  • Oracle SQL Select query takes long time than expected.

    Hi,
    I am facing a problem in SQL select query statement. There is a long time taken in select query from the Database.
    The query is as follows.
    select /*+rule */ f1.id,f1.fdn,p1.attr_name,p1.attr_value from fdnmappingtable f1,parametertable p1 where p1.id = f1.id and ((f1.object_type ='ne_sub_type.780' )) and ( (f1.id in(select id from fdnmappingtable where fdn like '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#%')))order by f1.id asc
    This query is taking more than 4 seconds to get the results in a system where the DB is running for more than 1 month.
    The same query is taking very few milliseconds (50-100ms) in a system where the DB is freshly installed and the data in the tables are same in both the systems.
    Kindly advice what is going wrong??
    Regards,
    Purushotham

    SQL> @/alcatel/omc1/data/query.sql
    2 ;
    9 rows selected.
    Execution Plan
    Plan hash value: 3745571015
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    | 1 | SORT ORDER BY | |
    | 2 | NESTED LOOPS | |
    | 3 | NESTED LOOPS | |
    | 4 | TABLE ACCESS FULL | PARAMETERTABLE |
    |* 5 | TABLE ACCESS BY INDEX ROWID| FDNMAPPINGTABLE |
    |* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    |* 7 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
    |* 8 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    Predicate Information (identified by operation id):
    5 - filter("F1"."OBJECT_TYPE"='ne_sub_type.780')
    6 - access("P1"."ID"="F1"."ID")
    7 - filter("FDN" LIKE '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#
    8 - access("F1"."ID"="ID")
    Note
    - rule based optimizer used (consider using cbo)
    Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    0 bytes sent via SQL*Net to client
    0 bytes received via SQL*Net from client
    0 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    9 rows processed
    SQL>

  • How can i update rows  in a table based on a match from a select query

    Hello
    How can i update rows in a table based on a match from a select query fron two other tables with a update using sqlplus ?
    Thanks Glenn
    table1
    attribute1 varchar2 (10)
    attribute2 varchar2 (10)
    processed varchar2 (10)
    table2
    attribute1 varchar2 (10)
    table3
    attribute2 varchar2 (10)
    An example:
    set table1.processed = "Y"
    where (table1.attribute1 = table2.attribute1)
    and (table1.attribute2 = table3.attribute2)

    Hi,
    Etbin wrote:
    Hi, Frank
    taking nulls into account, what if some attributes are null ;) then the query should look like
    NOT TESTED !
    update table1 t1
    set processed = 'Y'
    where exists(select null
    from table2
    where lnnvl(attribute1 != t1.attribute1)
    and exists(select null
    from table3
    where lnnvl(attribute2 != t1.attribute2)
    and processed != 'Y'Regards
    EtbinYes, you could do that. OP specifically requested something else:
    wgdoig wrote:
    set table1.processed = "Y"
    where (table1.attribute1 = table2.attribute1)
    and (table1.attribute2 = table3.attribute2)This WHERE clause won't be TRUE if any of the 4 attribute columns are NULL. It's debatable about what should be done when those columns are NULL.
    But there is no argument about what needs to be done when processed is NULL.
    OP didn't specifically say that the UPDATEshould or shouldn't be done on rows where processed was already 'Y'. You (quite rightly) introduced a condition that would prevent redo from being generated and triggers from firing unnecessarily; I'm just saying that we have to be careful that the same condition doesn't keep the row from being UPDATEd when it is necessary.

  • Creation of Database View , Projection View

    Hi ABAP EXPERTS,
    Can anyone plz send me the step by step creation of DATABASE and PROJECT VIEWS. Just steps by step explanation will do , screen shots will be more than appreciated.
    Kind Regards,
    Sunil Ranal.

    Database View (SE11)
    Database views are implement an inner join, that is, only records of the primary table (selected via the join operation) for which the corresponding records of the secondary tables also exist are fetched. Inconsistencies between primary and secondary table could, therefore, lead to a reduced selection set. In database views, the join conditions can be formulated using equality relationships between any base fields. In the other types of view, they must be taken from existing foreign keys. That is, tables can only be collected in a maintenance or help view if they are linked to one another via foreign keys.
    Check this link for database view creation.
    http://help.sap.com/saphelp_40b/helpdata/en/cf/21ed06446011d189700000e8322d00/content.htm
    Projection View
    Projection views are used to suppress or mask certain fields in a table (projection), thus minimizing the number of interfaces. This means that only the data that is actually required is exchanged when the database is accessed. A projection view can draw upon only one table. Selection conditions cannot be specified for projection views.
    Check this link for Projection view creation.
    http://help.sap.com/saphelp_nw70/helpdata/en/cf/21ed20446011d189700000e8322d00/content.htm
    Regards,
    Maha

Maybe you are looking for

  • Changing multiple songs on a playlist causes app to crash?

    Whenever I have a playlist that I want to delete around 10 songs from and I start deleting them, the Music App crashes and the playlist is returned to how it was before I started editing it. This also happens if I move songs around and then delete so

  • Question on BLOCK in BPM

    Hi, everybody. I have a question when develop a BPM. In my BPM scenario, I have a RECEIVE, a RECEIVER DETERMINATION, a BLOCK, and in the BLOCK I have a SEND.(all of these are configure as this sequence) I configurate it, and have test. The BPM log sh

  • Strange system-wide bahviour

    I don't know if this is a virus, or what. I've noticed two strange phenomena over the past several days. 1. Under the apple menu, I get reduplication of Restart, Shutdown and Log out. The bottom of the menu goes: "Sleep Restart... Restart Shut Down..

  • Incremental update or Monthly update AW

    Hi, My client is using OWB to build and deploy AW cube. This database will have 12 Scenarios and my scenario dimension have N_0 to N_11 unique values. Each scenario is representative of 36 month of history and 18 months of future time buckets to hold

  • I just installed creative cloud and none of the installed apps will work!

    they open for a couple seconds and then say they stopped working! what do I do? I have deinstalled all of Adobe product and reinstalled everything I payed for "renting" the cloud. it's been going on for 4 days and I'm kinda need photoshop for school