SSAS 2008 Linking two cubes on the foreign key between two fact tables

Hi, all -- 
I have two cubes:
Cube 1 has Fact1 (F1, "Events") and 3 dimensions (D1, D2, D3)
Cube 2 has Fact2 (F2, "Sales") and 3 dimensions (D4, D1, D6)
As you can see, two cubes reuse D1 as their common dimension.  In addition, F2 foreign keys into F1, e.g. F1 is "Events", and F2 is "Sales".  Every "sale" is an "event", but not every "event" is
a "sale".
The question is, how to I link the two cubes and their two respective fact tables on the foreign key?
Thanks, Austin.

Hi Austin,
According to your description, you want to retrieve data from two different cubes, right? In Analysis Services, to query multiple cubes from a single MDX statement you can use the LOOKUPCUBE function (you can't specify multiple cubes in your FROM statement).
The LOOKUPCUBE function will only work on cubes that utilize the same source database as the cube on which the MDX statement is running. For the detail information about it, please refer to the link below to see the blog.
Retrieving Data From Multiple Cubes in an MDX Query Using the Lookupcube Function
If I have anything misunderstood, please point it out.
Regards,
Charlie Liao
TechNet Community Support

Similar Messages

  • How to link two fact table in OBIEE

    i experts
    1. I have one fact table EXCHANGE_FACT(Contains the exchange rate for each curruncy on each day) .
    2. I Have anothe fact Table ACCOUNT_FACT(Contains Amount for each currency on each day).
    Now i have to link these two table on bace of currency_key and time_key in OBIEE. so i have can i achieve it in OBIEE.
    Regards
    Frnds

    Hi Frnds,
    You should create two common dimensions (currency en time) and join each fact table seperately to these dimension. Create a demnsion (hierarchy) for each dimension.
    Good Luck,
    Daan Bakboord
    Scamander Solutions

  • How to determine the logical Keys of logical fact table in BMM layer?

    Hello guys
    I'd like to know more about how to know what columns of the logical fact table should be used as key in BMM layer. How OBIEE behaving differently when different keys are selected?
    In my situation, I have 1 fact table that physically joins to 20 dimensions in physical layer. Therefore, in physical layer, this fact table has about 20 foreign keys but no primary keys..
    In the logical layer, this fact table is logically joined to the same group of dimension tables. So in this case, how do I know what columns in logical fact table I should use as keys?
    Please advice
    Thanks

    thanks for the reply...
    The interesting thing I notice is that, when I start using fragmentation with the fact tables in its LTS, if not primary key is defined in the logical fact table, then I will be getting errors:
    [nQSError: 10058] A general error has occurred. [nQSError: 14023] None of the fact sources for columns are compatible with the detail filter []. (HY000)
    When I create the key by choosing random columns from the fact table as the logical key columns, this error goes way and the correct SQL is generated according to the frag..
    Because of such behavior, I'd really like to know how logical key really works in BMM layer.

  • Foreign keys in logical fact

    Hi,
    Should I define foreign keys in logical fact table? I need to use "aggregation rule=count distinct" of the foreign key column in my reports.
    Thanks.
    Andy

    Hi Andy,
    You can add the foreign keys to your fact table as a measure column (count distinct aggregation).
    Do not use these foreign keys to create foreign key joins in the logical layer. Always use complex joins (http://obibb.wordpress.com/2010/08/06/joins-in-oracle-bi-ee/)
    Good Luck,
    Daan Bakboord
    http://obibb.wordpress.com

  • Foreign Keys for a Logical Table

    Hi All,
    I want to know in which scenarios we create the Foreign Keys for a Logical Table. Once we create the foreign key for the logical table, does it mean that it will automatically override if any joins are there.
    Physical Table A, B ( no physical joins)
    Logical Table A, B (logical join B(Dim)-->A(Fact))
    created the foreign key in logical table A with B .(A.1=B.1)
    Will the rpd generate sql with A.1=B.1 join condition for reports.
    I tried to create the logical foreign key for logical table A, I could not see any corresponding table option.Here is its snapshot
    http://tinypic.com/r/jq1gkz/6
    Thanks,
    Virat

    In general when we go complex joins in Physical layer we go for Logical foreign key joins in BMM layer, best examples is SCD Type-II.
    Physical Table A, B ( no physical joins)
    -->You need to have a physical join so that this can be override by BMM layer
    created the foreign key in logical table A with B .(A.1=B.1) Will the rpd generate sql with A.1=B.1 join condition for reports.
    -->Yes you can see this join in BI Physical query.
    I tried to create the logical foreign key for logical table A, I could not see any corresponding table option.Here is its snapshot
    -->2 cases: 1)You need to delete existing logical joins 2) You might not have join in physical layer.
    Hope this helps
    Let me know for issues
    Edited by: Srini VEERAVALLI on Jan 18, 2013 1:29 PM
    BTW: You got very good name, why dont you update in your profile to see your name instead of some number
    Edited by: Srini VEERAVALLI on Jan 18, 2013 1:29 PM

  • Designing a cube with two Fact tables

    Hi,
    I am new to multi-dimensional modeling. I am trying to define a cube with two fact tables which have many to many relationship. so I came up with following schema:-
    I want to design a cube so that I can get the count of "FactOne" items which are related to "FactTwo" items having particular status. So, I want to get the count of "FactOne" where they are related to items in "FactTwo"
    which have "Status1". Could anyone please guide me how would I do it?
    Thanks

    Hi Ahsan,
    In your scenario, there are tow fact tables on your Data Source View, and now what you want is that "count of FactOne" which are related to "FactTwo" in a particular status, right?
    It seem that you have find a blog that describes how to select facts with reference dimension on you another thread. As per my understanding, you can follow that blog to achieve your requirement.
    http://bifuture.blogspot.com/2011/11/ssas-selecting-facts-with-reference.html
    Regards,
    Charlie Liao
    If you have any feedback on our support, please click
    here.

  • How to create a ROLAP Cube that has two fact tables.

    I want to know if it is possible to create a ROLAP Cube with two fact tables.
    Suppose that I have these two star schemas:
    The first star schema has only a measure and a time dimension. The time dimension has three levels (Year -> Month -> Day)
    The second star schema has the same measure of the first schema and a time dimension. In this schema the time dimension has only two levels (Year -> Month). The values of the measure of this schema come from the first schema, this is, the value of the measure for a defined year and month results of the sum of all fact values of the first schema, that have the same year and month.
    I want to know if is possible to create a ROLAP cube that can get the information of the two star schemas, according to the level that the user are consulting.
    For example, if the user consults the cube with "OracleBI Spreadsheet Add-In", and if the user is consulting the first two levels (Year and Month), then the ROLAP cube would get the information of the second star schema.
    But if the user does a drill down in a month to get information of the days, then the ROLAP cube would get the information of the first star schema.
    Is it possible to do this?
    Regards,
    Rui Torres

    I'm not exactly sure what you want to do. Sorry if I get this wrong.
    You have two fact tables, one with data values at the day, month and year levels and a second fact table with data values at just the month and year levels. If this is the case, in the CWM2 APIs or OWB Paris, you would create a view that joins the two tables together and then map this view to the ROLAP cube.
    For CWM2 details, please refer to the Oracle OLAP Reference.

  • Problem to insert id into the foreign key  php/mysql

    Hello all,
    I'm having rouble to understand the process and there is no tutorial about my problem anywhere
    I have two table:
    Table 1 (member) with id, name, phone etc
    Table2 (post) add_id, title, description, price, member_id
    I got a form to post the add and I need to insert the id of table 1 into my table 2 member_id zone
    Fisrt I did the recorset to get user id
    $colname_rsMember = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_rsMember = $_SESSION['MM_Username'];
    mysql_select_db($database_connect, $connect);
    $query_rsMember = sprintf("SELECT * FROM member WHERE username='".$_SESSION['MM_Username']."'")or die(mysql_error());
    $rsMember = mysql_query($query_rsMember, $connect) or die(mysql_error());
    $row_rsMember = mysql_fetch_assoc($rsMember);
    $totalRows_rsMember = mysql_num_rows($rsMember);
    This part is working and I'm able to retreive info via echo just for testing
    After this code I have my insert code
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
      $insertSQL = sprintf("INSERT INTO add (title, `description`, price, member_id) VALUES (%s, %s, %s, %s)",
                           GetSQLValueString($_POST['title'], "text"),
                           GetSQLValueString($_POST['description'], "text"),
                           GetSQLValueString($_POST['price'], "text"),
                           GetSQLValueString($_POST['member_id'], "int"));
      mysql_select_db($database_connect, $connect);
      $Result1 = mysql_query($insertSQL, $connect) or die(mysql_error());
      $insertGoTo = "ok.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    Do I need to include hidden field in y form?
    I'm having the same error message. Col member_id can't not be null
    Any idea what I'm doing wrong?
    Thank You!

    When someone logs in, Dreamweaver creates a session variable called $_SESSION['MM_Username']. Use that session variable to create a recordset to get the user's ID, which can then be entered into the foreign key field of the child table.
    Dreamweaver automatically puts the code for recordsets immediately above the DOCTYPE declaration, so you will need to move it above the code for the Insert Record server behavior. So, it needs to be in this order:
    Recordset to get user ID
    Insert Record for child table

  • Populate the foreign key automatically

    HI All!
    I have a form in which there are two data blocks One is emp_master and other is salary_details.I have a foreign key salary_code in Emp_master and similarly Salary_code as primary key in salary details.I have used two list item in place of Emp_id and Salary_code.I want that when I select the emp_id as 10 from the list automatically salary_code list item should get populated by 1 item in the list item.Similary the rest should follow .Please someone look into this matter it would be a gr8t help to me.
    Thanks

    Abha,
    I would not use list items for this. Instead, use a multi-record text box with a scroll bar. It looks and behaves like a t-list, but is much easier to code and manage.
    Use the datablock wizard to create the master-detail relationship. When you use the wizard, all the code will be generated for you. Then use the layout wizard, and display multiple records with scroll bars.
    BTW, it is customary to have the primary key in the master, and the foreign key in the details. In your case it is backwards.
    Also see
    http://www.oracle.com/technology/obe/obe_as_10g/bi/forms/formsmasterdetailobe.htm

  • Foreign-key autocreation in child table giving issue in the application

    Hi,
      I am facing an issue with partitioning a table that foreign key relationship is created on the original table with interim table. This gives exception in the application because of its existence. Please suggest me how to get rid of this issue.
    Let's say my table T_TABLENAME has to be partitioned. It has a child table T_CHILD_TABLENAME which references (FK_T1) ID column of T_TABLENAME.
    While partitioning, COPY_TABLE_DEPENDENTS function copies/creates the key/index/trigger objects for the interim table. [I need copy_constraints => TRUE in COPY_TABLE_DEP call], Fine.
    But, after partitioning is done, the foreign key (TMP$$_FK_T1) object exists with the child table which should absolutely not happen as this forms dependency with interim table as well along with parent table.
    Here my script goes:
    i) Creating interim table
    CREATE TABLE T_TABLENAME_PT
    PARTITION BY RANGE (CREATED_DATE)
    (PARTITION P_2007 VALUES LESS THAN (TO_DATE('01-JAN-2008','dd-MON-yyyy')),
    PARTITION P_2009 VALUES LESS THAN (TO_DATE('01-JAN-2010','dd-MON-yyyy')),
    PARTITION P_2011 VALUES LESS THAN (TO_DATE('01-JAN-2012','dd-MON-yyyy')),
    PARTITION P_2012 VALUES LESS THAN (TO_DATE('01-JAN-2013','dd-MON-yyyy')),
    PARTITION P_RECENT VALUES LESS THAN (MAXVALUE))
    AS SELECT * FROM T_TABLENAME WHERE 1=2;
    ii) Partitioning Script
    declare
      v_username varchar2(50);
      v_exception varchar2(220);
      l_num_errors PLS_INTEGER;
      v_source_table  varchar2(35) := 'T_TABLENAME';
      v_interim_table varchar2(35) := 'T_TABLENAME_PT';
    BEGIN
      select USERNAME into v_username from USER_USERS where rownum <= 1;
      begin
          DBMS_REDEFINITION.CAN_REDEF_TABLE(v_username, v_source_table, DBMS_REDEFINITION.CONS_USE_PK);
          DBMS_REDEFINITION.START_REDEF_TABLE(
            uname      => v_username,
            orig_table => v_source_table,
            int_table  => v_interim_table);
          DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS(
            uname      => v_username,
            orig_table => v_source_table,
            int_table  => v_interim_table,
            copy_indexes => 1,
            copy_triggers => TRUE,
            copy_constraints => TRUE,
            copy_privileges => TRUE,
            ignore_errors => TRUE,
            num_errors => l_num_errors);
          DBMS_REDEFINITION.SYNC_INTERIM_TABLE(v_username, v_source_table, v_interim_table);
          begin
           DBMS_REDEFINITION.FINISH_REDEF_TABLE(
            UNAME      => v_username,
            ORIG_TABLE => v_source_table,
            INT_TABLE  => v_interim_table);       
         EXCEPTION
         WHEN OTHERS THEN
           DBMS_REDEFINITION.ABORT_REDEF_TABLE(
            UNAME      => v_username,
            ORIG_TABLE => v_source_table,
            INT_TABLE  => v_interim_table);
          end;     
          exception
              when others then
                v_exception :=substr(SQLERRM,1,150);
      end;
    exception
      when others then
        v_exception := substr(SQLERRM,1,175);
    END;

    Thanks for your information. I am using Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit.
    1) I am logging the exceptions in a logger table.
    2) If CAN_REDEF_TABLE gives exception, flow goes to the final EXCEPTION block and program terminates. So if no exceptions, the other steps comes into the flow of execution.
    Complete Details
    (1) Parent Table (existing): T_SOH_SUBREQ_INSTALLATION_ADDR
    create table T_SOH_SUBREQ_INSTALLATION_ADDR
      ACCOUNT_ADDRESS_ID  NUMBER(10),
      SUBREQ_ADDRESS_ID   NUMBER(10) not null,
      COMMUNITY_ID        NUMBER(10),
      STREET_ID           NUMBER(10),
      BUILDING_ID         NUMBER(10),
      CREATED_USER_ID     VARCHAR2(40) not null,
      MODIFIED_USER_ID    VARCHAR2(40) not null,
      CREATED_DATE        TIMESTAMP(6) not null,
      MODIFIED_DATE       TIMESTAMP(6) not null,
      DELETION_STATUS     CHAR(1) not null
    alter table T_SOH_SUBREQ_INSTALLATION_ADDR
      add constraint PK_T_SOH_SUBREQ_INST_ADDR primary key (SUBREQ_ADDRESS_ID);
    alter table T_SOH_SUBREQ_INSTALLATION_ADDR
      add constraint FK_T_SOH_SUBREQ_INSTALLATIO624 foreign key (ACCOUNT_ADDRESS_ID)
      references T_SOH_ACCT_INSTALLATION_ADDR (ACCOUNT_ADDRESS_ID);
    (2) Child Table (existing): T_SOH_SUBREQ_LINKED_INST_ADDR
    create table T_SOH_SUBREQ_LINKED_INST_ADDR
      CREATED_DATE      TIMESTAMP(6) not null,
      CREATED_USER_ID   VARCHAR2(40) not null,
      MODIFIED_DATE     TIMESTAMP(6) not null,
      MODIFIED_USER_ID  VARCHAR2(20) not null,
      DELETION_STATUS   CHAR(1) not null,
      SUBREQ_ADDRESS_ID NUMBER(10) not null,
      SUBREQUEST_ID     NUMBER(10) not null,
      CIRCUIT_POINT     NUMBER(10)
    alter table T_SOH_SUBREQ_LINKED_INST_ADDR
      add constraint PK_T_SOH_SUBREQ_LINK_INST_ADDR primary key (SUBREQ_ADDRESS_ID, SUBREQUEST_ID);
    alter table T_SOH_SUBREQ_LINKED_INST_ADDR
      add constraint FK_T_SOH_SUBREQ_LINKED_INST626 foreign key (SUBREQ_ADDRESS_ID)
      references T_SOH_SUBREQ_INSTALLATION_ADDR (SUBREQ_ADDRESS_ID);
    (3) Partitioning is done on Parent Table
    CREATE TABLE T_TMP_PARTITION_LOGS
      LOG_MSG  VARCHAR2(250),
      LOG_TIME TIMESTAMP(6)
    CREATE TABLE T_SOH_SUBREQ_INSTALL_ADDR_PT
    PARTITION BY RANGE (CREATED_DATE)
    (PARTITION P_2007 VALUES LESS THAN (TO_DATE('01-JAN-2008','dd-MON-yyyy')),
    PARTITION P_2009 VALUES LESS THAN (TO_DATE('01-JAN-2010','dd-MON-yyyy')),
    PARTITION P_2011 VALUES LESS THAN (TO_DATE('01-JAN-2012','dd-MON-yyyy')),
    PARTITION P_2012 VALUES LESS THAN (TO_DATE('01-JAN-2013','dd-MON-yyyy')),
    PARTITION P_RECENT VALUES LESS THAN (MAXVALUE))
    AS SELECT * FROM T_SOH_SUBREQ_INSTALLATION_ADDR WHERE 1=2;
    insert into t_tmp_partition_logs(log_msg,log_time) values('01_CreateTable: T_SOH_SUBREQ_INSTALL_ADDR_PT Table Created', systimestamp);
    (4) Script for REDEFINITION
    declare
      v_username varchar2(50);
      v_exception varchar2(220);
      l_num_errors PLS_INTEGER;
      v_source_table  varchar2(35) := 'T_SOH_SUBREQ_INSTALLATION_ADDR';
      v_interim_table varchar2(35) := 'T_SOH_SUBREQ_INSTALL_ADDR_PT';
      v_file_name     varchar2(20) := '02_Redefine';
    BEGIN
      insert into t_tmp_partition_logs(log_msg,log_time) values(v_file_name || '.sql --> Starts', systimestamp);
      select USERNAME into v_username from USER_USERS where rownum <= 1;
      insert into t_tmp_partition_logs(log_msg,log_time) values(v_file_name || ': UserName-'|| v_username, systimestamp);
      begin
          DBMS_REDEFINITION.CAN_REDEF_TABLE(v_username, v_source_table, DBMS_REDEFINITION.CONS_USE_PK);
          insert into t_tmp_partition_logs(log_msg,log_time) values(v_file_name ||': '|| v_source_table ||' After CAN_REDEF_TABLE', systimestamp);
          DBMS_REDEFINITION.START_REDEF_TABLE(
            uname      => v_username,
            orig_table => v_source_table,
            int_table  => v_interim_table);
          insert into t_tmp_partition_logs(log_msg,log_time) values(v_file_name ||': '|| v_source_table ||' After START_REDEF_TABLE', systimestamp);
          DBMS_REDEFINITION.COPY_TABLE_DEPENDENTS(
            uname      => v_username,
            orig_table => v_source_table,
            int_table  => v_interim_table,
            copy_indexes => 1,
            copy_triggers => TRUE,
            copy_constraints => TRUE,
            copy_privileges => TRUE,
            ignore_errors => TRUE,
            num_errors => l_num_errors);
          insert into t_tmp_partition_logs(log_msg,log_time) values(v_file_name ||': '|| v_source_table ||' After COPY_TABLE_DEPENDENTS - l_num_errors:' || l_num_errors, systimestamp);
          DBMS_REDEFINITION.SYNC_INTERIM_TABLE(v_username, v_source_table, v_interim_table);
          insert into t_tmp_partition_logs(log_msg,log_time) values(v_file_name ||': After SYNC_INTERIM_TABLE on '|| v_source_table, systimestamp);
          begin
           DBMS_REDEFINITION.FINISH_REDEF_TABLE(
            UNAME      => v_username,
            ORIG_TABLE => v_source_table,
            INT_TABLE  => v_interim_table);       
          insert into t_tmp_partition_logs(log_msg,log_time) values(v_file_name ||': After FINISH_REDEF_TABLE on '|| v_source_table, systimestamp);
         EXCEPTION
         WHEN OTHERS THEN
           DBMS_REDEFINITION.ABORT_REDEF_TABLE(
            UNAME      => v_username,
            ORIG_TABLE => v_source_table,
            INT_TABLE  => v_interim_table);
           insert into t_tmp_partition_logs(log_msg,log_time) values(v_file_name ||': Aborted '|| v_source_table, systimestamp);
          end;     
        insert into t_tmp_partition_logs(log_msg,log_time) values(v_file_name ||': '|| v_source_table ||' redefined', systimestamp);
          exception
              when others then
                v_exception :=substr(SQLERRM,1,150);
                insert into t_tmp_partition_logs(log_msg,log_time) values(v_file_name ||'-EXCEPTION:'|| v_source_table ||'-' || v_exception, systimestamp);
      end;
      insert into t_tmp_partition_logs(log_msg,log_time) values(v_file_name ||'.sql <-- Ends', systimestamp);
    exception
      when others then
        v_exception := substr(SQLERRM,1,175);
        insert into t_tmp_partition_logs(log_msg,log_time) values(v_file_name ||'-EXCEPTION:' || v_exception, systimestamp);
    END;
    ==> NOW THE ISSUE
    My child table T_SOH_SUBREQ_LINKED_INST_ADDR is having another foreign key column TMP$$_FK_T_SOH_SUBREQ_LIN4 with the interim table T_SOH_SUBREQ_INSTALL_ADDR_PT.

  • Identifying the Foreign Keys

    How can I identify the Foreign Keys in a row ???
    Regards,
    Junior

    How can I identify the Foreign Keys in a row ???Junior:
    Are you referring to FKs of a View Row involved in a View Link? If so, a View Row could have multiple FKs if it is involved in multiple View Links.
    By writing MT (middle-tier) code, you can get the attribute list from the View Link. Note that this logic is only available in MT. If you need this info in the client, you can write this logic in MT and export it as a custom method that can be called from client.
          // Get the list of view links that this VO ('vo')
          // is involved in.
          String[] vls = vo.getViewLinkNames();
          // Get the View Link object.
          ViewLink vl = myAM.findViewLink(vls[0]);
          // Get the View Link definition.
          oracle.jbo.server.AssociationDefBase vlDef = (oracle.jbo.server.AssociationDefBase)
               ((oracle.jbo.server.ViewLinkImpl) vl).getDef();
          AttributeDef[] attrs;
          // Get the source side attribute definitions
          attrs = vlDef.getAttributeDefImpls();
          for (int j = 0; j < attrs.length; j++)
             System.out.println("  Attr: " + attrs[j].getName());
          // Get the destination side attribute definitions
          attrs = vlDef.getOtherAttributeDefImpls();
          for (int j = 0; j < attrs.length; j++)
             System.out.println("  Attr: " + attrs[j].getName());

  • I am unable to create the Foreign key

    Hi,
    I need to create the Foreign key which reffered to composite primary key.
    the following table structure
    Parent table
    DIVISION, PROJECT_NUMBER, COMPETITION_PROJECT_NUMBER, COMPETITIVE_STMT_TYPE, SEQUENCE, CATEGORY, STATEMENT, USER_ID, RECORD_MODIFICATION_DATE
    Here composite primary key columns(DIVISION, PROJECT_NUMBER, COMPETITION_PROJECT_NUMBER, COMPETITIVE_STMT_TYPE, SEQUENCE)
    Child Table
    DIVISION          VARCHAR2 (4)          
    PROJECT_NUMBER          NUMBER (10)COMPETITION_PROJECT_NUMBER     NUMBER (10)          
    COMPETITIVE_STMT_TYPE          VARCHAR2 (2)          
    SEQUENCE     NUMBER (2)          
    CATEGORY          VARCHAR2 (100)     
    STATEMENT     LONG          
    USER_ID     VARCHAR2 (100)          
    RECORD_MODIFICATION_DATE     DATE     
    ALTER TABLE COMPETITION_STMT ADD (CONSTRAINT COMPET_STMT_FK_PROJ_NUM foreign key
              (PROJECT_NUMBER) REFERENCES PROD_COMPET_XREF (PROJECT_NUMBER));
    when i am trying to create foreign key i got this error
    ORA-02270: no matching unique or primary key for this column-list
    this is production issue Please help me.
    Thanks in advance
    Regards
    Kumar.s

    ALTER TABLE PROD_COMPET_XREF ADD (
    CONSTRAINT PROD_COMP_XREF_PK_DPNCPNCT
    PRIMARY KEY
    (COMPETITION_PROJECT_NUMBER, PROJECT_NUMBER, DIVISION, PRODUCT_LOC_INDICATOR)
    When you create a foreign key, it must reference a unique or primary key. The primary or Unique key must consist ONLY of those columns upon which the Primary key is based.
    You must Alter the table and add a Unique key if you want to keep your compsite primary key constraint. The Unique key must be for only the column that your foreign key references. Then try to recreate your foreign key.
    I doubt you will be able to add a foreign key because I suspect you might have multiple rows with the same value for this column based on your composite key; however, if you only intend for the project number to be listed only once and to be unique for each row, then the unique key may work or you may want to revist your primary key on this table. Perhaps you don't need it to be a composite PK???
    If you can't work around that, one thing you can do is build a table based just on PROJECT_NUMBER that contains details about the project number and have other tables reference that. That is, if you have multiple rows with the same project number in that table. You may already have one? Perhaps you can build your foreign key to reference that?

  • Disable all the foreign keys in a database

    Hy, what sql to use to disable all the foreign keys in a database and how to enable all them again. Thanks

    select * from dba_constraints where constraint_type = 'R' and status = 'ENABLED'
    ALTER TABLE table_name
    disable CONSTRAINT constraint_name;
    ALTER TABLE table_name
    enable CONSTRAINT constraint_name;
    select
    'ALTER TABLE ' || OWNER || '.' || table_name || ' enable CONSTRAINT ' || constraint_name || ';'
    from dba_constraints where constraint_type = 'R' and status = 'ENABLED';
    Execute and save result for enable before disable
    select
    'ALTER TABLE ' || OWNER || '.' || table_name || ' disable CONSTRAINT ' || constraint_name || ';'
    from dba_constraints where constraint_type = 'R' and status = 'ENABLED';
    Execute result for disable.

  • How to retrieve the Foreign key information in Oracle

    I want to know how to retrieve the Foreign Key information in Oracle while using SQL Statement?
    I have use three SQL statement to retrieve such information, but the performance is very bad.
    The three SQL Statements are:
    Select constraint_name, r_constraint_name from all_constraints where constraint_type = 'R' and table_name = table1;
    Select column_name from all_cons_columns where constraint_name = cons1;
    Select table_name, column_name from all_cons_columns where constraint_name = r_ccons1;
    Do anyone know another method to retrieve the Foreign Key information which has better performance?

    These sql-statements don't seem very performance intensive. My guess is something is wrong with your database (unless you have millions of constraints). How many constraints do you have? how many concurrent users? What is your dictionary cach hitratio? (other hitratio?) memory problems? other tasks of the computer? is this query the only one being slow? etc.

  • Find which tables are linked to this one via foreign keys

    Hi, I need to drop & recreate a table, but this table is referenced by other tables via foreign key constraints.
    1. Is there a query I can run to find those tables (the ones referencing this one) ?
    2. What is the standard way to drop & recreate this table being referenced by others?

    1) You can try the following query:
    select r.owner, r.table_name
    from user_constraints r, user_constraints o
    where r.r_owner = o.owner and r.r_constraint_name = o.constraint_name
    and o.constraint_type in ('P','U') and r.constraint_type = 'R'
    and o.table_name = 'DEPT'
    2) To drop tables with references you can also use drop table cascade constraints,
    which will also drop constraints from tables:
    [email protected]> drop table dept;
    drop table dept
    ERROR at line 1:
    ORA-02449: unique/primary keys in table referenced by foreign keys
    [email protected]> drop table dept cascade constraints;
    Table dropped.
    Another way is to prepare a script which will remove the tables in proper order.
    Best Regards
    Krystian Zieja / mob

Maybe you are looking for

  • I can't open a PDF file with password with my iphone app

    I can't open a PDF file with password with my iphone app, the app send me an error, but the password is correct. This only happend in the new version of iphone. In the latest version I didn't have this problems.

  • JTable displays only default column headers

    Hello, after a tblModel.setDataVector(dataArray, (Object[])headers) I check the header with a System.out.println(tblModel.getColumnName(0)) and it's correct. But only the capitals A, B, C ... are displayed as headers. I am using a DefaultTableModel.

  • Changing the EJB connection not under OC4J

    Dear all, I am facing a problem that after I deploy an ejb from Jdev and using teh connection from the Jdev. It is working fine, however I found that the EJB is totally depends on the connection which I have setup from Jdev but not from the OC4J conn

  • What is the auxiliary constructs in sql

    I need some help to know what's the auxiliary constructs, and examples in the auxiliary constructs

  • Z BDC Field in the script

    Hello Gurus, We are working on Interactive script in the SAP CRM 7.0 and we are having a problem when a variable that comes from a non-standard BOL object is include in the script. This BOL is not used in any view and it is just used to show addition