2 definitions of view based on the value of the table

Hi all

Is it possible to have 2 different definitions of each entry of 2 base tables display different, based on the value of the table?

We have 2 tables with similar columns, one with historical and other data was only the latest / greatest according to yesterday (it is populated by ETL from mainframe). Changes made by the java application online is now going into the table containing historical data immediately, but edits made in mainframe comes to the table with the data current next day.

There are 2 products, an is based on the last and largest of the historical table based on cre date and date of mod and other product relies on the table with the current data (not historical).

Tried using joins for these two tables but the performance wasn't good and each product needs table data alone, and so I wanted to eliminate joins.

We wanted to use the same name for the view from the metadata using the shared functionality based on the name of the view.

Is there a way define a view under certain conditions?

It is:

If the value for a particular parameter is 0 then

Select c1, c2, c3 of < historical table > other

Select c1, c2, c3 of < no history table >

Any ideas?

You are looking for something like this?
Re: how to pass parameters in a view

Tags: Database

Similar Questions

  • Materialized view, based on the stored procedure

    Hi all

    is it possible to create a materialized view on the results returned by a stored procedure?

    If this is not the case, do you think that any other way except for filling a table with data from the stored procedure and then founded the MV on it?

    Thanks in advance.

    MichaelTsilikidis wrote:

    Sorry I don't speak properly. In fact the procedure does not return a value, it fills one of its parameters (of the ref cursor type) of data. That's what I wanted.

    No it's not.

    REF CURSOR don't store data, so it's not possible.

    A Ref cursor is just a pointer to a query... and you can't "select from" a ref cursor, you can retrieve only one open.

    PL/SQL 101: Understand the Ref Cursor

    As correctly stated above, you can't question from a procedure to a function, and a materialized view is based on a query, you cannot use a procedure in a materialized view.

    You could use a function pipeline instead of a procedure, or have the pipeline function obtain the results of the procedure and pipelines, and then the materialized view could be based on the results of this function in the pipeline.

    example of function pipeline:

    SQL > CREATE or REPLACE TYPE AS OBJECT num_descript (num number, descript varchar2 (30))
    2.

    Type of creation.

    SQL >
    SQL > CREATE or REPLACE TYPE tbl_num_descript AS TABLE OF THE num_descript
    2.

    Type of creation.

    SQL >
    SQL >
    SQL > CREATE or REPLACE PACKAGE AS-reftest
    2 FUNCTION pipedata (number p_choice) tbl_num_descript RETURN PIPELINED;
    3 END;
    4.

    Package created.

    SQL >
    SQL > CREATE or REPLACE PACKAGE BODY AS-reftest
    2 FUNCTION pipedata (number p_choice) tbl_num_descript RETURN PIPELINED IS
    3 v_obj num_descript: = num_descript (NULL, NULL);
    4 v_rc sys_refcursor;
    5 BEGIN
    6. IF p_choice = 1 THEN
    7 v_rc OPEN to SELECT empno as num, ename like descript FROM emp;
    8 ELSIF p_choice = 2 THEN
    9 OPEN v_rc to SELECT deptno as num, dname as descript OF THE Department;
    10 END IF;
    11 LOOP
    12 FETCH v_rc INTO v_obj.num, v_obj.descript;
    EXIT 13 WHEN v_rc % NOTFOUND;
    14 PIPE ROW (v_obj);
    15 END LOOP;
    16 v_rc NARROW;
    RETURN 17;
    18 END;
    END 19;
    20.

    Package body created.

    SQL > select * from table (reftest.pipedata (1));

    DESCRIPT NUM
    ---------- ------------------------------
    7369 SMITH
    7499 ALLEN
    7521 WARD
    7566 JONES
    7654 MARTIN
    7698 BLAKE
    7782 CLARK
    7788 SCOTT
    KING 7839
    7844 TURNER
    7876 ADAMS
    JAMES 7900
    7902 FORD
    7934 MILLER

    14 selected lines.

    SQL > select * from table (reftest.pipedata (2));

    DESCRIPT NUM
    ---------- ------------------------------
    10 ACCOUNTING
    SEARCH 20
    30 SALES
    40 OPERATIONS

  • Dynamically create checkboxes based on a value in a table

    Hi friends,

    I am looking for crerating several checkboxes based on a value in the table. For example if I'm clicking on a name of 'material' in a report, I need to show all interfaces for equipment like the checkboxes in another page. There is a table that contains interfaces corresponding to a particular equipment. The box should be checked if this particular interface is "put into service". This info is present in the table "provisioing. How can I achieve this. Help, please.


    Kind regards
    TJ

    The display order of your boxes depends on your SELECT statement, just put an ORDER BY in there, and you can do whatever you want.

    Don't forget: the LOV-statement must select all of the possibilities, with the process, you set the provisioned to checked.

    brgds,
    Peter

    -----
    Blog: http://www.oracle-and-apex.com
    ApexLib: http://apexlib.oracleapex.info
    BuilderPlugin: http://builderplugin.oracleapex.info
    Work: http://www.click-click.at

  • Impact on performance at the addition of materialized view logs at the tables?

    I write a very complex query for a client of our database system transaction and this will require the creation of a materialized viewbecause, all attempts at development to make acceptable performance failed.

    I want to activate the fast refresh the MVIEW but I am confused about the consequences of the addition of the addition of materialized view logs to the base tables.

    Some tables are large and involved in a large number of transactions and I wonder if the INSERT/update performance will be seriously affected by the presence of a newspaper mview.

    Maybe it's a simple question, but I was unable to find an answer very clear in the literature.

    Thanks for all the answers!

    Chris Mills
    Biotechnology data management consultant

    There is an overload for the newspapers of the view materialized, a little less, but roughly on par with a trigger that writes to a table.

    If it is an OLTP system where you do a lot of low-value transactions, the general expenses percentage is probably not particularly great, something in the range of 5-10% maybe (although, of course, by running tests in the development environment would be desirable). If there are loads in bulk, the impact of the percentage could be higher.

    Justin

  • based on the table line oaf page filter lines

    Hello

    Right now, I have the search page where the results are displayed in the region of the table.

    In addition, I have situation where I need to filter the lines and display the results in the background region based when you click on the row of table area...

    How can I achieve this?

    Please let me know.

    Thank you

    MK

    Managed to get this working?

  • Check boxes based on the table...

    I have an 'event' of the table, a "subject" of table and one table that links these two 'event_topics '. I have a form to create events and want to have all the available topics in the table of 'event' presented a list with checkboxes, to verify for each event, all the van when registering for any subject verified and relevant topics, a line is added in "event_topics" with the event_id and the topic_id.

    Is this possible? And if so, how do I start on this? I use Apex 3.2.

    Hello Tom,

    Yes, it is possible.

    First of all, you need a point of the box. The LOV for this element of the value to something like

    select topic_name, topic_id from topic order by topic_id
    

    To save the selection you need a process of pl/sql

    declare
      vPICKED apex_application_global.vc_arr2;
      vITEMS varchar2(1000);
      vCOUNT number;
    begin
    
      vITEMS := :YOUR_CHECKBOX_ITEM;
    
      --first delete all entries from event_topics that are not checked
      delete from event_topics
      where ':' || trim(to_char(topic_id)) || ':' not in (':' || vITEMS || ':')
      and event_id = :EVENT_ID;
    
      -- insert all new checked topics into event_topics
      vPICKED := apex_util.string_to_table(vITEMS, ':');
    
      for z IN 1..vPICKED.count
      loop
        select count(*) into vCOUNT from event_topics
        where event_id = :EVENT_ID
        and topic_id = vPICKED(z);
    
        if vCOUNT = 0 then
          insert into event_topics values (:EVENT_ID, vPICKED(z));
        end if;
      end loop;
    
    end;
    

    To extract the items all turned on during the loading of the page, you need to load on before the process of the header:

    declare
      vPICKED apex_application_global.vc_arr2;
    begin
    
      select to_char(topicl_id)
      bulk collect into vPICKED
      from event_topics
      where event_id = :EVENT_ID
      order by topic_id;
    
      :YOUR_CHECKBOX_ITEM := apex_util.table_to_string(vPICKED, ':');
    
    end;
    

    Hope this helps,
    Dirk

  • ViewStack container. Choose the view based on the variable command.

    Hi I am trying to implement in my application role-based access control.  I opted for a login screen which will compare users and passwords to a MySQL database.  on a match, I need to read the 'role' associated with each user.  I want to have different views for each Admin role with the role, that role will see views admin and users, a user discovers and so on.

    I managed with a button to change the view.selectedChild.  How can I use view.selectedChild = $var.

    As a test I used a dataGrid to give me choices.  But when I use the selectionChange like this event handler

    protected function dataGrid_selectionChangeHandler(event:GridSelectionEvent):void
                                  {
                                            view.selectedChild = dataGrid.selectedItem.role;
                                  }
    

    It does not change the view.

    Is it possible to use ViewStack for control of access in this way?

    SelectedChild is a point of view.  What is the role?  What is an int or a string?  I would like to map it to selectedIndex instead.

    But really, I wouldn't use ViewStack and use view States that match name role.

  • The default view sysdate to a form based on the table element

    Hello

    How to display the current sysdate to a default element value...

    In my scenario, I have transaction date not I have no need to have a date for she picker...

    I do display the element, and then how to display the date current system, and it needs to be changed dynamically on the basis of the day...

    Kind regards

    Vincent

    Edit the item page and and the default configuration of sysdate value text field

    and the type of default value expression plsql

    Leave.

  • Field of view based on the calculated result?

    Hello

    So far, these forums have been very helpful to me making the forms for my company. I really have 2 questions, I appreciate any help I can get!

    Question 1:

    I have a submission form we use that calculates the total price by multiplying a "Quantity" field by field "cost". However, when no value is entered, the field displays "$0.00," which is accurate, but we would prefer if field does not display anything if the price was exactly zero (we actually wants it displays negative amounts, because we add discounts deducted from our quotes). Is there a way to turn 'off' field when it is equal to $0, or modify it so that it displays nothing until it changes its value?

    Question 2:

    Can I format a field so that every word in it capitalizes the first letter in uppercase? Some companies we work with can be 3-5 words long, and he saves just our sellers boredom especially when you fill out them on an iPad.

    Thank you!

    1: use this code as the custom validation script:

    "" If (event.value == "0") event.value = "";

    2. Yes, use the following custom format script:

    If {(event.value)

    Words cut var = event.value.split("");

    var newValue = "";

    for (var i = 0; i)

    If (I! = 0) newValue += "";

    newValue += splitWords [i] .charAt (0) .toUpperCase () + splitWords [i] .substring (1);

    }

    Event.Value = newValue;

    }

    I can't guarantee that it will work on the iPad, though.

  • Error definition day LOV based on the month and year

    Select ' 1 ', ' 01' day_aff union double val
    ...
    Select '29', ' 29 "double where '29' < = to_char (last_day (to_date ('01.' |)))" '02'. '.' || (((', 'dd.mm.yyyy')), 'jj') union
    Select '30', ' 30 "double where '30' < = to_char (last_day (to_date ('01.' |)))" '02'. '.' || (((', 'dd.mm.yyyy')), 'jj') union
    Select '31', '31' from dual where '31' < = to_char (last_day (to_date ('01.' |))) '02'. '.' || (((', 'dd.mm.yyyy')), 'jj')
    order by 2

    That works well.

    If I replace '02' by: P10_MONTH & P10_MONTH. or v ('P10_MONTH') and 2008 by: P10_YEAR & P10_YEAR. or v ('P10_YEAR'), I get the following error on the creation of LOV (in shared components or LOV section of the element):

    LOV query is not valid, a display and a return value is needed, the column names must be different. If your query contains a query online, the first CLAUSE in the SQL statement must not belong to the query online.

    No work around?

    Igor

    Hi Igor,.

    I think it's the | in the SQL that is causing the problem. You can get around this by the presence of a hidden page element which is calculated at the point of process before header which calculates the first day of the selected month.

    I did it on this page: [http://apex.oracle.com/pls/otn/f?p=35917:16]

    In addition, you can simplify your SQL statement to something like:

    SELECT LEVEL d, LEVEL r
    FROM DUAL
    CONNECT BY LEVEL <= TO_NUMBER(TO_CHAR(LAST_DAY(TO_DATE(v('P16_FIRSTDATE'),'DD/MM/YYYY')),'DD'))
    

    (P16_FIRSTDATE is the element that contains the calculated date)

    Andy

  • Definition of attributes based on the change of password

    Hello

    I have a requirement where if the administrator changes the password of a user to the IOM, I need set a particular attribute in the directory server, but if the user changes his password, I need to delete it. Could someone please tell me how can I capture that has changed the password and then set this attribute in the DS?

    Thank you
    PETREA

    It will give the details of the profile for the user that triggered the change of password.

    Ideally, you should plug the API code in the task where you try to define attributes in the DS.

  • Created the form based on the table - created new line - how to retrieve line editing?

    Hello

    Sorry for such a stupid question, but being new in APEX, I don't know much about how the end user on a form.

    I have created a new form (not in a table), based on a table.

    I ran the form and created a new line.

    After the line was created, the form comes back ready to create another line (all the values in the fields).

    How can I go on the recovery of the line, I added just to make a few changes?

    Again, please forgive my ignorance.

    Mason

    Masong says:

    Sorry for such a stupid question, but being new in APEX, I don't know much about how the end user on a form.

    Or about how best to use this forum. Always include all the details of your environment and your application when you post a question so that we can provide a solution version - and context, case-specific: How to get the answers from the forum

    I have created a new form (not in a table), based on a table.

    I ran the form and created a new line.

    After the line was created, the form comes back ready to create another line (all the values in the fields).

    How can I go on the recovery of the line, I added just to make a few changes?

    Ensure that the attribute key back to point in the line process of... The ARP process is defined to return the value of PK of records inserted in the element of key primary page and delete any Reset Page clearly session state process created by the wizard page.

  • create materialized view log on the table without a primary key

    Hi all
    CREATE TABLE client_months 
    (
      SUBJ_CODE         NUMBER(4),
      SERV_CODE         NUMBER(4),
      DEBIT_CODE        NUMBER(4),
      PERIOD_NUM        NUMBER(2),
      PERIOD_NAME       VARCHAR2(40 CHAR),
      FIRST_MON_DAY     DATE,
      LAST_MON_DAY      DATE,
      VALUE_MON_DAY     DATE,
      MONTHES           NUMBER(4,2),
      GARDENING_WEIGHT  NUMBER(5,4),
      REASON_CODE       NUMBER(5),
      STAMP_ACTION      VARCHAR2(1 CHAR),
      STAMP_CDATE       DATE                        DEFAULT SYSDATE,
      STAMP_DATE        DATE,
      STAMP_USER        VARCHAR2(15 CHAR),
      REGION_CODE       NUMBER(9)
    )
    table created.
    
    CREATE UNIQUE INDEX client_months_UK  ON client_months 
    (SUBJ_CODE, SERV_CODE, DEBIT_CODE, PERIOD_NUM, REGION_CODE)
    index created.
    
    CREATE MATERIALIZED VIEW LOG ON client_months with rowid;
    
    CREATE MATERIALIZED VIEW client_months_mv 
    BUILD immediate 
    REFRESH FAST ON COMMIT 
    AS 
    SELECT * FROM client_months;
    
    ORA-12014: table 'CLIENT_MONTHS' does not contain a primary key constraint
    I don't want to refresh the mview when validation is performed on the base table.
    And I don't want to change the base table by adding a primary key.

    is it possible to create the mview journal using the unique index? or another solution?
    Please help
    Thanks in advance
    Naama

    Naamas wrote:
    No,
    I already read this post!

    Then you read wrong:

    SQL> CREATE TABLE client_months
      2  (
      3    SUBJ_CODE         NUMBER(4),
      4    SERV_CODE         NUMBER(4),
      5    DEBIT_CODE        NUMBER(4),
      6    PERIOD_NUM        NUMBER(2),
      7    PERIOD_NAME       VARCHAR2(40 CHAR),
      8    FIRST_MON_DAY     DATE,
      9    LAST_MON_DAY      DATE,
     10    VALUE_MON_DAY     DATE,
     11    MONTHES           NUMBER(4,2),
     12    GARDENING_WEIGHT  NUMBER(5,4),
     13    REASON_CODE       NUMBER(5),
     14    STAMP_ACTION      VARCHAR2(1 CHAR),
     15    STAMP_CDATE       DATE                        DEFAULT SYSDATE,
     16    STAMP_DATE        DATE,
     17    STAMP_USER        VARCHAR2(15 CHAR),
     18    REGION_CODE       NUMBER(9)
     19  )
     20  /
    
    Table created.
    
    SQL> CREATE UNIQUE INDEX client_months_UK  ON client_months
      2  (SUBJ_CODE, SERV_CODE, DEBIT_CODE, PERIOD_NUM, REGION_CODE)
      3  /
    
    Index created.
    
    SQL> CREATE MATERIALIZED VIEW LOG ON client_months with rowid
      2  /
    
    Materialized view log created.
    
    SQL> CREATE MATERIALIZED VIEW client_months_mv
      2  BUILD immediate
      3  REFRESH FAST WITH ROWID ON COMMIT -- pay attention to WITH ROWID
      4  AS
      5  SELECT * FROM client_months
      6  /
    
    Materialized view created.
    
    SQL>
    

    SY.

  • performance of the duties based on the table

    Hello

    I have the package with multiple functions inside, each function represents the specific verification, some or all of the controls are executed on a data set.

    New controls are implemented, they are added to the main proceedings, that's good but editing master procedure source is the disadvantage.

    What I want is to move controls run logic from graphical user interface that allows the operator disable or enable the specific check without having to edit the source.

    My first idea of a table with the function names and check toggle the flag (available from the GUI) and master procedure with prepared loop only on the controls enabled.

    Secondly, one was call to main table inside each check to find is it enabled or not.

    Anyone have an idea better?

    Hi GregV,

    Audits are functions inside the package each company represents the rule, they are run on each change committed by the user. If all controls are passed the change is allowed.

    Now, there is a change - there are several groups changing dynamically the users who should be cheeks just against little business rules.

    We must allow privileged user (Administrator of the Group) assign users to groups and chose the active business rules for them.

    I'm not a big fan of dynamic sql (first idea), so

    1. I want to create tables that define active rules for groups and user group mapping

    2. change each control function of the first table of query groups and to determine who is special rule should be enforced against this group.

    3. create a gui for admin group to manage groups and assign users.

    If it is even a good idea?

    See you soon

    [UPDATE]

    I chose this way

  • collection type parameter [11.2] based on the table in pipeline?

    Hello

    I have a collection of type "table of ' which is filled iteratively. (he gets the new entries more of a souce)

    I need to sort the entries in this type of collection as well as the criteria.

    My approach is to use a function table in pipeline which offers individual entries as lines for a "select from table (my_function (the_collection)).

    My problem is that I get a compilation error in this query statement:

    [Error] PLS-00382 (1209:70): PLS-00382: Dieser Lutherischen hat den falschen type-> expression is of the wrong type

    [Error] PLS-00306 (1209:51): PLS-00306: wrong Anzahl oder Typen von illuminated by von call "ma_fonction"-> wrong number or type of arguments

    [Error] ORA-00904 (1209:25): PL/SQL: ORA-00904: "my_package." "" ma_fonction "-> is not a valid identifier

    but this feature is present in the package body and declared in the package header.

    the entries in the collection are declared as record types in the package header

    the collection of parameter type is declared as 'IS THE INDEX BY a_table.varchar2_attribute%TYPE my_record_type TABLE.

    the package compiled until I added the request.

    so my questions are:

    1. What is the best way to sort the types of collection (by 2 attributes)?

    2. how to pass a parameter of type of collection to a table of pipeliened function?

    Good bye

    DPT

    This approach has proved to work well.

    I created a temporary table to collect the data in. At this point, I use the MERGE statement to remove duplicates.

    I sort everything in refetching this temporary table data.

    Good bye

    DPT

Maybe you are looking for