Views and corelated query

Hi ,
1> When are views useful?(scenarios where u could use)
2> when are corelated subqueries used?(scenarios where u could use)
Thanks in advance

When are views useful?
A view is simply the representation of a SQL statement that is stored in memory so that it can easily be re-used. For example, if we frequently issue the following query
SELECT empid FROM emp;
I might well want to make this a view (the reality is that we would probably never create a view for a statement this simple but we wanted to use an easy example).
To create a view use the create view command as seen in this example
CREATE VIEW view_emp
AS
SELECT empid FROM emp;
This command creates a new view called VIEW_EMP
Benefits of Oracle Views
* Commonality of code being used.
* Security.
* Predicate pushing
when are corelated subqueries used?(scenarios where u could use)
A correlated subquery is a subquery that uses values from the outer query. The Oracle database wants to execute the subquery once and use the results for all the evaluations in the outer query. With a correlated subquery, the database must run the subquery for each evaluation because it is based on the outer query’s data.
SQL> select
2 book_key,
3 store_key,
4 quantity
5 from
6 sales s
7 where
8 quantity < (select max(quantity)
9 from sales
10 where book_key = s.book_key);
BOOK_K STOR QUANTITY
B101 S101 1000
B102 S102 10
B102 S103 200
B116 S105 100
B101 S105 8000
B109 S109 100
81 rows selected.
In the example above, the subquery references the book_key in the outer query. The value of the book_key changes by row of the outer query, so the database must rerun the subquery for each row comparison. This has a significant performance impact on the execution time of the query, and for that reason, correlated subqueries should be avoided if possible.
The outer query knows nothing about the inner query except its results. For that reason, the outer query cannot reference any columns in the subquery. However, the subquery has access to the outer query and can reference outer query columns, thus the correlated subquery.

Similar Messages

  • Difference btn View and a Query

    Hello there,
    I am having difficulty conceptualizing the difference btn a view and a query.
    I searched the forum but did not get very useful information.
    Can someone explain in plain language how a view is different from a query?
    Thank you.

    Hi Kara,
    Have you seen this thread:
    Re: What is view
    And also this one:
    Re: Difference: query- report- view- workbook
    Hope this helps...
    Message was edited by: Bhanu Gupta
    Thanks for pointing that out. I have changed them, plese try again.

  • When to go for generic extraction using view and infoset query?

    Hi,
                        Can anyone clarify me when we should go for generic extraction using view and when we should go for generic extraction using infoset query....
    Also what is the difference between view and infoset?
    I tried but could not find out....
    Regards,
    Kalyani.

    Hi Kalyani,
    We normally go for View or infoset when the data to be fetched in BW is distributed in different tables in SAP R/3.
    Had the data been available in one table we can easily build our datasource on that table but if there are more tables then its not possible to do it without Views or Infosets. You can use Function Modules to build your datasource in case it involves complex logic to figure out the data from various tables.
    Depending upon the table relationships we create view and include various fields from these tables in that view. Same is with the Infosets, you can have more flexible options like Outer Join, left outer Join etc.
    Regards,
    Pratap Sone

  • Generic Extractors for HR Reports using views and Infoset Query

    Hi Friends... I am working to come out with the HR reports in BW for the HR reports which are already there in R/3. The HR reports in R/3 are created based on Infoset Query.I could not find any standard business content cubes which can give me these reports.
    1)So please can anyone give me step by step approach so to create a generic extractors based on Infoset Query.
    2)And also how to populate the data into the fields of the generic extractor which is created by Infoset Query( Please provide any sample ABAP code if available)
    3)can anyone give me step by step approach so to create a generic extractors based on View/Table.
    4)And also how to populate the data into the fields of the generic extractor which is created by View/Table( Please provide any sample ABAP code if available)
    Thanks

    Hi Kalyani,
    We normally go for View or infoset when the data to be fetched in BW is distributed in different tables in SAP R/3.
    Had the data been available in one table we can easily build our datasource on that table but if there are more tables then its not possible to do it without Views or Infosets. You can use Function Modules to build your datasource in case it involves complex logic to figure out the data from various tables.
    Depending upon the table relationships we create view and include various fields from these tables in that view. Same is with the Infosets, you can have more flexible options like Outer Join, left outer Join etc.
    Regards,
    Pratap Sone

  • Generic Extraction - query view and infoset query difference

    Hi Guys,
    I want to know the Generic datasource difference between Extraction from view and Extraction from Query .I have read some threads and documents, still i am not getting the exact difference.
    My understanding :
    Views: combination of tables to view the end result , we use views.
    Infoset query also with help of SQ01, 02, 03  : we combine tables to see the result.
    both use primary key to select the data.
    Please help me.
    Thanks ,
    Nithi.

    Hi Nithi ,
    When we build the datasource on the View
    View is basically a table in which you can take data from many table combniation  .
    in view you can specify the table join condtion and selection condtion
    View data gets updated as the data in the source table gets updated
    When we build the datasource on the Infoset
    Data source str gets filled from the infoset query .you need to use SQ01 and Sq02 transaction for this
    in infoset you can define the tables from which you want to read the date .There is also facilty to write ABAP code which will process the data and fill the the data source str using infoset query
    infoset query read the data from infoset and transfer to data structure
    Thanks
    Rajendra

  • View and the query for the view giving different datasets

    I have a view created with the below syntax.
    CREATE OR REPLACE FORCE VIEW vw_name (/*column names*/ )
    AS SELECT /*column names*/ from tables
    When I execute the query with which the view is constructed , I m getting different data set which contains 4690 rows
    and when I exeute the view I m getting dataset which contains only 4657 rows.
    Can you please explain why the differnce in count when the source for both is the same.

    Can you please explain why the differnce in count when the source for both is the same.Answer should be one of the following
    1. The two query are not same
    2. The table data has been modified
    3. You are seeing at the wrong thing (manual error)

  • Difference between inline view and WITH

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

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

  • Difference between sub-query and corelated subquery

    Hi,
    can anyone please give me the clear difference between sub-query and coreleated subquery with an example.
    I am very much confused with the both.
    Also please let me know in which cases/situation these are used.
    Thanks,

    Basically Sub Query is Query within Query. There are different type of SubQuery.
    1. Scalar Sub Query
    Query that is totally independent from the main query.
      select empno, (select count(*) from emp) total_emp
        from emphere the subquery is totally independent of the main query.
    2. Corelated Sub Query
    The sub query reffers to the main query.
      select empno, (select deptname from dept d where e.deptno = d.deptno) deptname
         from emp e3. Inline view
    A sub query that is used as a table or view in a SQL
    select *
      from (select empno, deptname
              from emp e, dept d
             where e.deptno = d.deptno)
    where sal > 100

  • How to Create a View of a Query and assign it into my web template?

    Hi All,
    I need to create 3 views for my query and show that on my web template. I have never done this before. Can you please let me know step-by step procedure to create views for a query and how to show it on my WAD report?
    Thanks,
    Satyam

    Hi Satyam,
    Include the Dropdown Box web item in your web template. In the Web Item Parameters tab, select the Data Binding type as Query View Selection. Assign the Dataprovider from Selection of Query Views button below the Data Binding Type. You also have the option to Display Specific list of Query Views or all views based on that Query. For this you have to choose Selection of Query Views button. Here you can turn on Specific List of Query Views checkbox and select the Views depending on your requirement.
    Regards,
    Hari.
    Edited by: Hari Krishnan K on Aug 18, 2010 2:33 PM

  • View and Navigate through PDF´s on a DB2 SQL Query

    Hello,
    We need to create a windows forms application in .Net to view and navigate through pdf´s that are located on a DB2 Express SQL database using the Acrobat SDK or PDF Library.
    The idea would be to query the SQL table and the result we should be able to view and navigate through by using the viewer procedures from the SDK without having to send the PDF files to a temporary folder on the hard drive.
    So for example, if the query returned 20 pdf´s, we should be able to navigate and view these pdf´s on a windows form connecting directly to the query via streams or a data source.
    We assume that what we need is some sort of procedure to connect the viewer to the query through a data source.
    Please help us to research about this and determine if this is possible.
    Thanks.

    Hello lrosenth and thanks for your reply.
    Our goal is to develop a Windows Form in .Net where we could view the pdf without launching Acrobat.
    I guess you mean that we should develop a plugin in C/C++ for Acrobat, but that is not what we intend.
    Is there a way to develop a function in .Net that will allow a Windows Form to read a stream with a pdf using Adobe ´s SDK or PDF´s library?
    If so, would you be so kind as to point us to some reading material?
    Regards

  • Diff Between Saved Query Views and Work Books

    Hi..
    Can some one explain me the diff betwen Saved Query views and Workbooks interms of their use, and operation..
    thanks..
    kishore

    hi kishore,
    We use workbooks for excel formating,like font changes, lay out changes etc...
    Workbooks into which queries are inserted are no different in appearance than other Excel workbooks.
    They can be saved as files, copied, sent and (using Excel functions) edited however you like and even supplemented with other data.
    Views are primarily used for BW Web Reports, it is similar to the concept of workbooks is for BEx.A local view can be accessed only within a workbook in which it was saved, where as a global view can be accessed globally in the system, it is not attached to a workbook. Only Global view can be used in BW Web Templates.
    u can seee the help doc for more details:
    http://help.sap.com/saphelp_nw04s/helpdata/en/0d/af12403dbedd5fe10000000a155106/content.htm
    http://help.sap.com/saphelp_erp2004/helpdata/en/3a/89883989676778e10000000a11402f/content.htm
    bye
    shameem

  • Writing an sql script to query a calculation view  and an attribute view inside a calculation view

    Hi,
    I was trying to query a calculation view with sql , and as one of the input parameters i was trying to give a query over an attribute view
    So my sql will look like this
    SELECT * FROM "MyApp.calculation_views::GET_CHECKLIST_FOR_ACCOUNT"('PLACEHOLDER' = ('$$ACCOUNT_ID$$', '1','$$CHECKLIST_ID$$',' SELECT CHECKLIST_ID FROM "MyApp"."CHECKLIST_PRODUCTS" WHERE PRODUCT_ID = 5'));
    So as an input to $$CHECKLIST_ID$$   i wanted to give an id selected from checklist products table where products id is passed as an input
    but this is not working, i am getting syntax error at the $$CHECKLIST_ID$$ there i can only pass values like  $$CHECKLIST_ID$$, '1'
    Please help me to figure out which  is the correct syntax  i tried putting the sql statement to get the checklist_id in '' but it too didnot work

    I'm not sure you'll be able to do a SELECT subquery directly in the placeholder definition, but you can create another calc view (scripted) as a wrapper to your original calc view and use a scalar variable to pass the parameter over.
    Try this as the base code for your second calc view:
    var_id VARCHAR(10);
    BEGIN
         SELECT CHECKLIST_ID INTO :var_id FROM "MyApp"."CHECKLIST_PRODUCTS" WHERE PRODUCT_ID = 5;
         var_out = SELECT * FROM "MyApp.calculation_views::GET_CHECKLIST_FOR_ACCOUNT"
              (PLACEHOLDER."$$ACOUNT_ID" => 1, PLACEHOLDER."$$CHECKLIST_ID$$" => :var_id);
    END
    You could even create input parameters in the second Calc View for the Account Id & Product Id (which are currently hard coded in your code below).
    Best,
    Henrique.
    PS: avoid using SELECT * for the var_out in the scripted calc view. It's better, from a code maintenance perspective, to explicitly define the columns you're outputting.

  • Query to find the Views and synonyms that are accessing through db_link

    HI all,
    Oracle 10g
    I need a Query to find the Views and synonyms that are accessing through db_link.
    ie.
    database A have the db_link to database B through a schema A
    now i need to find what are the Synonyms and views that are accessing through db_link either directly or indirectly..
    regards,
    Deepak
    Edited by: Deepak_DBA on Dec 10, 2010 5:38 PM

    On the second database (B) use this query to find the SQL which used by the schema A (DB LINK USER). Check the SQL_FULLTEXT column.
    select sql_fulltext,sql_id,module,parsing_schema_name,parsing_user_id,first_load_time,loads,users_executing,rows_processed,plsql_exec_time,sorts,fetches,invalidations,parse_calls,cpu_time,elapsed_time,disk_reads,buffer_gets
    from V$sqlarea
    where parsing_schema_name = 'A' --and to_char(first_load_time,'dd/mm/yyyy') like  '%11/08/2007'
    order by first_load_time desc;
    Regards
    Asif Kabir

  • How to prevent end user to create a Query View and save back to BW Server?

    Dear All :
    Do Someone know that how to setup authorization for Bex Query View Creation? We want to prevent end user to create a Query View to save back to BW Server his favorite folder. when our user run Bex Query, he can base on this query and use Bex Analyzer's save function to save a Query View and save into his favorite folder.
    My question is :
    1. Can we set up a Authorization to prevent end user to save Bex Query View?
    2. Or can I remove Save function from Bex Analyzer to prevent end user use save function, But Developer should not to be prevent .
    Thanks for all of your kindly response.
    Best Regard
    Lawrence Kuo

    Hi.
    Yes, you can do it like you outline in your point 1):
    You need to use the authorization object S_RS_COMP for this. This object let's you control what parts/components of a query the user can do stuff to. So, in your case, you need to have a role for the users, where you do not grant create-access to the component QVW, and then you need another role for developers, where you grant full access or whatever you need for your developers.
    See [this post|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a6c54319-0e01-0010-20a4-fb81ad32f330?QuickLink=events&overridelayout=true&5003637661135] and the [SAP Help entry|http://help.sap.com/saphelp_nw70/helpdata/en/80/1a6859e07211d2acb80000e829fbfe/content.htm].
    You will also need to use the authorization object S_RS_COMP1. If you already have a productive system with users doing reporting, both objects will be maintained in one of the roles already.
    You also want to consider using the object S_RS_PARAM to allow users to create variants for the variabel screen.
    Good luck.
    Jacob

  • How to retrieve Task Lists from All Subsites to the Parent Site and display in Grid view using CAML Query

    How to retrieve Task Lists from All Subsites to the Parent Site and display in  Grid view using CAML Query + object model

    do u just want task list or items under task list for all subsites
    for items use spsitedataquery ref
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.aspx use recursive to get it from alll subsite under site collection
    for tasklist only u can a simply use a for loop to find in all subsite
    Manish Sati

Maybe you are looking for

  • Welcome to the Kanaka for Mac Forum

    Welcome to the Kanaka for Mac forum. See the press release: http://www.novell.com/news/press/201...available.html Thanks for adding your experiences, knowledge, and questions here in the forums.

  • Drill Down Help

    Greetings APEX Users and Experts, I want to create a drill down on my report, but I don't want to create two tables and use a join to do it. I would like it to be from a single table. Is that possible? If so, how? Thanks! David Edited by: Bob Sacaman

  • Force width change of readonly column

    Within a drag and drop ADF table, using an outputtext component, the column is shrunk to the width of the contents, likewise if I use an inputtext with the readonly attribute set to true. How can I force a readonly column to be a width greater than t

  • Suppresion of NON-ZERO numbers in Key Figures

    Dear All, How do we suppress Non - zero values for multiple Key figures in Query Designer? Please suggest some method. I have tried conditions and it does not work for individual cells....It works for an entire row..... Thanks, Naveen

  • Silent install parameters for Mgmt Studio (from SQL 2012 SP1 Express)

    Hi All, I'm looking to incorporate the installation of SQL Management studio ONLY from the SQL 2012 Sp1 Express bundle, into System Centre Configuration Manager. I need the silent installation options to install all features for it. File used - SQLMa