Unique constraint on valid_to and valid_from dates

Suppose I have a table:
create table test (name varchar2(40), valid_from date, valid_to date);
insert into test values ('fred', to_date('01/04/2008', 'dd/mm/yyyy'), to_date('01/04/2008', 'dd/mm/yyyy');
insert into test values ('fred', to_date('04/04/2008', 'dd/mm/yyyy'), to_date('06/04/2008', 'dd/mm/yyyy');
insert into test values ('fred', to_date('08/04/2008', 'dd/mm/yyyy'), to_date('09/04/2008', 'dd/mm/yyyy');How can I enforce uniqueness such that at any one point in time, only one row exists in the table for each name?
eg. insert into test values ('fred', to_date('02/04/2008', 'dd/mm/yyyy'), to_date('03/04/2008', 'dd/mm/yyyy'); -- success!
insert into test values ('fred', to_date('02/04/2008', 'dd/mm/yyyy'), to_date('05/04/2008', 'dd/mm/yyyy'); -- fail!
insert into test values ('fred', to_date('01/04/2008', 'dd/mm/yyyy'), to_date('03/04/2008', 'dd/mm/yyyy'); -- fail!
insert into test values ('fred', to_date('05/04/2008', 'dd/mm/yyyy'), to_date('05/04/2008', 'dd/mm/yyyy'); -- fail!
insert into test values ('fred', to_date('07/04/2008', 'dd/mm/yyyy'), to_date('11/04/2008', 'dd/mm/yyyy'); -- fail!Is there a method using fbi's or unique constraints? I'd really rather avoid using triggers and pl/sql if I can, but I can't think of a way...
Message was edited by:
Boneist
Added some extra test conditions

How about this pair of indexes:
CREATE UNIQUE INDEX test_fromdate_idx ON test(name,valid_from);
CREATE UNIQUE INDEX test_todate_idx ON test(name,valid_to);Here is the test:
SQL> create table test (name varchar2(40), valid_from date, valid_to date);
Table created.
SQL> insert into test values ('fred', to_date('01/04/2008', 'dd/mm/yyyy'), to_date('01/04/2008', 'dd/mm/yyyy'));
1 row created.
SQL> insert into test values ('fred', to_date('04/04/2008', 'dd/mm/yyyy'), to_date('06/04/2008', 'dd/mm/yyyy'));
1 row created.
SQL> insert into test values ('fred', to_date('08/04/2008', 'dd/mm/yyyy'), to_date('09/04/2008', 'dd/mm/yyyy'));
1 row created.
SQL> CREATE UNIQUE INDEX test_fromdate_idx ON test(name,valid_from);
Index created.
SQL> CREATE UNIQUE INDEX test_todate_idx ON test(name,valid_to);
Index created.
SQL> insert into test values ('fred', to_date('02/04/2008', 'dd/mm/yyyy'), to_date('03/04/2008', 'dd/mm/yyyy'));
1 row created.
SQL> insert into test values ('fred', to_date('02/04/2008', 'dd/mm/yyyy'), to_date('05/04/2008', 'dd/mm/yyyy'));
insert into test values ('fred', to_date('02/04/2008', 'dd/mm/yyyy'), to_date('05/04/2008', 'dd/mm/yyyy'))
ERROR at line 1:
ORA-00001: unique constraint (TEST_USER.TEST_FROMDATE_IDX) violated
SQL> insert into test values ('fred', to_date('01/04/2008', 'dd/mm/yyyy'), to_date('03/04/2008', 'dd/mm/yyyy'));
insert into test values ('fred', to_date('01/04/2008', 'dd/mm/yyyy'), to_date('03/04/2008', 'dd/mm/yyyy'))
ERROR at line 1:
ORA-00001: unique constraint (TEST_USER.TEST_FROMDATE_IDX) violated
SQL> spool off;Hope this helps!

Similar Messages

  • Put a unique constraint on column if duplicate data is already present

    how to put a unique constraint on column if duplicate data is already present in that column?

    Hello,
    I have Oracle 10g and in this version documentation (SQL Reference) just says
    ENABLE NOVALIDATE ensures that all new DML operations on the constrained data comply with the constraint. This clause does not ensure that existing data in the table complies with the constraint and therefore does not require a table lock.
    So, as far as I understand, it does not guarantee that the constraint is really not validated:
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
    Connected as xxxx
    SQL>
    SQL> create table drop_me as
      2  select 1 as id from dual
      3  union all
      4  select 1 as id from dual;
    Table created
    SQL> alter table drop_me
      2  add constraint unq_id unique (id) enable novalidate;
    alter table drop_me
    add constraint unq_id unique (id) enable novalidate
    ORA-02299: cannot validate (XXXX.UNQ_ID) - duplicate keys found
    SQL>

  • Composite unique constraint on parent and child values?

    Is it possible to have a composite unique constraint containing values from child elements? The below example has the 'child' elements are out-of-line but this is preferred but optional, as I know you cannot have a unique constraint across tables without having a reference table containing the constraint and both columns. How does xdb handle this requirement?
    allowed:
    <parent ID="1">
       <child><name>test1</name></child>
       <child><name>test2</name></child>
    </parent>
    <parent ID="2">
       <child><name>test1</name></child>
       <child><name>test2</name></child>
    </parent>not allowed:
    <parent ID="1">
       <child><name>test1</name></child>
       <child><name>test1</name></child>
    </parent>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
               xmlns:xdb="http://xmlns.oracle.com/xdb"
               xdb:storeVarrayAsTable="true"
               elementFormDefault="qualified">
        <xs:element name="parent" type="Parent_T"
            xdb:columnProps="CONSTRAINT parent_pkey PRIMARY KEY (XMLDATA.ID)"
            xdb:defaultTable="PARENT"/>
        <xs:complexType name="Parent_T" xdb:SQLType="PARENT_T" xdb:maintainDOM="false">
            <xs:sequence>
                <xs:element name="child" type="Child_T" minOccurs="1" maxOccurs="unbounded" xdb:SQLName="CHILD"
                          xdb:SQLInline="false" xdb:defaultTable="CHILD" "/>
            </xs:sequence>
            <xs:attribute name="ID" xdb:SQLName="ID" use="required" />
        </xs:complexType>
        <xs:complexType name="Child_T" xdb:SQLType="CHILD_T">
           <xs:sequence>
             <xs:element name="name" type="xs:string" xdb:SQLName="NAME"/>
           </xs:sequence>
         </xs:complexType>    
    </xs:schema>xdb:columnProps="CONSTRAINT parent_pkey PRIMARY KEY (XMLDATA.ID),*UNIQUE(XMLDATA.CHILD.NAME)*" raises nonexistant attribute
    One possible solution would be to copy the value of the parent primary key to the child element, then I could create a composite unique constraint using only values from the child. However, I have this same requirement elsewhere in my schema nested further down, and it may become messy / bad design having to cascade all the primary keys down the schema. For example I have a recursive element in which two attributes need to be unique only within the parent:
    <parent id="1">
       <child a="1" b="1">
          <child a="1" b="2">
             <child a="1" b="1" /> *not allowed
          </child>
       </child>
       <child a="1" b="2" /> *not allowed
    </parent>Possible fix:
    <child a="1" b="2" parent_id="1" />
    <xs:complexType name="Child_T>
       <xs:sequence>
          <xs:element name="child" xsd:SQLInline="false" xsd:columnProps="UNIQUE(XMLDATA.a,XMLDATA.b,XMLDATA.parent_id)" minOccurs="0" maxOccurs="unbounded" type="Child_T">
       </xs:sequence>
       </xs:element
    </xs:complexType>Is there a better design?
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production                          
    CORE     10.2.0.4.0     Production                                      
    TNS for Linux: Version 10.2.0.4.0 - Production                  
    NLSRTL Version 10.2.0.4.0 - Production

    You can do something like this :
    SQL> DECLARE
      2 
      3    xsd_doc xmltype := xmltype('<?xml version="1.0" encoding="utf-8"?>
      4  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb">
      5    <xs:element name="name" xdb:SQLType="VARCHAR2">
      6      <xs:simpleType>
      7        <xs:restriction base="xs:string">
      8          <xs:maxLength value="30"/>
      9        </xs:restriction>
    10      </xs:simpleType>
    11    </xs:element>
    12    <xs:element name="child" xdb:SQLType="CHILD_T">
    13      <xs:complexType xdb:SQLType="CHILD_T" xdb:maintainDOM="false">
    14        <xs:sequence>
    15          <xs:element ref="name"/>
    16        </xs:sequence>
    17      </xs:complexType>
    18    </xs:element>
    19    <xs:element name="parent" xdb:SQLType="PARENT_T">
    20      <xs:complexType xdb:SQLType="PARENT_T" xdb:maintainDOM="false">
    21        <xs:sequence>
    22          <xs:element ref="child" maxOccurs="unbounded" xdb:SQLCollType="CHILD_COLL"/>
    23        </xs:sequence>
    24        <xs:attribute name="ID" type="xs:integer" use="required"/>
    25      </xs:complexType>
    26    </xs:element>
    27    <xs:element name="root" xdb:defaultTable="MY_XML_TABLE" xdb:SQLType="ROOT_T">
    28      <xs:complexType xdb:SQLType="ROOT_T" xdb:maintainDOM="false">
    29        <xs:sequence>
    30          <xs:element ref="parent" maxOccurs="unbounded" xdb:SQLCollType="PARENT_COLL"/>
    31        </xs:sequence>
    32      </xs:complexType>
    33    </xs:element>
    34  </xs:schema>');
    35 
    36  BEGIN
    37 
    38    dbms_xmlschema.registerSchema(
    39      schemaURL => 'test_parent.xsd',
    40      schemaDoc => xsd_doc,
    41      local => true,
    42      genTypes => true,
    43      genbean => false,
    44      genTables => false,
    45      enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_NONE
    46    );
    47 
    48  END;
    49  /
    PL/SQL procedure successfully completed
    SQL> CREATE TABLE my_xml_table OF XMLTYPE
      2  XMLTYPE STORE AS OBJECT RELATIONAL
      3  XMLSCHEMA "test_parent.xsd"
      4  ELEMENT "root"
      5  VARRAY xmldata."parent" STORE AS TABLE my_parent_tab
      6  (
      7    VARRAY "child" STORE AS TABLE my_child_tab
      8  )
      9  ;
    Table created
    SQL> ALTER TABLE my_parent_tab ADD CONSTRAINT parent_uk UNIQUE (nested_table_id, "ID");
    Table altered
    SQL> ALTER TABLE my_child_tab ADD CONSTRAINT child_uk UNIQUE (nested_table_id, "name");
    Table altered
    Then :
    SQL> insert into my_xml_table values (
      2  xmltype('<root><parent ID="1">
      3     <child><name>test1</name></child>
      4     <child><name>test2</name></child>
      5  </parent>
      6  <parent ID="1">
      7     <child><name>test1</name></child>
      8     <child><name>test2</name></child>
      9  </parent></root>')
    10  );
    insert into my_xml_table values (
    ERREUR à la ligne 1 :
    ORA-00001: violation de contrainte unique (DEV.PARENT_UK)
    SQL> insert into my_xml_table values (
      2  xmltype('<root><parent ID="1">
      3     <child><name>test1</name></child>
      4     <child><name>test1</name></child>
      5  </parent>
      6  <parent ID="2">
      7     <child><name>test1</name></child>
      8     <child><name>test2</name></child>
      9  </parent></root>')
    10  );
    insert into my_xml_table values (
    ERREUR à la ligne 1 :
    ORA-00001: violation de contrainte unique (DEV.CHILD_UK)
    SQL> insert into my_xml_table values (
      2  xmltype('<root><parent ID="1">
      3     <child><name>test1</name></child>
      4     <child><name>test2</name></child>
      5  </parent>
      6  <parent ID="2">
      7     <child><name>test1</name></child>
      8     <child><name>test2</name></child>
      9  </parent></root>')
    10  );
    1 ligne créée.http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb06stt.htm#sthref987

  • HOWTO: Add a UNIQUE constraint to a populated column

    Here is the way to add a unique constraint to a populated column, ensuring that the existing values are unique as well.
    ALTER TABLE t1
    ADD CONSTRAINT t1_uk UNIQUE (col1,col2)
    EXCEPTIONS INTO my_exceptions
    /If the alter table statement fails this will populate the MY_EXCEPTIONS table with the rows that contain duplicate values for (col1,col2). These are identified by ROWID. We can then chose to:
    [list]
    [*]delete rows with a bad key;
    [*]amend the values of the key columns;
    [*]re-apply the constraint with the NOVALIDATE option.
    [list]
    We should be wary of choosing the NOVALIDATE option. There's usually a good reason why the unique constraint is required and we should not circumvent it. Apart from anything else, Oracle allows us to build foreign keys referencing NOVALIDATE unique keys. This could result in child rows that have two parents, which is normal in biology, but very wrong in a database.
    NOVALIDATE is useful in datawarehouses and suchlike, because little updating occurs and the data integrity issues are of less imporatance. I don't think it ought to be used in OLTP situations. The code example at the end of this posting illustrates why we should exercise caution with NOVALIDATE.
    Once we have handled the duplicate values we can re-run the alter table statement and apply the constraint.
    If you don't already have an EXCEPTIONS table (it can be called anything, it's the structure that counts) you may need to run (or get a DBA to run) a script called UTLEXCPT.SQL, which will be in the $ORACLE_HOME/rdbms/admin directory.
    Cheers, APC
    SQL> SELECT col1, col2, col3 FROM t1;
          COL1       COL2       COL3                                               
             1          1          0                                               
             2          1          0                                               
             2          1          0                                               
    SQL> SELECT col1, col2, cola FROM t2;
          COL1       COL2 COLA                                                     
             1          1  I'm child #1                                                        
             1          1  I'm child #2                                                        
             2          1  I'm child #3                                                        
    SQL> ALTER TABLE t1
      2  ADD CONSTRAINT t1_uk UNIQUE (col1, col2);
    ALTER TABLE t1 ADD CONSTRAINT t1_uk UNIQUE (col1, col2)
    ERROR at line 1:
    ORA-02299: cannot validate (TST2.T1_UK) - duplicate keys found We can't add a unique key, so we decide to use the NOVALIDATE clause.
    SQL> CREATE INDEX t1_i ON t1(col1, col2);
    Index created.
    SQL> ALTER TABLE t1
      2  ADD CONSTRAINT t1_uk UNIQUE (col1, col2) ENABLE NOVALIDATE;
    Table altered.
    SQL> INSERT INTO t1 VALUES (2, 1, 1);
    insert into t1 values (2, 1, 1)
    ERROR at line 1:
    ORA-00001: unique constraint (TST2.T1_UK) violated Well, we can't add any more duplicate keys, so that's alright isn't it? Nope. We can add a foreign key to table T2 referencing T1 but we don't know which row in T1 is the parent of the rows in T2.
    SQL> ALTER TABLE t2
      2  ADD CONSTRAINT t2_t1_fk foreign key  (col1, col2)
      3  REFERENCES t1(col1, col2)
    Table altered.
    SQL> SELECT rowid FROM t1 WHERE col1 = 2;
    ROWID                                                                          
    AAAVnMAANAAAB96AAB                                                             
    AAAVnMAANAAAB96AAC                                                             
    SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAB';
    1 row deleted.
    SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAC';
    DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAC'
    ERROR at line 1:
    ORA-02292: integrity CONSTRAINT (TST2.T2_T1_FK) violated - child record found
    SQL> ROLL
    Rollback complete.
    SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAC';
    1 row deleted.
    SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAB';
    DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAB'
    ERROR at line 1:
    ORA-02292: integrity CONSTRAINT (TST2.T2_T1_FK) violated - child record found
    SQL>  ROLL
    Rollback complete.
    Why this matters: queries joining child and parent tables return more rows than we'd expect normally.
    SQL> SELECT t2.cola
      2  FROM   t2
      3  WHERE  t2.col1 = 2
      4  and    t2.col2 = 1;
    COLA                                                                           
    I'm child #3                                                                   
    SQL> SELECT t2.cola, t1.col4
      2  FROM   t1, t2
      3  WHERE  t2.col1 = 2
      4  AND    t2.col2 = 1
      5  AND    t1.col1 = 2
      6  AND    t2.col2 = 1;
    COLA                    COL4                                                   
    I'm child #3            I'm the daddy                                          
    I'm child #3            No, I'm the daddy!!                                    
    SQL> Caveat emptor
    This posting is issued on behalf of the Rogue Moderators. It is posted with the best of intentions but is not guaranteed in any way, shape or form. In particular, the code is presented "as is" and you assume full responsibility for running it on your system. Furthermore, you must not download and install software from the internet unless you know what you are doing and have the permission of whoever owns your system. It was never this hard for the Lone Ranger.

    Hi,
    You can not create unique key with duplicate values as you know. Now if you want to create unique key then you have to delete duplicate records from the table but this again if you can afford to delete because this data may be more importante to you and you can not delete any record.
    or you can use ENABLE NOVALIDATE option of oracle explain by Tom on below link.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:8806498660292
    or if you dont want to use Tom's way then you go with primary key like
    Drop old primary key if there is already on the column.
    create new primary key with enable novalidate option.

  • Mapping failed due to Unique Constraint

    Hi,
    We are using Oracle Financial Analytics and noticed that one of the mapping SIL_PositionDimenstionHierarchy failed due to Unique Constraint.
    Mapping was inserting data into W_POSITION_DH table.
    Is there a way to find the source table from where it is inserting the record?
    I don't have much Informatica experience.
    Thanks,
    Poojak

    Hi,
    Our servers are hosted to Oracle On Demand. I have opened a ticket with Oracle. They have asked us to aply a patch to increase the version of the Mapping.
    Please see update from Analyst.
    "Development team is requesting to apply patch number 9782718, which solves this issue as well.
    You need to go to Patches and Updates tab on Support Portal, click on Oracle, Siebel and Hyperion products link and do a simple search with patch number 9782718. The patch files contain detailed instructions.
    Please test on your Test environment first before applying to Production. Let us know if you have any issues.
    Thanks,
    Poojak

  • Unique Constraint on a Table

    I want to have a unique constraint on deptno and emp_name in emp table.
    What I want is:
    Any Dept can have 100 Steves OR 100 Johns but only 1 Robert
    Dept No               Emp Name     
    10               Steve
    10               Steve
    10               Robert
    20               Steve
    20               Robert
    20                John
    20               John
    How can we achieve this with unique constraint??
    Cheers
    Prasad.

    You are talking about unique constraint and you want to have duplicate records in a column with unique constraint. No, what you want is not possible with unique constraint. When you have a unique constraint on emp_name, how can you have 100 johns or 100 steves. Forget about 100, you can't have the second john/steve.

  • Performance Impact of Unique Constraint on a Date Column

    In a table I have a compound unique constraint which extends over 3 columns. As a part of functionality I need to add another DATE column to this unique constraint.
    I would like to know the performance implications of adding a DATE column to the unique constraint. Would the DATE column behave like another VARCHAR2 or NUMBER column, or would it degrade the performance significantly?
    Thanks
    Message was edited by:
    user627808

    What performance are you concerned about degrading? Inserts? Or queries? If you're talking about queries, what sort of access path are you concerned about?
    Are you concerned that merely changing the definition of the unique constraint would impact performance? Or are you worried that whatever functional change you are making would impact performance (i.e. if you are now retaining historical data in the table rather than just updating it)?
    Regardless of the performance impact, unique indexes (and unique constraints) need to be correct. If you need to allow duplicates on the 3 current columns with different dates, then you would need to change the unique constraint definition regardless of the performance impact. Fast and wrong generally isn't going to be preferrable to slow and right.
    Generally, though, there probably is no reason to be terribly concerned about performance here. Indexing a date is no different than indexing any other primitive data type.
    Justin

  • NOT NULL Unique Constraint in Data Modeler

    I've created Unique Constraints in the Relational Model and I'm trying to figure out how to make it a NOT NULL constraint.
    Let's say the table name is category with columns cat_id, cat_name, sort.
    In SQL I create "ALTER TABLE category MODIFY (category CONSTRAINT xxx_cat_name_nn NOT NULL);", but inside the modeler there is no data entry points in the [Unique Key Properties - xxx_cat_name_nn] dialog box, that I can find, that lets me tell it that it is a NOT NULL constraint. I'm sure there is a way but I'm just fall over my own feet trying to find it.
    Any help would be greatly appricated.
    Edited by: 991065 on Feb 28, 2013 1:40 PM

    Hi,
    You can make the column NOT NULL by unsetting the "Allow Nulls" property for the Column.
    If you want a named NOT NULL Constraint, you should also set the "Not Null Constraint Name" property (on the Default and Constraint tab of the Column Properties dialog).
    David

  • Difference between unique constraint and unique index

    1. What is the difference between unique constraint and unique index when unique constraint is always indexed ? Which one is better in this case for better performance ?
    2. Is Composite index of 3 columns x,y,z better
    or having independent/ seperate indexes on 3 columns x,y,z is better for better performance ?
    3. It has been very confusing for me to decide which columns to index, I have indexed most foreignkey columns, is it a good idea ? We do lot of selects and DMLS on most of our tables. Is there any query that I can run and find out if indexes are really being used and if they are improving any performance. I have analyzed and computed my indexes using ANALYZE index index_name validate structure and COMPUTE STATISTICS;
    null

    1. Unique index is part of unique constraint. Of course you can create standalone unique index. But is is no point to skip the logical view of business if you spend same effort to achive.
    You create unique const. Oracle create the unique index for you. You may specify index characteristic in unique constraint.
    2. Depends. You can't utilize the composite index if the searching condition is not whole or front part of the indexing key. You can't utilize your index if you query the table for y=2. That is.
    3. As old words in database arena, Index may be good or bad for a table depending on the size of table, number of columns in the table... etc. It is very environmental dependent. In fact, It is part of database nomalization. Statistic is a way oracle use to determine the execution plan.
    Steve
    null

  • HT1766 How do i combine 2 distinctly unique backups so as to merge my notes and contacts ?  Can i simply restore both and the data will be merged, or will one complete backup merely overwrite the other ?

    How do i combine 2 distinctly unique backups so as to merge my notes and contacts ?  Can i simply restore both and the data will be merged, or will one complete backup merely overwrite the other ?

    you can't merge backups.  it's all or nothing.  one or the other.

  • Unique constraint violation while updating a non PK column

    Hi,
    I seem to have found this strange error.
    What I try to do is bulk fetch a cursor in some table arrays. with limit of 1000
    Then using a forall and a save exceptions at the end
    I update a table with the values inside one of the table arrays.
    The column I update is not part of a PK
    I catch the error message: ORA-24381
    by using PRAGMA exception_init(dml_errors, -24381);
    and later on :
    WHEN dml_errors THEN
    errors := SQL%BULK_EXCEPTIONS.COUNT;
    FOR i IN 1..sql%BULK_EXCEPTIONS.count LOOP
    lr_logging.parameters:= 'index = ' || sql%BULK_EXCEPTIONS(i).error_index || 'error = ' ||Sqlerrm(-sql%BULK_EXCEPTIONS(i).error_code) ;
    END LOOP;
    I insert these errors in another table. and i get 956 errors
    first one is :
    index = 3error = ORA-00001: unique constraint (.) violated
    last one is
    index = 1000error = ORA-00001: unique constraint (.) violated
    How can this be.Since i don't update in a PKcolumn.
    FULL CODE IS:
    PROCEDURE Update_corr_values( as_checkdate_from IN VARCHAR2,
    as_checkdate_until IN VARCHAR2,
    as_market IN VARCHAR2
    IS
    LS_MODULE_NAME CONSTANT VARCHAR2(30) := 'update_values';
    lr_logging recon_logging.logrec;
    CURSOR lc_update IS
    SELECT /*+ORDERED*/c.rowid,c.ralve_record_id,d.value,c.timestamp,f.value
    FROM rcx_allocated_values a,
    rcx_allocated_values b,
    meter_histories e,
    rcx_allocated_lp_value c,
    rcx_allocated_lp_value d,
    counter_values f
    WHERE a.slp_type NOT IN ('S89', 'S88', 'S10', 'S30') --AELP
    AND b.slp_type IN ('S89', 'S88') --residu
    AND a.valid_from >= to_date(as_checkdate_from,'DDMMYYYY HH24:MI')
    AND a.valid_to <= to_date(as_checkdate_until,'DDMMYYYY HH24:MI')
    AND a.market = as_market
    AND a.market = b.market
    AND a.ean_sup = b.ean_sup
    AND a.ean_br = b.ean_br
    AND a.ean_gos = b.ean_gos
    AND a.ean_dgo = b.ean_dgo
    AND a.direction = b.direction
    AND a.valid_from = b.valid_from
    AND a.valid_to = b.valid_to
    AND c.ralve_record_id = a.record_id
    AND d.ralve_record_id = b.record_id
    AND c.TIMESTAMP = d.TIMESTAMP
    AND e.ASSET_ID = 'KCF.SLP.' || a.SLP_TYPE
    --AND f.timestamp between to_date(gs_checkdate_from,'ddmmyyyy') and to_Date(as_checkdate_until,'ddmmyyyy')
    AND e.SEQ = f.MHY_SEQ
    AND f.TIMESTAMP =c.timestamp - 1/24
    ORDER BY c.rowid;
    TYPE t_value IS TABLE OF RCX_ALLOCATED_LP_VALUE.VALUE%TYPE;
    TYPE t_kcf IS TABLE OF COUNTER_VALUES.VALUE%TYPE;
    TYPE t_timestamp IS TABLE OF RCX_ALLOCATED_LP_VALUE.TIMESTAMP%TYPE;
    TYPE t_ralverecord_id IS TABLE OF RCX_ALLOCATED_LP_VALUE.RALVE_RECORD_ID%TYPE;
    TYPE t_row IS TABLE OF UROWID;
    ln_row t_row :=t_row();
    lt_value t_value := t_Value();
    lt_kcf t_kcf := t_kcf();
    lt_timestamp t_timestamp := t_timestamp();
    lt_ralve t_ralverecord_id := t_ralverecord_id();
    v_bulk NUMBER := 1000;
    val number;
    kcf number;
    ralve number;
    times date;
    dml_errors EXCEPTION;
    errors NUMBER;
    PRAGMA exception_init(dml_errors, -24381);
    BEGIN
    --setting arguments for the logging record
    lr_logging.module := LS_MODULE_NAME;
    lr_logging.context := 'INFLOW_ALL_VALUES_PARTS';
    lr_logging.logged_by := USER;
    lr_logging.parameters := 'Date time started: ' || TO_CHAR(sysdate,'DD/MM/YYYY HH24:MI');
    -- log debugs
    recon_logging.set_logging_env (TRUE, TRUE);
    recon_logging.log_event(lr_logging,'D');
    OPEN lc_update;
    LOOP
    FETCH lc_update BULK COLLECT INTO ln_row,lt_ralve,lt_value,lt_timestamp,lt_kcf LIMIT v_bulk;
    FORALL i IN NVL(lt_value.first,1)..NVL(lt_value.last,0) SAVE EXCEPTIONS
    UPDATE RCX_ALLOCATED_LP_VALUE
    SET VALUE = VALUE * lt_value(i) * lt_kcf(i)
    WHERE rowid =ln_row(i);
    COMMIT;
    lt_value.delete;
    lt_timestamp.delete;
    lt_ralve.delete;
    lt_kcf.delete;
    ln_row.delete;
    EXIT WHEN lc_update%NOTFOUND;
    END LOOP;
    CLOSE lc_update;
    recon_logging.log_event(lr_logging,'D');
    lr_logging.parameters := 'Date time ended: ' || TO_CHAR(sysdate,'DD/MM/YYYY HH24:MI');
    recon_logging.log_event(lr_logging,'D');
    --to be sure
    COMMIT;
    EXCEPTION
    WHEN dml_errors THEN
    recon_logging.set_logging_env(TRUE,TRUE);
    lr_logging.module := 'updatevalues';
    lr_logging.context := 'exception';
    lr_logging.logged_by := USER;
    lr_logging.parameters := 'in dml_errors';
    recon_logging.log_event(lr_logging);
    errors := SQL%BULK_EXCEPTIONS.COUNT;
    lr_logging.parameters:=errors;
    recon_logging.log_event(lr_logging);
    lr_logging.parameters :=('Number of errors is ' || errors);
    --DBMS_OUTPUT.PUT_LINE('Number of errors is ' || errors);
    FOR i IN 1..sql%BULK_EXCEPTIONS.count LOOP
    lr_logging.parameters:= 'index = ' || sql%BULK_EXCEPTIONS(i).error_index || 'error = ' ||Sqlerrm(-sql%BULK_EXCEPTIONS(i).error_code) ;
    recon_logging.log_event(lr_logging);
    END LOOP;
    --recon_logging.set_logging_env(TRUE,TRUE);
    --recon_logging.log_event(lr_logging);
    commit;
    WHEN OTHERS THEN
    lr_logging.module := 'updatevalues';
    lr_logging.context := 'exception';
    lr_logging.logged_by := USER;
    recon_logging.set_logging_env(TRUE,TRUE);
    lr_logging.parameters := 'in others error=' || SQLERRM;
    recon_logging.log_event(lr_logging);
    commit;--to look which is truly the last (else only commit after 1000)
    --raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
    END Update_corr_values;

    Hi,
    No I didn't update a unique constraint.
    But I found out that there is a trigger that causes the unique constraint while updating in the table.
    Silly mistake.Didn't know there was a trigger there.
    Thx anyway.
    Greetz

  • 1-to-1 Relationship Between UI and subVI Data Cluster

    Discussion continued from here.
    In summary:
    JackDunaway wrote:
    Yes,
    I can see clear benefits in implementing this Idea - that is, if your
    underlying datatype elements have a 1:1 relationship with the UI
    elements.
    I will
    illustrate this point by showing some potential flaws in your example:
    "Profile Running" and "Profile Complete" are mutually exclusive, no?
    Wouldn't it be better to have a single enum named "Profile" with three
    elements "Idle, Running, and Complete" for the underlying datatype?
    Having two mutually exclusive pieces of data in an underlying datatype
    is among my favorite of code smell indicators.
    Also, the underlying datatype probably only needs "Forward Miles" and
    "Reverse Miles" since "Total Miles" is derived. Exclude "Total Miles"
    from the underlying cluster and just show the sum for display.
    Another
    argument against using a 1:1 relationship: the customer now wants to
    multiply speed by -1 if Direction==Reverse and not show the Direction
    enum on the UI. The data source (the VI that generates the data) would
    need to be updated using your 1:1 relationship. Using underlying data
    different from the display data, only the data client (the UI front
    panel) needs to change. I would be much more inclined to service the UI
    FP for a cosmetic upgrade rather than tracing the data source back
    through the HMI framework, through TCP, back to the RT, back to FPGA...
    Basically...
    I question a perfectly overlapped Venn Diagram where the set of data
    shown to the user equals the dataset used for underlying data
    processing/messaging/storing. The underlying datatype should be as
    stripped and streamlined as possible, while the display datatype can
    inherit all the flair and post-processing that Upper Management wants to
    see in a UI.
    LabBEAN wrote:
    <JackDunaway wrote
    I will illustrate this point by showing some potential flaws in your example...
    <LabBEAN response
    The data you see maps directly to tags on the PLC.
    <JackDunaway wrote
    Yes, I can see clear benefits in implementing this Idea - that is, if your underlying datatype elements have a 1:1 relationship with the UI elements.
    <LabBEAN response
    JackDunaway wrote:
    This is a good indicator that we're both aware at this point that I'm
    missing something... in all seriousness, could you reply to the 1:1
    argument? I really want to understand this Idea and learn how/if I need
    to apply it to my own style (our last back-and-forth turned out to be an enlightening and introspective exercise for me).
    ***EDIT: By all means, please start a discussion on the LabVIEW board so we're not hindered by the Exchange's interface. ***
    My long delayed response:
    The indicators you see map to tags on the PLC.  That is, we were connecting through OPC to an application on a PLC that was written ~15 years ago.  I have a VI where I read a bunch of SVs (Shared Variables).  Each SV is bound through OPC to a PLC tag.  In the interest of disclosure, two 16-bit tags are required to represent each 32-bit mileage number.  In the same subVI, I read each set of mileage tags, convert, and feed my subVI cluster indicator.  The same is true for wheel size:  three bits get converted to the enum.  Regardless, though, I have one subVI that reads SVs and outputs the same "underlying data" cluster that is seen on the UI.  The UI has a "Faults" cluster full of fault Booleans that follows the same logic.  When the user configures a profile of steps, they do so via an array of "step" clusters (although the cluster look is hidden for aesthetics).  It's the same thing as above except we write tags instead of reading them.
    In my case, each set of 16-bit tags is worthless as two 16-bit numbers.  They are only useful as a 32-bit mileage, so I don't pass around the raw 16-bit data.  The same is true for the wheel size bits. My software can just as easily (in fact, more easily) operate on the enum.  So, the underlying cluster from the subVI is programmatically useful and applicable to the UI.  I would guess that the same is true for a lot of RT applications, where the read VI can have some intelligence to process the data into useful / applicable clusters.
    There are going to be cases where "Upper Management" would like to see "flair and post-processing" as you say.  Your speed illustration is a good example of this.  There are also instances where the cluster works fine on the UI the way it is (like this one and many others that we've seen).
    <JackDunaway wrote
    "Profile Running" and "Profile Complete" are mutually exclusive, no?
    Wouldn't it be better to have a single enum named "Profile" with three
    elements "Idle, Running, and Complete" for the underlying datatype?
    <LabBEAN response
    Did you mean "not" mutually exclusive?  We combined 3 "dependent" (not mutually exclusive) Booleans into an enum for Wheel Size, as I mentioned above.  Not sure now why we went the other way with these two (this was 2 years ago).  In any event, with regard to UI representation, I still pass a cluster out of my read-raw-data-and-process-into-cluster subVI up to the applicable queued state machines and to the UI.
    <JackDunaway wrote
    Having two mutually exclusive pieces of data in an underlying datatype
    is among my favorite of code smell indicators.
    <LabBEAN response
    Working with applications written in ladder logic, it is not uncommon to see separate Booleans that indicate the same condition.  This seems to be especially true when safety is a concern.  That is, ladder Coil A ON and Coil B OFF == switch open.  Coil A OFF and Coil B ON == switch closed.  If you ever read OPC tags from Coil A and Coil B and the two are the same, you know the ladder is in transition (hasn't updated the tags).  Throw that point out and read again.
    I, too, appreciate our back-and-forths.  Good discussion.
    Certified LabVIEW Architect
    Wait for Flag / Set Flag
    Separate Views from Implementation for Strict Type Defs

    Thanks for replying, Jason. Let me see if I can craft a coherent response after getting back up to speed...
    (...later)
    OK, let's go. I'm going to fully agree with you that LabVIEW imposes a strange constraint unique from most other languages where a Typedef defines two things: the underlying data structure, and also the view. A Strict Typedef should be more accurately deemed the Datatype-View-Definition, and a Typedef would be more accurately called the Datatype-Definition-and-View-Suggestion. And to be clear, there are two types of views: the programmer's view (a SubVI look and feel) and the UI view (what the user and Upper Management sees). (Finally, I admit I'm ignorant whether view or View is more a more appropriate term)
    Linking the programmer's view to the datatype is perfectly fine with me, and based on your original Idea I think we both agree that's OK. I think we run into a disagreement where you have loosely tied the concept of "Strict TD" to "UI View".
    Historically, I have used Strict Typedefs for the programmer's view (SubVIs), since I like to maintain a "functional UI" at the SubVI level. I don't use type definitions on User Interfaces - only Controls. That's the reason your Idea does not appeal to me, but perhaps if your Idea were implemented, it would appeal to me since View and Implementation would be divorced as separate entities within the Type Definition. (Does that classify as a Catch-22?) So, you're Idea is fundamentally suggesting that Type Definition .ctl files should be more accurately called "a container that holds both a Type Definition and any number of View Definitions as well".
    Fundamentally, I think I finally understand the gist of your Idea: "let's ditch this weird constraint where View and Datatype are inextricably defined together in one file", and for that, I'll give Kudos to the original Idea. I got really tied up with the example you used to present the Idea, and plus I'm still learning a lot.
    Additional thoughts:
    This Idea reminds me of another: Tag XControl as Class View
    We've still got some arguing to do on a 1:1 relationship between underlying datatype and UI presentation, so put your mean face back on: 
    Since our last conversation, interestingly, I have been on an anti-Typedef kick altogether.  Why don't you drop some feedback on my attempt at a completely typedef-free UI framework?
    a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"] {color: black;} a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"]:after {content: '';} .jrd-sig {height: 80px; overflow: visible;} .jrd-sig-deploy {float:left; opacity:0.2;} .jrd-sig-img {float:right; opacity:0.2;} .jrd-sig-img:hover {opacity:0.8;} .jrd-sig-deploy:hover {opacity:0.8;}

  • ORA-00001: unique constraint @ impdp with table_exists_action=truncate

    Hi everybody
    I can't understand why my data pump import execution with parameter TABLE_EXISTS_ACTION=TRUNCATE returned ORA-00001 (unique constraint violation), while importing schema tables from a remote database where the source tables have the same unique constraints as the corresponding ones on the target database.
    Now my question is "If the table would be truncated, why I get unique constraint violation when inserting records from a table where the same unique constraint is validated?
    Here are the used parameter file content and the impdp logfile.
    parfile
    {code}
    DIRECTORY=IMPEXP_LOG_COLL2
    CONTENT=DATA_ONLY
    NETWORK_LINK=PRODUCTION
    PARALLEL=1
    TABLE_EXISTS_ACTION=TRUNCATE
    EXCLUDE=STATISTICS
    {code}
    logfile
    {code}
    Import: Release 10.2.0.1.0 - Production on Gioved� 22 Ottobre, 2009 15:33:44
    Copyright (c) 2003, 2005, Oracle. All rights reserved.
    Connesso a: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    FLASHBACK automatically enabled to preserve database integrity.
    Starting "IMPEXP"."PROVA_REFRESH_DBCOLL": impexp/********@dbcoll SCHEMAS=test_pump LOGFILE=test_pump.log parfile=refresh_dbcoll.par JOB_NAME=prova_refresh_dbcoll
    Estimate in progress using BLOCKS method...
    Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
    Total estimation using BLOCKS method: 523 MB
    ORA-31693: Table data object "TEST_PUMP"."X10000000_TRIGGER" failed to load/unload and is being skipped due to error:
    ORA-00001: unique constraint (TEST_PUMP.SYS_C00726627) violated
    ORA-31693: Table data object "TEST_PUMP"."X10000000_BASIC" failed to load/unload and is being skipped due to error:
    ORA-00001: unique constraint (TEST_PUMP.SYS_C00726625) violated
    Job "IMPEXP"."PROVA_REFRESH_DBCOLL" completed with 2 error(s) at 15:34:04
    {code}
    Thank you
    Bye Alessandro

    I forgot to read the last two lines of the documentation about TABLE_EXISTS_ACTION where it says:
    "TRUNCATE cannot be used on clustered tables or over network links."
    So it seems that it ignored the clause for the use of NETWORK_LINK and unreasonably opted for an APPEND action instead of throwing an error to highlight the conflicting parameters in the used configuration.
    Bye Alessandro

  • ORA-00001 Unique constraint Violation Error

    We are upgrading our NW BW 7.01 java server to 7.3 and during the Downtime phase of the Installer, while running the Offline Migration, we are getting an error "EP-KM-BC: Unique Constraint Violation error: ORA-000001".  Unknown Object# (12xxxxxx) does not exist. We have one CI and two DI. Any help would be greatly appreciated.

    Hi Anil,
    You need to clear the data from the table
    1. SHD_AP_PROPVALUE
    2. SHD_KMC_AP_PROP
    3. SHD_AP_MC
    Repeat the phase and also follow the sapnote
    1873288 - RUN_OFFLINE_MIGRATION phase fails during SAP NetWeaver migration
    Also paste the logs of RUN_OFFLINE_MIGRATION phase.
    With Regards
    Ashutosh Chaturvedi

  • (Error) ORA-00001: unique constraint (WHSE_DBA.PK_DELPHI_TRANS_FACT) violat

    I have a stored proc which runs every night. The stored proc is giving a unique constraint violation.
    (Error) ORA-00001: unique constraint (WHSE_DBA.PK_DELPHI_TRANS_FACT) violated.
    Any idea about how to debug this.

    I want to create an error table on the stored proc shown below. I know I have to add something in the exceptions. Can anyone give me the commands and where to add it.
    CREATE OR REPLACE PROCEDURE WHSE_DBA.DM_LD_DELPHI_TRANS_FACT
    IS
    -- VARIABLE DECLARATIONS
    LAST_LOAD_DATE                   DATE;
    INSERTCOUNT                 NUMBER:=0;
    -- LOGGING VARIABLES AND CONSTANTS
    TARGETTABLE                 CONSTANT VARCHAR2(20):='DELPHI_TRANS_FACT';
    MSGUNKNOWNERR               CONSTANT VARCHAR2(20):='Error';
    NBRIGNOREERR                CONSTANT NUMBER:=12541;
    DEFDATE                     CONSTANT DATE:='01-OCT-2006';
    ERRDESCRIPTION              VARCHAR2(255);
    V_DELPHI_TRANS_TOTAL            NUMBER;
    V_DELPHI_TRANS_FACT_TOTAL   NUMBER;
    BEGIN
    -- LOOK UP LAST LOADED RECORD
    SELECT NVL(MAX(SNAPSHOT_DATE),DEFDATE)
    INTO LAST_LOAD_DATE
    FROM DELPHI_TRANS_FACT;
    -- * LOAD ALL DIMENSION TABLES
    -- BUDGET_YR_DIMENSION
    INSERT INTO BUDGET_YR_DIMENSION (BUDGET_YEAR, SNAPSHOT_DATE)
    (SELECT DISTINCT BUD_YR, SYSDATE
    FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM BUDGET_YR_DIMENSION
    WHERE BUDGET_YEAR=OUTER.BUD_YR));
    -- EFF_DATE_DIMENSION
    INSERT INTO EFF_DATE_DIMENSION (PAID_FIS_YEAR, PAID_QTR, EFFECTIVE_DATE, SNAPSHOT_DATE)
    (SELECT DISTINCT CVT_DATE_TO_FISCAL_YEAR(EFF_DT), PD_QTR, EFF_DT, SYSDATE
    FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM EFF_DATE_DIMENSION
    WHERE EFFECTIVE_DATE=OUTER.EFF_DT));
    -- PROC_DATE_DIMENSION
    INSERT INTO PROC_DATE_DIMENSION (PROCESS_DATE, SNAPSHOT_DATE)
    (SELECT DISTINCT PROC_DT, SYSDATE
    FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM PROC_DATE_DIMENSION
    WHERE PROCESS_DATE=OUTER.PROC_DT));
    -- ORG_DIMENSION
    INSERT INTO ORG_DIMENSION (ORG,COST_CTR,SNAPSHOT_DATE)
    (SELECT DISTINCT ORG, CC_CD, SYSDATE
    FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM ORG_DIMENSION
    WHERE ORG=OUTER.ORG));
    -- BPAC DIMENSION
    INSERT INTO BPAC_DIMENSION (BPAC, AFC_CD, PE_CODE, SNAPSHOT_DATE)
    (SELECT DISTINCT BPAC, AFC_CD, PE, SYSDATE
    FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM BPAC_DIMENSION
    WHERE BPAC=OUTER.BPAC));
    -- FUND DIMENSION
    INSERT INTO FUND_DIMENSION (FUND,APPROP_CD,LIM_CD,SNAPSHOT_DATE)
    (SELECT DISTINCT FUND, APPROP_CD, APPLIM_CD, SYSDATE
    FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM FUND_DIMENSION
    WHERE FUND=OUTER.FUND));
    -- OBJ_CD_DIMENSION
    INSERT INTO OBJ_CD_DIMENSION (OBJ_CD,SNAPSHOT_DATE)
    (SELECT DISTINCT OC_CD, SYSDATE
    FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM OBJ_CD_DIMENSION
    WHERE OBJ_CD=OUTER.OC_CD));
    -- GLA DIMENSION
    INSERT INTO GLA_DIMENSION (GLA_CD,SNAPSHOT_DATE)
    (SELECT DISTINCT GLA, SYSDATE FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM GLA_DIMENSION
    WHERE GLA_CD=OUTER.GLA));
    -- PROJECT_TASK_DIMENSION
    INSERT INTO PROJECT_TASK_DIMENSION (PROJECT_NO,TASK_NO,SNAPSHOT_DATE)
    (SELECT DISTINCT PROJ_NBR, TASK_NBR, SYSDATE FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM PROJECT_TASK_DIMENSION
    WHERE PROJECT_NO=OUTER.PROJ_NBR
      AND TASK_NO=OUTER.TASK_NBR));
    -- TRANS_DESC_DIMENSION
    INSERT INTO TRANS_DESC_DIMENSION (DESCRIPTION,SNAPSHOT_DATE)
    (SELECT DISTINCT DESCR, SYSDATE FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM TRANS_DESC_DIMENSION
    WHERE DESCRIPTION=OUTER.DESCR
    AND OUTER.DESCR IS NOT NULL));
    -- SUPPLIER_DIMENSION
    INSERT INTO SUPPLIER_DIMENSION (SUPPLIER_NAME, SNAPSHOT_DATE)
    (SELECT DISTINCT VENDOR_NAME, SYSDATE FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM SUPPLIER_DIMENSION
    WHERE SUPPLIER_NAME=OUTER.VENDOR_NAME));
    -- DELPHI_INV_DIMENSION
    INSERT INTO DELPHI_INV_DIMENSION (INVOICE_NO, SNAPSHOT_DATE)
    (SELECT DISTINCT INV_NO, SYSDATE FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM DELPHI_INV_DIMENSION
    WHERE INVOICE_NO=OUTER.INV_NO));
    -- DELPHI_PO_DIMENSION
    INSERT INTO DELPHI_PO_DIMENSION (PO_NO, SNAPSHOT_DATE)
    (SELECT DISTINCT PO_NO, SYSDATE FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM DELPHI_PO_DIMENSION
    WHERE PO_NO=OUTER.PO_NO));
    -- TEMPORARILY DISABLE KEY FOR FASTER LOADING
    DB_MISC.PRO_EXE_DDL('ALTER TABLE DELPHI_TRANS_FACT DISABLE CONSTRAINT PK_DELPH_TRANS_FACT');
        -- MOVE DATA INTO TABLE
         INSERT INTO DELPHI_TRANS_FACT (BPAC_KEY, ORG_KEY, FUND_KEY, OBJ_CD_KEY, GLA_KEY,
         EFF_DATE_KEY, PROC_DATE_KEY, PROJECT_TASK_KEY, BUDGET_YR_KEY, DELPHI_TRANS_DESC_KEY,
         BALANCE, COMMIT_AMT, UDO_AMT, AEU_AMT, AEP_AMT, OBLIGATION_AMT, SNAPSHOT_DATE,
         SUPPLIER_KEY, DELPHI_INV_KEY, DELPHI_PO_KEY)
         (SELECT BPAC_KEY, ORG_KEY, FUND_KEY, OBJ_CD_KEY, GLA_KEY, EFF_DATE_KEY, PROC_DATE_KEY,
         PROJECT_TASK_KEY, BUDGET_YR_KEY, TRANS_DESC_KEY, SUM(BAL), SUM(COMMIT_AMT), SUM(UDO_AMT),
         SUM(AEU_AMT), SUM(AEP_AMT), SUM(OBLIGATION_AMT), MAX(SYSDATE), SUPPLIER_KEY, DELPHI_INV_KEY,
         DELPHI_PO_KEY
         FROM BPAC_DIMENSION, ORG_DIMENSION, FUND_DIMENSION, OBJ_CD_DIMENSION, GLA_DIMENSION,
        EFF_DATE_DIMENSION, PROC_DATE_DIMENSION, PROJECT_TASK_DIMENSION, BUDGET_YR_DIMENSION,
         TRANS_DESC_DIMENSION, DELPHI_TRANS,     SUPPLIER_DIMENSION, DELPHI_INV_DIMENSION, DELPHI_PO_DIMENSION
         WHERE DELPHI_TRANS.SNAPSHOT_DATE>LAST_LOAD_DATE
         -- JOIN WITH BPAC_DIMENSION
        AND DELPHI_TRANS.BPAC=BPAC_DIMENSION.BPAC
         -- JOIN WITH ORG_DIMENSION
         AND DELPHI_TRANS.ORG = ORG_DIMENSION.ORG
         -- JOIN WITH FUND_DIMENSION
         AND DELPHI_TRANS.FUND = FUND_DIMENSION.FUND
         -- JOIN WITH OBJ_CD_DIMENSION
         AND DELPHI_TRANS.OC_CD=OBJ_CD_DIMENSION.OBJ_CD
         -- JOIN WITH GLA_DIMENSION
         AND  DELPHI_TRANS.GLA=GLA_DIMENSION.GLA_CD
         -- JOIN WITH EFF_DATE_DIMENSION
         AND DELPHI_TRANS.EFF_DT=EFF_DATE_DIMENSION.EFFECTIVE_DATE
         -- JOIN WITH PROC_DATE_DIMENSION
         AND DELPHI_TRANS.PROC_DT=PROC_DATE_DIMENSION.PROCESS_DATE
         -- JOIN WITH PROJECT_TASK_DIMENSION
         AND (DELPHI_TRANS.PROJ_NBR=PROJECT_TASK_DIMENSION.PROJECT_NO
         AND DELPHI_TRANS.TASK_NBR=PROJECT_TASK_DIMENSION.TASK_NO)
         -- JOIN WITH BUDGET_YR_DIMENSION
         AND DELPHI_TRANS.BUD_YR=BUDGET_YR_DIMENSION.BUDGET_YEAR          
         -- JOIN WITH  TRANS_DESC_DIMENSION
         AND DELPHI_TRANS.DESCR=TRANS_DESC_DIMENSION.DESCRIPTION
         -- JOIN WITH SUPPLIER_DIMENSION
         AND DELPHI_TRANS.VENDOR_NAME=SUPPLIER_DIMENSION.SUPPLIER_NAME
         -- JOIN WITH DELPHI_PO_DIMENSION
         AND DELPHI_TRANS.PO_NO=DELPHI_PO_DIMENSION.PO_NO
         -- JOIN WITH DELPHI_INV_DIMENSION
         AND DELPHI_TRANS.INV_NO=DELPHI_INV_DIMENSION.INVOICE_NO
         GROUP BY BPAC_KEY, ORG_KEY, FUND_KEY, OBJ_CD_KEY, GLA_KEY, EFF_DATE_KEY, PROC_DATE_KEY,
         PROJECT_TASK_KEY, BUDGET_YR_KEY,TRANS_DESC_KEY, SUPPLIER_KEY, DELPHI_INV_KEY, DELPHI_PO_KEY);
    -- COUNT AFFECTED RECORDS
    INSERTCOUNT:=0+SQL%ROWCOUNT;
    -- RE-ENABLE KEY CONSTRAINT
    DB_MISC.PRO_EXE_DDL('ALTER TABLE DELPHI_TRANS_FACT ENABLE VALIDATE CONSTRAINT PK_DELPH_TRANS_FACT');
    -- STORE RESULTS OF OPERATION
    IF INSERTCOUNT>0 THEN
      DB_MISC.LOGFAILURE_EX('none', 'none', INSERTCOUNT||' new records loaded successfully.', TARGETTABLE, 'DM_LD_DELPHI_TRANS_FACT', FALSE);
    END IF;
    --- COMPARE BALANCE TOTAL FROM DELPHI_TRANS TABLE AND DELPHI_TRANS_FACT TABLE
    SELECT SUM(BAL) INTO V_DELPHI_TRANS_TOTAL
    FROM DELPHI_TRANS ;
    SELECT SUM(BALANCE) INTO V_DELPHI_TRANS_FACT_TOTAL
    FROM DELPHI_TRANS_FACT ; 
    VALIDATE_LOAD(V_DELPHI_TRANS_TOTAL,V_DELPHI_TRANS_FACT_TOTAL); 
    -- EXCEPTION HANDLING ROUTINES * * * * * * * * * * * * * * * * * * * * * *
    EXCEPTION
        WHEN OTHERS THEN
          ROLLBACK;
          IF SQLCODE!=NBRIGNOREERR THEN
            ERRDESCRIPTION:=SQLERRM;
            -- CALL ROUTINE TO PROCESS ERROR
            DB_MISC.LOGFAILURE_EX('none', 'none', ERRDESCRIPTION, TARGETTABLE, 'DM_LD_DELPHI_TRANS_FACT', TRUE);
            COMMIT;
          END IF;
    -- END EXCEPTION HANDLING ROUTINES * * * * * * * * * * * * * * * * * * * * * *
    END

Maybe you are looking for

  • Get GUID in custom WPC page layout

    I'm developing a custom WPC page layout with an embedded Visual Composer flash file. Since KMC web pages are stored in KM I can use the KM Java API to access properties on the document in KM. I want to use this technique to let users store a value at

  • How to configure network for Plex Media Server

    How do I configure my router for accessing Plex Media Server running on my home PC? The router ActionTec MI424-WR Rev F adds an entry in the port forwarding (port 32400), but I am unable to access the system.

  • MuseJSAssert Error. Need help.

    I need help. All of a sudden, I am getting an error on my website in IE (8 or 9). Here is the error:  MuseJSAssert: Error calling selector function:TypeError: 'undefined' is not a function (evaluating 'PIE.attach(this)'). Please help someone. This si

  • Program Logic for showin number of red lines on the o/p screen?

    Hi I have an output list wherein I am settin clours on the output screen based on certain conditions like if say 2 values in my final internal table doesn't match then I am settin the colour to red also green is set. My requirement is that I want to

  • Calling BAPI using ECATT

    Can some body please advice me on the method of how to call a BAPI/FM using ECATT?. I searched in SCN/SDN but to no avail. Thanks.