Fast Refresh using two non-primary key tables

Hi,
I have a materialized view based on two tables with an outer join clause. Both the tables do not have a primary key so I had created materialized view log with row-id on each of them but still I am not able to bring out the fast refresh option for the materialized view. My question is can I have a fast refresh option for materialized view built from two tables without primary keys and having an outer join clause????. If possible please send me some sample scripts for quicker understanding.
Thanks and Regards,
Sudhakar

I was able to create a fast-refreshable MV, on tables without any PK. Unfortunately, I can't complete all the steps since my setup is a multi-master advanced replication (which ABSOLUTELY requires the tables to have PK's). Here are anyway the steps I took. Note that ORA102 is my (definition) master site, and MVDB is my MV site. The tables were created under user HR, and my master group is called "hr_repg". Here are my steps:
HR on ora102 >create table countries_no_pk as select * from countries;
Table created.
HR on ora102 >create table regions_no_pk as select * from regions;
Table created.
HR on ora102 >create materialized view log on countries_no_pk with rowid;
Materialized view log created.
HR on ora102 >create materialized view log on regions_no_pk with rowid;
Materialized view log created.
REPADMIN on ora102 >exec dbms_repcat.suspend_master_activity('hr_repg')
PL/SQL procedure successfully completed.
Elapsed: 00:00:02.68
REPADMIN on ora102 >BEGIN
2 DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
3 gname => 'hr_repg',
4 type => 'TABLE',
5 oname => 'countries_no_pk',
6 sname => 'hr',
7 use_existing_object => TRUE,
8 copy_rows => FALSE);
9 END;
10 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:05.19
REPADMIN on ora102 >set timing off
REPADMIN on ora102 >BEGIN
2 DBMS_REPCAT.CREATE_MASTER_REPOBJECT (
3 gname => 'hr_repg',
4 type => 'TABLE',
5 oname => 'regions_no_pk',
6 sname => 'hr',
7 use_existing_object => TRUE,
8 copy_rows => FALSE);
9 END;
10 /
PL/SQL procedure successfully completed.
(note that you ABSOLUTELY need the rowid's in your select statement for an MV with joins):
MVIEWADMIN on mvdb >CREATE MATERIALIZED VIEW hr.complex_mv refresh fast as
2 select c.rowid "C_ROW_ID", r.rowid "R_ROW_ID", c.COUNTRY_ID, c.COUNTRY_NAME,
3 c.REGION_ID, r.REGION_NAME from hr.regions_no_pk@ora102 r, hr.countries_no_pk@ora102 c
4 where c.region_id = r.region_id (+);
Materialized view created.
MVIEWADMIN on mvdb >BEGIN
2 DBMS_REPCAT.CREATE_MVIEW_REPOBJECT (
3 gname => 'hr_repg',
4 sname => 'hr',
5 oname => 'complex_mv',
6 type => 'SNAPSHOT',
7 min_communication => TRUE);
8 END;
9 /
PL/SQL procedure successfully completed.
REPADMIN on ora102 >BEGIN
2 DBMS_REPCAT.GENERATE_REPLICATION_SUPPORT (
3 sname => 'hr',
4 oname => 'countries_no_pk',
5 type => 'TABLE',
6 min_communication => TRUE);
7 END;
8 /
PL/SQL procedure successfully completed.
(wait when the entries in DBA_REPCATLOG is empty)
REPADMIN on ora102 >exec dbms_repcat.resume_master_activity('hr_repg')
Hope that can help you. If that doesn't work, tell us where it bombs.
Daniel

Similar Messages

  • Partition key on non primary key column

    I have scenario where the table has defined non primary key column as "partition key".
    I was wondering how it will affect the purge/archive process if the index and table are using different column (they are not aligned)?
    What should be the solution to this scenario?
    Can I use the non primary key column as partition key? Is this affect purging/archiving or switching -IN or OUT partitions?
    Here is the article which Im following but didn't get the precise answer:
    "When the indexes and the table use the same partitioning function and columns in the same order, the table and index
    are aligned." 
    https://msdn.microsoft.com/en-US/library/ms345146%28v=SQL.90%29.aspx?f=255&MSPPError=-2147217396#sql2k5parti_topic9
    Look at "Index
    Partitioning" and "Defining
    the Partitioning Key" section.
    ZK

    If it non aligned, you cannot do switching in or out.  to switch, you should have aligned partitons.
    Hope it Helps!!

  • Let me know the standary primary key tables in standard table??

    let me know the standary primary key tables in standard table??

    Hi,
    You can go and check the primary keys of a table in SE11 by entering the table name and pressing display.
    You will get to see that there will be some fields with a tick mark in the primary key column.The fields which have such tick marks are the primary keys of that table.
    As far as I know there is nothing called primary key tables.All tables have some fields as primary keys based upon which a record is uniquely defined in that table.
    Hope it was useful.
    Thanks,
    Sandeep.

  • Selection criteria based on non-primary key columns in Custom-SQL

    Hi all,
    Could anybody please tell me how to perform a search using non-primary key columns, The query is written in Workbench under Custom Sql --> Read Object. The Query goes something like this
    select * from Employee where firstName like #name
    where firstName is a Non-primary key column.
    The Java Code goes like this
    Employee empm = new Employee();
    empm.setFirstName("John");
    Employee employees = (Employee) session.readObject(empm);
    This does not fetch me any values . I dont want the queries to be written in any java class. Is there Any other way to do it ??

    Hi all,
    Could anybody please tell me how to perform a
    search using non-primary key columns, The query is
    written in Workbench under Custom Sql --> Read
    Object. The Query goes something like this
    select * from Employee where firstName like #name
    where firstName is a Non-primary key column.
    The Java Code goes like this
    Employee empm = new Employee();
    empm.setFirstName("John");
    Employee employees = (Employee)
    session.readObject(empm);
    This does not fetch me any values . I dont want the
    queries to be written in any java class. Is there Any
    other way to do it ??I dont think you have set it up the right way to do what you want to do. You need to click on "Queries" on the Employee Descriptor and then Named Queries and then give a name for a named query and then choose ReadObjectQuery under type and then choose SQL under Format. Enter the custom SQL and then export the project xml file.
    Then in your application logic you have to call this named query the usual way.
    Employee employee = (Employee)session.executeQuery("findEmployeeByName,Employee.class,args);
    where args is a vector containing the name of the Employee.

  • Identify columns to use as a primary key

    Good Afternoon,
    Is there a way using dynamic SQL to scan a table to identify the columns to use as the primary key?.
    Thank you in advance.
    Steve

    I converted
    Prashanth's query to dynamic sql:
    DECLARE @SQLString nvarchar(500)
    DECLARE @YourTableName nvarchar(128)
    SET @YourTableName = 'YourTableName'
    SET @SQLString =
    SELECT
    TAb.TABLE_NAME,
    Col.Column_Name,
    Constraint_Type
    from
    INFORMATION_SCHEMA.TABLE_CONSTRAINTS Tab,
    INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE Col
    WHERE
    Col.Constraint_Name = Tab.Constraint_Name
    AND Col.Table_Name = Tab.Table_Name
    AND Constraint_Type = ''PRIMARY KEY''
    AND Tab.Table_Name = ''' + @YourTableName + '''
    --PRINT @SQLString
    EXECUTE sp_executesql @SQLString
    GO
    A Fan of SSIS, SSRS and SSAS
    Didnt understand why you need to make it dynamic here
    There's nothing which requires the query to be dynamic as per the above
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Key value does not currently exist in the primary key table error

    Im testing out a form and creating a new insert once all the fields are filled in it wont allow me to move on and comes up with this error message;
    key value does not currently exist in the primary key table
    Is this becuase the form contains foriegn keys which reference different tables which fields are not dispalyed on this form?
    If so how to I link the other forms together so that when i create a new record in this form it will automaticaly create the primary key entry in the other form to allow the insert of the referenced foreign key in this form?
    does this make sense?

    It seems that it has the table in which you'r inserting is a foreign key table.
    Take the emp& dept table example in the schema scott/tiger.
    Say we have deptno 10, 20, 30, 40 in the dept table.
    We make a form for emp table and insert into this form.
    Now, we'r bound to insert deptno 10, 20, 30, 40 into this emp form. This form will not allow us to insert deptno 50 as it doesn't exist in the primary key column in dept table.
    Obviously if a department doesn't exist in the company, it doesn't make sense to assign the employees to that department.
    So for this purpose, we need to add a department in the dept table then we can insert values in the emp table for that department.
    For this purpose, I suggest to make a button on the mp form and invoke the dept form and add a new department to it and then insert into emp table.
    The same scenario can be applied in your case.

  • Key in View  for two primary keys tables

    Hi
    I have some view joining LIKP and LIPS:
    LIKP -   Primary Key MANDT, VBELN
    LIPS -   Primary Key MANDT, VBELN, POSR
    The Key for the LIKP-LIPS View is:
    MANDT      LIKP
    VBELN       LIKP
    MANDT_I    LIPS
    VBELN_I    LIPS
    POSNR_I   LIPS
    So, for that Key, if i need to acces a specify LIPS detail record , must i fill all the keys in the where  (filling VBELN twice) like this:
    WHERE VBELN =  vbvalue AND VBELN_I =  vbvalue AND POSNR_I = posvalue ?
    How must i make the Select for acces this View using its Key ?
    Regards
    Frank

    Hi
    Just as I said:
    SELECT SINGLE * FROM Z<VIEW> WHERE VBELN = <VBELN>
                                                                AND POSNR_I = <POSNR>.
    Anyway it's should be better you correct the view deleting the field MANDT_I, VBELN_I, if you can't, I believe the select above works fine.
    VIEW FIELDS:
    View Field Table Field Key
    MANDT LIKP MANDT Yes
    VBELN LIKP VBELN Yes
    <b>MANDT_I LIPS MANDT Yes <----- WRONG
    VBELN_I LIPS VBELN Yes      <----- WRONG</b>
    POSNR_I LIPS POSNR Yes
    ERNAM LIKP ERNAM
    ERDAT LIKP ERDAT
    VKORG LIKP VKORG
    PSTYV_I LIPS PSTYV
    MATNR_I LIPS MATNR
    WERKS_I LIPS WERKS
    LGORT_I LIPS LGORT
    By this defintion the field MANDT and VBELN are only twice, but it doesn't mean the record is double in the VIEW.
    So it you have the delivery 100 with 3 items in the client 200, in the view you'll see:
    Record 1: MANDT   = 200
                   VBELN    = 0000000100
                   MANDT_I = 200
                   VBELN_I  = 0000000100
                   POSNR_I = 000010
    Record 2: MANDT   = 200
                   VBELN    = 0000000100
                   MANDT_I = 200
                   VBELN_I  = 0000000100
                   POSNR_I = 000020
    Record 3: MANDT   = 200
                   VBELN    = 0000000100
                   MANDT_I = 200
                   VBELN_I  = 0000000100
                   POSNR_I = 000030
    Max

  • Two column primary keys

    Hello,
    I am using two columns for my primary key. However when I crate a report and form pages, it doesn't work. The report page shows up but when I click on the edit icon next to each record it gives an error message.

    Zahid Khan wrote:
    Hi User (very common name!),
    In the following simple page I am using empno and hiredate columns as primary key:
    http://apex.oracle.com/pls/otn/f?p=9396:10
    It would be easier to help you if you set up an example on OTN.
    Thanks,
    ZahidDear Zahid,
    I looked at the application example you provided and the way the trigger ensures the trunc function is called on the date field before writing it to the db table, so the date retrieved from the db looks exactly the same as the date inserted.
    CREATE TABLE "EMP_DATE_KEY"
    (     "EMPNO" NUMBER,
         "ENAME" VARCHAR2(10),
         "HIREDATE" DATE,
         "SAL" NUMBER,
         "DEPTNO" NUMBER,
         CONSTRAINT "PK_EMP_DATE_KEY" PRIMARY KEY ("EMPNO", "HIREDATE") ENABLE
    CREATE OR REPLACE TRIGGER "BIUD_EMP_DATE_KEYS"
    before insert on emp_date_key
    for each row
    begin
    select nvl(max(empno),0)+1, trunc(sysdate)
    into :new.empno, :new.hiredate from emp_date_key;
    end;
    ALTER TRIGGER "BIUD_EMP_DATE_KEYS" ENABLE
    Line: --------
    However the database I am dealing with has not used the trunc function when creating the date field values and the primary key, by the way this db is very old and has a lot of data in it.
    any suggestions?
    Thanks,
    user

  • Another user has changed the row with primary key -Table changed externally

    Hello,
    I am facing the error: "Another user has changed the row with primary key oracle.jbo.Key[94 ]." during the delete operation.
    User case scenario:
    1. Added new row in the table.
    2. Once new row is added to the the table, another application will update few columns in the newly added row based on some logic.
    3. On the same session I am trying to delete the newly added row and getting above mentioned error.
    I have added a "Button" in the table to partialRefresh the table to check the new values of the changed columns.
    I have checked the forum and found many similar errors and tried the following but nothing helped.
    1. By setting "Auto Refresh = True" for the view object.
    Issue faced-> It worked fine but after few add and remove my db is getting to inconsistent state after which, I am not able to do any add/delete from my page.
    Error: "Too many objects match the primary key oracle.jbo.Key". I have checked this and I am not getting this error when "Auto Refresh = False" even after multiple add and remove actions.
    2. By Setting "Auto Refresh" the iterator associated with the page.
    Issue -> Did not work at all.
    Looking forward inputs from gurus.
    Thanks
    Abhijeet

    Finally I found one solution to this problem at: [ http://www.avromroyfaderman.com/2008/05/bring-back-the-hobgoblin-dealing-with-rowinconsistentexception/|http://www.avromroyfaderman.com/2008/05/bring-back-the-hobgoblin-dealing-with-rowinconsistentexception/]
    Simply overriding the lock() method in the entity object resolved issue. Kudos to the author.
    Code:
    public void lock() {
    try {
    super.lock();
    } catch (RowInconsistentException e) {
    refresh(REFRESH_WITH_DB_ONLY_IF_UNCHANGED | REFRESH_CONTAINEES);
    super.lock();
    But, Now my refresh button is not working as depend on the "Auto Refresh = True" to update the table.
    Can anyone tell me how can I refresh the VO of my table from the button.
    Thanks
    Abhijeet.
    P.S: I have already added the partial trigger but it is work not working as the data is cached in the VO. Removing the Cached property for the VO is creating other problems.

  • USE ROWID AS PRIMARY KEY OF ENTITY ON EJB3

    When we launch the Create Entities from Tables wizard, and create JPA (Java Persistence API) entities from existing database tables, if the table has no primary key and unique key field, you will get a warning. When you run, you will get the following information:
    Caused by: Exception [TOPLINK-7161] (Oracle TopLink Essentials - 2006.8 (Build 060829)): oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: Entity class [class model.Test] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass.
    Actually, every row of oracle table has a ROWID field , I think it is a good “primary key field”. Add it into Entity Java bean file as following:
    @Id
    private ROWID rowid;
    And generate accessors, ok, run……
    GOOD, No problem.
    But when you insert a new row, got an exception:
    Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2006.8 (Build 060829)): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00928: missing SELECT keyword
    Error Code: 928
    Call:INSERT INTO TEST (ROWID, B, A) VALUES (?, ?, ?)
         bind => [null, 555, 555]
    Query:InsertObjectQuery(model.Test@40979b)
    555~~~, what happened?! Somebody builds a wrong SQL …
    Don’t worry! I know (…) where is the “bug”.
    Find out the class
    oracle.toplink.essentials.internal.expressions. SQLInsertStatement
    which is included in the toplink-essentials.jar,
    decompile… , fix…, compile, and jar it back.
    Fix
    if(field.getTable().equals(getTable()) || !field.hasTableName())
    to
    if((field.getTable().equals(getTable()) || !field.hasTableName()) && !field.getName().equalsIgnoreCase("ROWID"))
    OK, it is running well.
    I suggest ORACLE fix it into his next version. Do you think it is a good idea?

    Do you think it is a good idea? Not really, but that's just my two cents.

  • Use of custom primary key using OSM Activation Tasks

    Hi,
    We are using OSM Activations Task to interact with ASAP. By default it uses OSM_ORDER_ID.HIST_ID as the corelation key and same as primary key while sending the request to ASAP. Is there a way we can customize this logic so as to send a custom value as the primary key to ASAP.

    Navid,
    A dropdown list can have only one value, so this is not possible. As a (dirty) work around you could introduce a transient attribute that concatenates the two PK values with for example a dash separating the two values, and base your drop down list on this transient attribute. In the setter method of this attribute you can then extract the two values and call the setters of the two PK attrs.
    Steven Davelaar,
    JHeadstart Team.

  • Reconciling composite primary key tables in 9.0.1.4 DB app connector

    Hi
    I am trying to get the reconciliation in the 9.0.1.4 db app connector to work on a view that has a composite primary key (one user_id field and one group_id field)
    There are no examples on how to do this and my "trial-and-error" efforts have not been fruitful this far. Anyone that has any experience of how to solve this problem?
    Best regards
    /Martin

    Hi Martin, our customer is also very sensitive to changes in his HR system, it is a custom oracle development. He provide us a read only view every day with all changes on their identities. We have developed a custom pl/sql proccess to fill a custom local table with the right information . Then we use this table locally with dbtable connector but with some custom addons.
    So i believe that using a second table and keep in synch it is the best approach.
    We have detect some problem with 9.0.1.4 DB app connector, it is using internally only one db connection for all its operations, in a huge load condition its can produce errors and race condition problems. We have a custom connector now and it is using connection pool from application server so we will have not this problem.
    I believe that oracle should release source for their connectors, i am very sure that partners and customers can improve it.

  • Testing for unique records in a compound Primary Key table

    I have a table with 2 fields being primary keys. I want to write a sql script to check if there are duplicates.
    Here is what I have but not sure if this is working right. I have table with millions of records.
    SELECT COUNT(CASE WHEN A.AUNQ >1  THEN 1 ELSE NULL END)
    FROM
    SELECT (List_Cd + Account_Key) PK_ListAcc, COUNT(List_Cd) AUNQ
    FROM RAW_AML_LISTEDACCNTS_JUN GROUP BY List_Cd, Account_Key HAVING (COUNT(List_Cd) >1))
     A;
    Can someone help?
    thanks

    Yes, I agree. I am doing data profiling and testing all these tables. I am expecting that the results show me zero, however, if there were any problems with the settings, then I should get something. I think that the subquery is needed because if I used
    what you suggested above I will get the following:
    List_CD    Account_Key
    1                    a
    2                    b
    3                    c
    3                    C
    1                    a
    1                    a
    the results will be:
    List_CD    Account_Key    CountOFAccount_Key
    1                    a                       
    3
    3                    C                       
    2
    I now need to count that query results to get the total which should be 2
    do you agree? I am just trying to confirm that the sql script I listed will give me this result correctly.

  • Can I use two  non-apple displays on my G5? Is there an adaptor for this?

    I found a great deal on two non-Apple wide screen displays. I can hook up one to my G5 via the DVI port but can't use the second port--typically used by an Apple Display. Is there an adaptor that I can use so that I can use my second non-apple display?

    <http://www.gefen.com/kvm/product.jsp?prod_id=1198>

  • Planning using the Non-Cumulative Key figures

    HI,
    In my reporting requirement for IP, I need to get some actual values from the cube 0IC_C03. The key figues which I required are 0VALSTCKVAL and 0TOTALSTCK, but these 2 are non-culative key figures. When I selected these 2 key figures in my aggregation level, it is throwing an error message as "InfoObject 0VALSTCKVAL(Version A) is not compounded and Aggregation level is inconsitent".
    I read in some document that, it is not possible to use non-cumulative keyfigures in ALVL.
    I searched in SDN and SERVICE also, but some documents are saying that, in new path level (19) it is possible. Now I using the path level 18 only. In this case how we have to use these non-cumulative keyfigues,, please sugguest me...
    Thanks in advance...
    Regards
    Rajesh

    Hi
    Non-cummulative keyfigures are not supported fro planning and teh error thrown is correct.Please find the help link which gives what are supported and not supported as part of aggregation levels.
    http://help.sap.com/saphelp_nw70/helpdata/EN/43/1c3c7031b70701e10000000a422035/content.htm
    Regards, Hyma

Maybe you are looking for