Is it possible to create a view where table in the From clause changes name

is it possible to create a view from a from a table like this
create view my_view as select id, col1, col2, result from <<my_latest_cacahe_table>>;
the table in the from clause changes the name .
I have another table which indicates the the latest name of my cache tables. Always there are two records there. The latest one and previous one.
select * from cache_table_def
table_name cache_table_name refresh_date
my_table cache_table245 1/23/2012
my_table cache_table235 1/22/2012
create table cache_table_def (table_name varchar2(25), cache_table_name varchar2(25), refresh_date date);
insert into cache_table_def values( 'my_table','cache_table245','23-jan-2012');
insert into cache_table_def values ( 'my_table','cache_table546','22-jan-2012');
create table cache_table245 (id number, col1 varchar2(50), col2 varchar2(20), result number);
insert into cache_table245 values(1, 'test123', 'test345',12.12);
insert into cache_table245 values (2, 'test223', 'test245',112.12);
create table cache_table235 (id number, col1 varchar2(50), col2 varchar2(20), result number);
insert into cache_table235 values (1, 'test123', 'test345',92.12);
insert into cache_table235 values (2, 'test223', 'test245',222.12);
what I need to do is find the latest cache_table name for my_table and use that in my view defintion
When user select from the the view it always reurns the data from the latest cache_table
is it possible to do something like this in oracle 11g?
I have no control on the cache tables names. that is why I need to use the latest name from the table.
Any ideas really appreciated.

I've worked up an example that does what you ask. It uses the SCOTT schema EMP table. Make two copies of the EMP table, EMP1 and EMP2. I deleted dept 20 from emp1 and deleted dept 30 from emp2 so I could see that the result set really came from a different table.
-- create a context to hold an environment variable - this will be the table name we want the view to query from
create or replace context VIEW_CTX using SET_VIEW_FLAG;
-- create the procedure specified for the context
- we will pass in the name of the table to query from
create or replace procedure SET_VIEW_FLAG ( p_table_name in varchar2 default 'EMP')
  as
  begin
      dbms_session.set_context( 'VIEW_CTX', 'TABLE_NAME', upper(p_table_name));
  end;
-- these are the three queries - one for each table - none of them will return data until you set the context variable.
select * from emp where 'EMP' = sys_context( 'VIEW_CTX', 'TABLE_NAME' );
select * from emp1 where 'EMP1' = sys_context( 'VIEW_CTX', 'TABLE_NAME' );
select * from emp2 where 'EMP2' =  sys_context( 'VIEW_CTX', 'TABLE_NAME' )
-- this is how you set the context variable depending on the table you want the view to query
exec set_view_flag( p_table_name => 'EMP' );
exec set_view_flag( p_table_name => 'EMP1' );
exec set_view_flag( p_table_name => 'EMP2');
-- this will show you the current value of the context variable
SELECT sys_context( 'VIEW_CTX', 'TABLE_NAME' ) FROM DUAL
-- this is the view definition - it does a UNION ALL of the three queries but only one will actually return data
CREATE VIEW THREE_TABLE_EMP_VIEW AS
select * from emp where 'EMP' = sys_context( 'VIEW_CTX', 'TABLE_NAME' )
union all
select * from emp1 where 'EMP1' = sys_context( 'VIEW_CTX', 'TABLE_NAME' )
union all
select * from emp2 where 'EMP2' =  sys_context( 'VIEW_CTX', 'TABLE_NAME' )
-- first time - no data since context variable hasn't been set yet
SELECT * FROM THREE_TABLE_EMP_VIEW
-- get data from the EMP table
exec set_view_flag( p_table_name => 'EMP' );
SELECT * FROM THREE_TABLE_EMP_VIEW
-- get data from the EMP2 table
exec set_view_flag( p_table_name => 'EMP2');
SELECT * FROM THREE_TABLE_EMP_VIEW
For your use case you just have to call the context procedure whenever you want to switch tables. You can union all as many queries as you want and can even put WHERE clause conditions based on other filtering criteria if you want. I have used this approach with report views so that one view can be used to roll up report data different ways or for different regions, report periods (weekly, quarterly, etc). I usually use this in a stored procedure that returns a REF CURSOR to the client. The client requests a weekly report and provides a date, the procedure calculates the START/END date based on the one date provided and sets context variables that the view uses in the WHERE clause for filtering.
For reporting it works great!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Is it possible to create materialized view log file for force refresh

    Is it possible to create materialized view log file for force refresh with join condition.
    Say for example:
    CREATE MATERIALIZED VIEW VU1
    REFRESH FORCE
    ON DEMAND
    AS
    SELECT e.employee_id, d.department_id from emp e and departments d
    where e.department_id = d.department_id;
    how can we create log file using 2 tables?
    Also am copying M.View result to new table. Is it possible to have the same values into the new table once the m.view get refreshed?

    You cannot create a record as a materialized view within the Application Designer.
    But there is workaround.
    Create the record as a table within the Application Designer. Don't build it.
    Inside your database, create the materialized with same name and columns as the record created previously.
    After that, you'll be able to work on that record as for all other within the Peoplesoft tools.
    But keep in mind do never build that object, that'll drop your materialized view and create a table instead.
    Same problem exists for partitioned tables, for function based-indexes and some other objects database vendor dependant. Same workaround is used.
    Nicolas.

  • Is it possible to create relational view on Analytic Workspace in Oracle 9i Release1

    Hi All,
    We are in the initial stages of Oracle 9i OLAP prototype. Since the current version of BIBeans 2.5 does not work with Release 2 of Oracle 9i OLAP, we are planning to use Oracle 9i OLAP Release 1. So can you please answer the following questions.
    1. Is it possible to create relational view on Analytic Workspace(like in Release 2) and populate the OLAP catalog, if so can you give me guidance to get the appropriate user guide. The OLAP DML guide in Release 1 talks about creating OLAP catalog metadata for Analytic Workspace using a metadata locator object.
    2, Is it advisable to use Oralce 9i OLAP Release 1? Does the Analytic Workspace and the corresponding BIBeans work in Release 1?
    Thank you,
    Senthil

    Analytic Workspaces (Express/multidimensional data objects and procedures written in
    the OLAP DML) are new to Oracle9i OLAP Release 2, you cannot find them in Release 1.
    BI Beans will soon (within a week) introduce a version on OTN that will work with Oracle9i OLAP Release 2.

  • Is it possible to create a generic report that accepts the SQL as a param

    Is it possible to create a generic report that accepts the FULL sql statement as a paramater and returns variable results based on this?
    We have a requirement to have a generic export routine to spit out csv's from clicking on a web page hyperlink, which would need to accept a "new" sql statement for every run, each containing different columsn etc that would be needed in the output.
    I was hoping could have a generic Oracle report, exporting delimited data format (and as such not using a layout) and somehow pass in the "new" sql statement as a parameter at run time - each sql statement would be different with different columns etc.
    Is this possible with oracle reports ?
    thanks

    If you need a simple dump of data you could try writing a report with a simple query such as
    select 'Report title or column headers'
    from dual
    &data_query
    then your &data_query parameter could be
    union select col1||','||col2 from data_table
    If you are outputing a comma separated data dump the you can concatenate together your data into a single text field.
    This would allow you to have a simple heading followed by the actual data. I guess you could extend this so that the 'Report title or column headers' from the first query was also a parameter to output your row headings i.e.
    select :column_headings_text
    from dual
    &data_query
    Give it a go and good luck

  • Is it possible to create a variable in bex with the last work day?

    Hi Gurus
    Is it possible to create a variable in bex with the last work day?
    Actually end-user every day open queries,
        - Put in selection date day - 1 or
        - put last Friday if the day is Monday or
        - put last Thursday if the day is Monday and Friday is holiday (in a calendar for example 25 the December).
    Please do the needful. It is urgent
    Thanks in advance
    Raj

    Try this logic in a customer exit:
    DATA:  l_s_range TYPE rsr_s_rangesid.
    DATA:  X_PERIOD LIKE T009B-POPER,
               X_YEAR   LIKE T009B-BDATJ.
      CASE I_VNAM.
      WHEN 'ZPREVWORKDAY'.
        DATA: l_DayOfWeek(1) TYPE C,
              l_act_date     TYPE d,
              l_prev_date    TYPE d.
        l_act_date = sy-datum.
        CALL FUNCTION  'DATE_COMPUTE_DAY'
             EXPORTING DATE = l_act_date
             IMPORTING DAY  = l_DayOfWeek.
        CASE l_DayOfWeek.
          WHEN '1'.
            l_prev_date = l_act_date - 3.
          WHEN '2'.
            l_prev_date = l_act_date - 1.
          WHEN '3'.
            l_prev_date = l_act_date - 1.
          WHEN '4'.
            l_prev_date = l_act_date - 1.
          WHEN '5'.
            l_prev_date = l_act_date - 1.
          WHEN '6'.
            l_prev_date = l_act_date - 1.
          WHEN '7'.
            l_prev_date = l_act_date - 2.
        ENDCASE.
        l_s_range-low  = l_prev_date.
        APPEND l_s_range TO e_t_range.
    ENDCASE.
    Edited by: Tyler Blouse on Feb 13, 2008 8:28 PM

  • Is it possible to create an album in gallery on the iPad or do you have to do it on your computer?

    Is it possible to create an album in gallery on the iPad or do you have to do it on your computer?

    Thanks, how about in gallery on MobileMe ? As I am not near my computer for the next 3 weeks so can't do a cable sync do you think I could create and album in gallery on mobile me on a "borrowed" computer and do it throughout the cloud?

  • Is it possible to create a 1 D array with the "build array VI"? when receiving random number

    Hello all,
    Is it possible to create a 1 D array with the "build array VI" when receiving random number?
    I am receiving random data and the build array VI always create a 2D array which might cause some problem if you want to compute certain type of operation after.
    Any example will be welcomed.
    Thank you,
    Israel 

    Hello Lynn and Yamaeda
    First I want to Thank you Lynn for your linguistic contribution indeed "Build Array" is a primitive and not VI, thank you for the education. In reality what I am doing is simple.
    I have two arrays of complex elements Array1 and Array2.
    Array1 conains the complex elements ""(a0+ib0) ; (a1+ib1) ;...(an+ibn) ;
    Array2 conains the complex elements ""(c0+id0) ; (c1+id1) ;...(cn+idn) 
    What I want to do is the multiplication of the first array by the  conjugate of the second array element.
    Array1*(Conjugate Array 2)" for the first element the results is "(a0.C0-b0.d0) + i(b0c0-a0d0)" and the etc...
    and then taking the square root ([(a0.C0-b0.d0) power of 2]) +  [(b0c0-a0d0) power of 2])
    I was wondering if there were some dedicate primitive that could solve the computation above which is the cross correlation in Frequency domain.
    Thank you very much.
    Israel

  • Is it possible to create all views in MM01 through ALE(MATMAS) ?

    Hi,
    I want to create all views(One or two may not require) in Inbound MATMAS through ALE. Is it possible ?
    Currently its creating only Basic data1 & 2,General Plant Data/Storage1 &2 ,plant stock.
    I didn't set any filter for any segments.
    Please don't post ALE or EDI document. I already have enough documents.
    Thanks,
    Narayan

    I solved by myself. Set PSTAT to whatever view you want.
    Thanks,
    Narayan

  • Is it possible to create all views in Material master through ALE(MATMAS) ?

    Hi,
    I want to create all views(One or two may not require) in Inbound MATMAS through ALE. Is it possible ?
    Currently its creating only Basic data1 & 2,General Plant Data/Storage1 &2 ,plant stock.
    I didn't set any filter for any segments.
    Please don't post ALE or EDI document. I already have enough documents.
    Thanks,
    Narayan

    I solved by myself. Set PSTAT to whatever view you want.
    Thanks,
    Narayan

  • How to create a view with parameters; read the documentation but nothing!

    Hello!
    I'm new to the Oracle world but together with my coworkers we need to very quickly study Oracle to figure out whether we'll add Oracle to our list of supported databases or not.
    Question: How do I create a view with parameters?
    I've read the documentation but I could not find this! I found the sql syntax to create a view but no parameters whatsoever...
    I have found on the web some very complicated way of doing this, but doesn't Oracle support Views with parameters?
    The goal here is to return a recordset, don't forget, so,please don't speak about stored procedures unless you are going to tell me how to get a recordset out of a stored procedure! ;)
    Thanks for all your help and attention!
    Jorge C.

    You can set up a parameterized view via context as follows:
    1. Set up a procedure to set your context values:
    create or replace procedure p_set_context (p_context IN VARCHAR2,p_param_name IN VARCHAR2,p_value IN VARCHAR2)
    as
    BEGIN
    sys.dbms_session.set_context(p_context,p_param_name,p_value);
    END;
    2. Create your context using the procedure you just created
    create or replace context my_ctx using p_set_context
    3. This is the test table I'll use
    create table my_table(col1 number)
    and populate it:
    begin
    for v_index in 1..10
    loop
    insert into my_table values(v_index);
    end loop;
    end;
    and the view that will be parameterised
    create or replace view v_my_table as select col1 from my_table where col1 between sys_context('my_ctx','start_range') and sys_context('my_ctx','end_range')
    4. Now set the parameters using the procedure above.
    begin
    p_set_context('my_ctx','start_range','1');
    p_set_context('my_ctx','end_range','5');
    end;
    5. Selecting from my_table will give you 1 to 10 (no surprise there :-) )
    selectng from v_my_table will give you 1 to 5
    You can use the context to set formats etc using the same principle. A common gotcha to watch for is trying to set the context directly using DBMS_SESSION.SET_CONTEXT instead of creating a procedure. This belongs to SYS and SYS won't have the privileges to set your context so you get an insufficient privileges result leading to much headscratching and unnecessary grants (at least that's my understanding of it).
    Sorry Jorge, as you're new to Oracle I should also have pointed out for completeness sake, that you can change the parameters at any time through recalling the p_set_context, for example, following on from above, after your "select * from v_my_table" and seeing 1 to 5, you could then do
    begin
    p_set_context('my_ctx','start_range','3');
    end;
    and when you requery 'Select * from v_my_table' you will now see rows 3 to 5.
    Bit of a simplistic example, but you can see how easy it is. :-)
    Message was edited by:
    ian512

  • Is it possible to create a Lightroom 5 cropping overlay guide from an image?

    I must have dreamed this but I thought I saw that LR 5 had the ability to create a cropping overlay from an image.  My goal is to create a quicker way to place a date on 5x7 and wallets so that it works for both prints.  I want WHCC's wallet guide as an overlay.

    It is not possible to create a custom crop overlay but you can use a Loupe Overlay to eyeball it.  View>Loupe Overlay>Layout Images and then navigate to a PNG (transparency enabled) version of this overlay. It will show you the overlay in Library>Loupe and Develop so that you can preview your crop.  If you don't have the means to create a transparent PNG, you can simply use CTRL/CMD to reduce the opacity of your Opaque PNG File.
    Note: the Overlay and the Crop Overlay cannot be active at the same time.

  • How to create a view on tables with different keys?

    I have to create a View on:
    Z3PVR: Transparent Table
    BSEG: Cluster Table
    CKIS: Transparent Table
    BKPF: Transparent Table
    RV61A: Structure
    T001: Transparent Table
    All the tables have different "Key Fields" and the structure has no "Key Fields". When i create the view, what do I mention in the "JOIN FIELDS" tab. and how do i create the view with the structure?
    Please advise.

    How to create a view on a Non-Transparent Tables.
    how to create view?
    HELP.. How to create a view with the tables with ALV

  • Is it possible to create l3vpn without enabling mpls in the core and PE routers .

    Hi 
    i have below setup , in this PE1,P,PE2 routers do not have mpls support , it have only MGRE and GRE tunnel support ,
    is it possible to create l3vpn without mpls here .
                              bgp session between PE1 and PE2, 
    CE1---------------PE1-----------------P---------------PE2------------CE2 .
    PE1,P,PE2 do not have mpls support .
    Thanks
    Duraipandi

    hi durai,
    you can use the vrf-lite model but this is complex to manage in larger networks.
    for example:
    CE1 ---PE----core(x)---P------PE---CE1
    CE2  --/                                    \----CE2
    in this case, without mpls, I need to create on the core(x) link 2 vrf's with 2 vlans to go to "P".
    and the same on the other PE and link.
    Now if you think that there are more P's with backup paths or more CE's that linkage exponentially increases to define those vlans and in all your P routers is that awareness of every CE route!
    MPLS just simplifies this; single core link,by just using labels. Your P routers only see PE next hops and are opaque to the number of vrf's you carry/service. Adding another P or PE device integrates into the routing naturally and MP BGP takes care of the PE advertisement. So expanding and rerouting are more natural and graceful here too.
    So while technically MPLS can be omitted, it is just not a smart thing to do from a design perspective in l3vpn.
    cheers!
    xander

  • Is it possible to create an Apple Script to import data from a web data feed (RESTful XML/JSON)?

    Before I get started looking for a programmer, does anyone know if it will be possible to create a script that will allow Numbers to connect to an external data feed in either XML or JSON? I want to enable some colleagues who use Mac to connect to the same data feed that Excel for Office connects to.. Thanks,

    It is definitely not hard to import XML or JSON data via an AppleScript. As an amateur tinkerer, I found a way, for example, to bring in OFX data from my bank (OFX is a flavor of XML) using the XML parser built into System Events, which is AppleScriptable.
    How satisfied your colleagues would be with the solution, though, will depend on what you mean by "connect to an external data feed." If you are dealing with datasets in the thousands of rows and need frequent and rapid response, then you may not be happy. In that kind of situation you would need to expect at least a few seconds of wait time every time you "refresh."
    If, as in my case, you have only a few hundred rows and don't need to bring the data in every few seconds, then the AppleScript solution is very practical. The programmer could probably goose the performance and make the job easier by using AppleScript as a wrapper for a script in Python or another language that is faster than AppleScript at parsing XML and JSON.
    SG

  • TabStripLayout-View: Where to set the text?

    Hello,
    I am using a view of the kind TabStrip. For your understanding> Not a normal view with a tabstrip. It is a view similar to Gridlayout, just TabStripLayout.
    I can not find where to set the text for the individual tabs, e.g. TAB1, TAB2 etc.
    Does anzbodz know?
    Regards Thank Mario

    I assume you are using a TabStrip layout of a viewset.  The tab 'captions' are set in the properties for the viewset.  In the explorer outline, expand Windows and click on the ViewSet and in the properties for the ViewSet it will have the captions listed for the tabs and you can change the text there.
    Be aware that the tab strip layout for viewsets is a bit limited.  As far as I can tell the navigation plugs between views do not work.  There are other forum questions/answers on how to use a normal TabStrip element rather than a viewset to get around this.
    -Cindy

Maybe you are looking for

  • Adobe Flash Player problems

    Hi have installed latest version of Adobe Flash player but when i go to a site that ueses this app it says i need to down load latest version ? Can any one help me

  • Need to re-install iTunes

    I have a problem with my iTunes, everytime I try to sync my iPhone 4 it says "backing up" and doesn't seem to progress anymore. I need to cancel the sync everytime because it just doesn't do anything and then I need to end iTunes through Windows Task

  • Terrible customer service and relations

    In January of this year my wife and I switched back to Verizon from StraightTalk.  I purchased the Droid Turbo and she purchased the IPhone.  Shortly after getting our new phones, I made the dumb mistake of laying my phone on the back of my truck and

  • Lost airport express output connection from ipad

    MY I pad had three output options which one could select affter a double click on the button on the right of the screen 1) Ipad 2) airport express 3) Apple TV : the airport express option has disappeared .. As a results I can no longer play music bac

  • N97 Mini Lotsa problems.

    FOR ONE I HAVE DECIDED TO STOP BUYING NOKIA PHONES. I HAVE HAD A TERRIBLE TIME WITH N97 MINI SINCE THE FIRST WEEK OF PURCHASE. Now I am facing problems in uninstalling apps and backing up my messages. THIS SUCKS BIG TIME.