Defining a view to point latest partition

Hi
I have a partition table on month-year. The partition names are like P201007, P201008, P201009 etc.
Now I want to create a view which will always point to the latest partition.
Is there any SQL command to do that?
Thanx

You can specify a partition in a query, but it is not a predicate and it can not be bound. So I think you will not be able to do it directly in a view.
That is, you can say
select * from your_table partition (P201009);but you can not say
select * from your_table where partition='P201009';or anything like that.
You can certainly create a view that specifies a single partition, but the partition you want would change from month to month. So you would have to redefine the view every month. That would not be a good design.
Partitions are intended to be pretty transparent to the user. The optimizer can decide to operate on a single partition if it determines that doing so is compatible with the query.
You may be able to query ALL_TAB_PARTITIONS , where HIGH_VALUE holds the maximum value allowed in the partition. PARTITION_POSITION can be used to find the partition with the highest and next-highest values. If you wrap this in a function, for example, then you could write a view that says
create or replace view your_table_latest as
select * from your_table
where effective_date >= get_date_of_lastest_partition_fnc('YOUR_TABLE');Note that this does not directly specify a partition - it has a date predicate which should be used by the optimizer to limit its scans etc. to the latest partition.
But... having said all that, I would suggest a different approach. Don't try to figure out the latest date by examining the partitions. It is evident that, somewhere in this process, you had to know which date to create the new partition for. So save that date in a table somewhere (possiibly a table with one row per table you are managing here) and use that in your view:
create or replace view your_table_latest as
select t.* from your_table t, lastest_refresh r
where t.effective_date = r.latest_refresh_date and r.table_name = 'YOUR_TABLE';

Similar Messages

  • Can we define a view that refers to 50 tables?

    Hi,
    I've a problem at hand and I'm not sure what the right solution I can adopt.
    There is an application which hits the DB (v11.2) for accessing a single view 'XVIEW'. This view has a simple sql & join which is based on two tables XTABLE1 and XTABLE2.
    Now, the new version of the schema that has got released has split XTABLE2 into 50 different tables each having a same structure. To the fix the issue, there are two solutions I could think of:
    1. Create 50 views on top of 50 tables, and fix the Application to refer to these 50 new views; note: the application has hundreds of references and this has a significant work involved.
    2. Rewrite XVIEW to refer to 50 tables. This will avoid changing the application, however I'm not sure if this is feasible and will have a decent performance.
    I would like to go for solution 2 as it involves significantly less effort, but not sure how best i should define the view, single the 50 table structure is the same can I just union all of them?
    Thanks for the help.

    Hi,
    Hozy wrote:
    Frank, thanks for helping me out.
    What you are suggesting is that I should recreate the view XVIEW which does union all (as the rows will be unique) of the 50 tables, however performance will be an issue unless I can create a materialized views.
    What I know of materialized views is that it's used for static, pre-computed type of data. A materialized view is pre-computed; that's what makes it faster. The time and effort spent in doing the UNION is shifted from the time when you do the queries to the time when you refresh the materialized view. Whether that is more or less total time depends on how often you query the view, and how often you refresh it. At any rate, the performance when you do the queries will be as good as possible.
    Materialized views ar often used in data wharehouses, where then data may only change once a month, but they are also often used in situations like yours, where the data changes every day, or even more frequently.
    In my case, the data in few of the 50 tables might change once every 24hrs and it all comes at one time. The queries that hit XVIEW should get the latest data. Is there a way I can define a materialized view which will pick up the new data in the base 50 tables?I see; you have some job that runs at, say, 2:00 am every morning, and changes some, or maybe all, of the 50 tables. You might refresh the materialized view at, say, 4:00 am every day, or at some time when you're sure that the changes to the base tables are complete. Any query that uses the materialized view between 2:00 and 4:00 am will get stale data.
    You could, alternatively, make the materilaized view refresh whenever any of the base tables change, but this uses more resources, including your time and effort setting it up.

  • Defining and Viewing BLOB Data in Oracle Application Express 3.2

    Hello All,
    There is a nice tutorial for working with images in Application Express 3.1 entitled "Defining and Viewing BLOB Data in Oracle Application Express 3.1". I have 3.2 and I am finding that I can't follow this tutorial... Is there any similar how to for 3.2?
    Thank you,
    Daniel

    Hi,
    I have just gone through the first steps in my OTN workspace app, and I do get the Implementation option (showing Interactive or Classic). In fact, my page at this point matches exactly the image shown in the tutorial.
    My OTN workspace app uses Apex version 3.2. The Interactive reports are relatively new, so older versions of Apex would not have this option. But you say that you are using version 3.2? If you just try to create a report page on, say, EMP, do you get the option to select Interactive or Classic?
    Andy

  • How to define a view on a table function

    I have a defined a pipelined table function in a package and can return data from it using:
    select * from table(mtreport.FN_GET_JOBS_FOR_PROJECT(?));How can I define a view on this so that users can select from it without having to know to use the 'table' syntax?
    select *
    from   vw_jobs_for_project
    where id = ?I've tried this, but it doesn't work
    CREATE OR REPLACE VIEW vw_jobs_for_project (PROJECT_ID, NAME) AS
    SELECT     PROJECT_ID, NAME
    FROM     table(mtreport.FN_GET_JOBS_FOR_PROJECT(PROJECT_ID));
    ERROR at line 3:
    ORA-00904: "PROJECT_ID": invalid identifier

    views do not accept input parameters in the way that you want to use. you can define a CONTEXT parameter, but the users would need to set the context value before selecting from the view, so you'll still need to train them to do something new.
    example:
    create or replace context my_context using pkg_context;
    <br>
    create or replace package pkg_context is
      procedure set_context(p_parameter in varchar2, p_value in varchar2);
      function get_context(p_parameter in varchar2) return varchar2;
    end;
    show errors
    create or replace package body pkg_context is
      CONTEXT_NAME constant all_context.namespace%type := 'MY_CONTEXT';
      procedure set_context(p_parameter in varchar2, p_value in varchar2) is
      begin
        dbms_session.set_context(CONTEXT_NAME, p_parameter, p_value);
      end;
      function get_context(p_parameter in varchar2) return varchar2 is
      begin
        return sys_context(CONTEXT_NAME, p_parameter);
      end;
    end;
    show errors
    create or replace view tree_view as
    select level lvl, chid
    from tree
    connect by prior parid=chid
    start with chid = sys_context('MY_CONTEXT','CHID');
    -- at runtime
    exec pkg_context.set_context('CHID', 14)
    select * from tree_view;

  • Since I can't view my points history...​..

    Can a specialist please let me know how many points I have pending and an estimated date of when I'll be receiving my points since I can't view anymore on bestbuy.com. I want to know if I'll be receiving points for a pre order and a purchase that I made on 9/27. When can we expect to be able to view our history. I figured since a lot of people are asking for this feature it would of been on the top of the to do list for bestbuy. I wouldn't be asking but I had problems in the past with receiving points.
    Solved!
    Go to Solution.

    Good morning Dracky,
    As long as your BestBuy.com and My Best Buy accounts are linked, you should be able to login to BestBuy.com right now and view your points/purchase history.  I posted an update to the forum on 10/1/2014 once the points/purchase history feature had officially been added to BestBuy.com.  You would want to login to BestBuy.com, click on "Account Overview" or "Rewards" under the My Best Buy tab, and then click on either "Points History" or "Purchase History."
    From what I can see, you do have a couple transactions from 9/27/2014 that are currently pending in your account.  If you would like to discuss your account in additional detail, then please feel free to send me a private message and I will see what I can do to help.  You can send a private message by logging into the forum and clicking on the yellow envelope located at the top of the page.
    *UPDATE* - Manage your My Best Buy account on BestBuy.com
    Thank you for posting to the forum!
    Derek|Social Media Specialist | Best Buy® Corporate
     Private Message

  • Define multiple views

    I'm trying to build a simple app which has multiple views. When the user clicks on the worksetItem I want to change the view, and display an other table in the shell. But I dont know how can I define another view, and add it to the shell.

    Hy Venkatesh
    I've found the link too that you've posted.
    I've used the following tutorial to buld the base of my app:
    Developing a simple List based SAPUI5 Application
    And now I want to spereate the BP data, and create a subview for it, and do the same for Sales, than load it to the main view, when the user clicks on the menu. But I dont really know how to write my own view. (what to write to the "createContent()").

  • Using orderby clause when defining a view

    Hi,
    In oracle documentation they specified the query that defines a view cannot contain the ORDER BY or FOR UPDATE clauses.
    But according to the book oracle DBA certification exam (by JASON S.COUCHMAN) the query that defines a view can contain the ORDER BY clause.
    Can anyone help me clarify, whether we can use order by clause in defining a view

    Hi,
    THere are two classifications for views:simple and complex.A complex view can contains functions or groups of data.Use syntax:
    Create view dept_sum_vu
    (name,minsal,maxsal,avgsal)
    as select d.name,MIN(e.sal),MAX(e.sal),AVG(e.sal)
    from emp e,dept d
    where e.deptno=d.deptno
    group by d.dname
    Hope it will work.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by moturideepa([email protected]):
    Hi,
    In oracle documentation they specified the query that defines a view cannot contain the ORDER BY or FOR UPDATE clauses.
    But according to the book oracle DBA certification exam (by JASON S.COUCHMAN) the query that defines a view can contain the ORDER BY clause.
    Can anyone help me clarify, whether we can use order by clause in defining a view<HR></BLOCKQUOTE>
    null

  • DHTML Viewer Extension Points

    Hi all,
    I have two tasks to achieve with the DHTML VIewer Extension Points.
    First task is to implement a custom prompt handling with some special behaviour.
    What I already have is the integration of my struts2 action and jsp page in the left pane.
    -> What is missing: How can I force the viewer to reload the document instance from storage token on which I did set the prompts?
    Second task is, to send a refreshed document to a user.
    The steps are to open a deski or webi report, hit refresh, set the prompts and then send the document with values to a user.
    What I do right now is to get the documentInstance from (refreshed) storageToken, call saveAs(...) and use the properties() to get the ID of the IInfoObject which I send to the user - but with using the IInfoObject, I still send the document like it was exportet to the repository.
    Any ideas?
    Thanks in advance!
    Jan

    Hi Ted,
    thanks for your response I finally found a way to do what I want to do, at least refreshing the document.
    Most of it was in processAnalyzePanel.jsp.
    Thanks again.
    Regards
    Jan

  • Why users with rights defined as View cannots see the data of the form ?

    Hi,
    I have a nice form page. My application has an authorization scheme with an authentification function : return acl_custom_auth. It is working well. I have defined users with Edit, View and Admin rights. Unfortunately on a form, if the user is defined as "View" he cannot see the data, he only sees the item but their content is not diplayed. I don't understand why. I would like him to see the data.
    The authorization scheme of the page is "Access control -view" as well as the items of the page.
    Do you have any idea of what is going wrong here ?
    Thank you for your kind help !
    Regards,
    Christian

    Another thing that can be done though mon tech-savy people may not know about it.
    Locate a group of PDF's and select at least 5-6 of them as a Group.
    hold down Option key while click on file menu
    Click on Get info.
    One window will open for the group.  in Mountain Lion (OSX.8.2) the term will change to Show Inspector.
    click on the  button next to Open With.
    choose either Reader or Acrobat.
    just bellow is a question Use Acrobat (or Reader) to open all files of this type, Click on it and choose yes.
    Make sure you have a mix of Adobe PDF's and Preview PDF/s for  this to work. If it wasn't good for opening other Type Files I'd compress Preview and throw the original away. It’s a nusiance.

  • Why can't Adobe add the feature of viewing focus points? This is an obvious,  common sense feature that Adobe Engineers must understrand how to do, No?

    Why can't Adobe add the feature of viewing focus points? This is an obvious,  common sense feature that Adobe Engineers must understrand how to do, No?
    I've seen this requested in several past Lightroom versions.
    Is Adobe not addressing this basic feature for a reason?, I mean, even Aperture has this feature, it can't be that hard to add? Can it?
    Maybe Adobe isn't reading the feature request?

    Honestly, I am hardly qualified to even guess - there are tons of bugs reported that would be easy to fix, but aren't, features that would be useful and easy enough to implement, but aren't. Things like focus points which seem like a no brainer but are never implemented - your guess is as good as mine..
    But to be clear: focus points are different for different cameras, and are stored in proprietary metadata. - not impossible to get at, obviously, but requires some programming/maintenance..
    Worth noting: Apple is shutting down their Aperture business. Yeah, they support focus points and all kinds of good stuff, but I guess Aperture isn't a real money-maker for them (lotsa maintenance work, but not a lot of revenue) - relatively small market.
    Adobe has been working on Revel, and Lightroom Mobile.., instead of focus points (and bug fixes, and...) - my guess: that's where the money is, or where they think it is.
    Cheers,
    Rob

  • How do I get the range of my latest partition

    Hello All,
    I have a range partitioned table. I would like to know the value of my latest partition. I tried using
    SELECT high_value FROM user_tab_partitions WHERE table_name = 'TBL_NAME' ORDER BY partition_name DESC  but no luck.
    I have partitions like
    list_cmpgn_201101 values less than 64000
    list_cmpgn_201112 values less than 65000
    list_cmpgn_201201 values less than 66000.
    It should give me 66000. Since that is my latest partition.
    Thx
    Shank.
    Edited by: SamFisher on Feb 2, 2012 10:42 AM

    You need to use PL/SQL:
    SQL> select  high_value
      2    from  user_tab_partitions
      3    where table_name = 'RANGE_SALES'
      4  /
    HIGH_VALUE
    TO_DATE(' 1998-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TO_DATE(' 1998-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TO_DATE(' 1998-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TO_DATE(' 1999-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TO_DATE(' 1999-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TO_DATE(' 1999-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TO_DATE(' 1999-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TO_DATE(' 2000-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TO_DATE(' 2000-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TO_DATE(' 2000-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TO_DATE(' 2000-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    HIGH_VALUE
    MAXVALUE
    12 rows selected.Now:
    create or replace
      type DateList
        as
          table of date
    declare
        v_DateList DateList := DateList();
        v_max_high_value date;
    begin
        for v_rec in (select high_value from user_tab_partitions where table_name = 'RANGE_SALES') loop
          if v_rec.high_value != 'MAXVALUE'
            then
              v_DateList.extend;
              execute immediate 'begin :1 := ' || v_rec.high_value || '; end;'
                using out v_DateList(v_DateList.count);
          end if;
        end loop;
        select  max(column_value)
          into  v_max_high_value
          from  table(v_DateList);
        dbms_output.put_line('Table RANGE_SALES max high value is ' || to_char(v_max_high_value,'MM/DD/YYYY HH24:MI:SS'));
    end;
    Table RANGE_SALES max high value is 10/01/2000 00:00:00
    PL/SQL procedure successfully completed.
    SQL>SY.

  • Webi DHTML Viewer Extension Points

    Hi
    Is it possible to hide the Fold-Unfold Toolbar feature via the use of Webi DHTML Viewer Extension Points?  I've tried various methods including hide_feature("FOLD_TOOLBAR") or hide_feature("FOLD-UNFOLD_TOOLBAR") but it doesn't appear to work.
    Thanks
    Nick

    Hi Nicholas,
    Create a new user and name him Test.
    By default he has no explicit rights over the particular group.
    Give some explicit rights over the Group in which Extension point reports belong to that Test User.
    For that Group, open the user security and Add principles.
    Give the View right to Group and test the  issue.
    Regards,
    Rohit

  • Viewing power point slideshows

    Before I had my Imac, I was able to view power point presentations on a Dell computer as a continuous slideshow complete with sound.  Now when someone sends me a power point file, I can only open it and view each slide separately.  Is there some way to view these slideshows the way I once did on my old computer?

    If you have MS Office for Mac installed on your iMac then please re-post your question on the Office for Mac Product Forums . BTW you should indicate what version of MS Office for Mac you have installed. If you do not have MS Office for Mac then you will need that.
    Good luck.

  • Every page in website is different even though they are the same size!  4 Views 0 Replies Latest reply: Sep 25, 2011 4:23 PM by kellynewmac     kellynewmac Level 1 (0 points) Sep 25, 2011 4:23 PM Can someone please tell me what I have done wrong ?

    Can someone please tell me what I have done wrong>?  Obviously I am new to iweb, and need help.  I recently built a website in iweb with only 5 pages, and I made the height, width, & all of the specs regarding the page size exactly the same, but they all load as different sizes on the website.  Also the text i typed loads right away, and the images take forever to load with each page when i look at it on a pc, and not mac.  Can someone please help me!!

    Obviously I am new to iweb, and need help.
    And one of your Services is Webdesign?
    Small consolation : iWeb is a very advanced piece of software. So advanced that even highly skilled professionals have difficulty understanding and using it.
    Anyway, your pages are NOT the same size by design. Which can clearly be seen. But also by checking the source of the pages.
    The Home page is 665px wide and the Contact page is 820px wide. That doesn't happen by magic. It's user induced.
    So do what I do : pay attention to every tiny detail. Especially when it's your business. No excuse.
    Here are some sample Sites :
         http://www.wyodor.net/mfi/
    You can download Domain files for your pleasure to study and use here :
         http://www.wyodor.net/mfi/Maaskant/How_To.html
         http://www.wyodor.net/mfi/size/768-946.html

  • How to define the Index on the column which is define in view (9i)

    hi all,
    I have one view which is based on to tables say 'customers' and 'vendors'
    view definition is like:
    create or replace view customer_vendor as
    select customer_name, 'Customer' type from customers
    union all
    select vendor_name, 'Vendor' type form vendors;
    my problem is that how i can define index on 'type' column if i used in where clause when i query the view.
    Regards
    s

    An index is a pointer. A pointer to a data place.
    Data result of a view aren't stored.
    So, how an index may work against a view ?
    SQL> create index idx1 on v1(type);
    create index idx1 on v1(type)
    ERROR at line 1:
    ORA-01702: a view is not appropriate hereThink about mview instead of view, maybe that can help. Data result of mview are stored somewhere in database, so you are allowed to create an index against mview, like for table.
    Anyway, if you want 'Customer', why not request onto customers table ?
    Nicolas.

Maybe you are looking for