Case-insensitive unique constraint

Hi guys,.

Is it possible to create a unique constraint that is case-insensitive

I mean if there is a unique constraint on the name of col

then
'James' and 'JAMES' must not


Kind regards

PAPI

Create a unique index to the basic function of...

create unique index uk_name on emp(upper(ename));

Tags: Database

Similar Questions

  • SELECT INTO make case-insensitive query?

    Hi all

    I'm having a problem with a query as if it is case-insensitive when I do a «SELECT table.x variable INTO...» ». If I do the same query, without the "variable INTO", I get a result as expected.

    The query is similar to the following:
    SELECT table_id variable FROM table WHERE table.varchar2column = 'name' AND table.integercolumn = int_variable;

    There is a unique constraint, forcing the varchar2column / integercolumn of the unique values.

    If the varchar2column has two entries that differ only in this case, a regular at the statement select returns a result. However, the procedure stored with the, I get the following error message:

    ORA-01422: exact fetch returns more than number of lines

    He gets not only if I remove the entry that only differs in the case of the letters. It is 10.2.0.1.0 Oracle, if that matters.

    I need this application to be case-sensitive. I'm not an expert of the DB, I'm just a developer trying to solve a problem. I tried to run "ALTER session SET nls_sort = binary" in the stored procedure, but I guess I can't do that...

    Any suggestion would be appreciated.

    As mentioned before... name your best-er settings.

    Your setting is the same as the name of the column on the table that you query... bad move.

    Here I change the username to work things p_username and 'magically '.

    CREATE OR REPLACE FUNCTION get_cached_user_id(p_username user_security_table.username%type, authserver user_security_table.authentication_server_id%type)
      RETURN user_security_table.user_security_id%type IS
    
      cacheduserid user_security_table.user_security_id%type;
    BEGIN
      6
      SELECT uat.user_security_id
      INTO cacheduserid
      FROM user_security_table uat
      WHERE uat.username = p_username AND uat.authentication_server_id = authserver;
    
      IF cacheduserid IS NULL THEN
         SELECT uat.user_security_id INTO cacheduserid FROM user_security_table uat WHERE uat.username = 'anonymous' AND uat.authentication_server_id IS NULL;
      END IF;
      RETURN cacheduserid;
      EXCEPTION
         WHEN NO_DATA_FOUND THEN
           SELECT uat.user_security_id INTO cacheduserid FROM user_security_table uat WHERE uat.username = 'anonymous' AND uat.authentication_server_id IS NULL;
           RETURN cacheduserid;
    END;
     21   /
    
    Function created.
    
    TUBBY_TUBBZ?SELECT get_cached_user_id('sample',20) from dual;
    
    GET_CACHED_USER_ID('SAMPLE',20)
    -------------------------------
                         2
    
    1 row selected.
    
    TUBBY_TUBBZ?
    

    Simple fix... development of a standard in the future, as for all procedure using p_ settings can save you a lot of grief.

  • Index naming standards does not and unique constraints

    I found yet another question of naming standards

    I have tried to create a unique constraint as a normal index via the unique constraints and indexes in Properties of Table with the assumption that it will use the design properties of models.  This isn't.

    Naming Standard Template.jpg

    As noted in the image of the model above, my Unique constraint model is {table} _ {columns} lancement_remarques

    and my model of Index idx _ {columns} {table}.  Yet, when I try to create the Unique constraint, it creates the naming convention in names like CUSTOMER_ADDRESS__UK (2 lines of underscore?) as shown below.

    Table_Props_Unique_Constraint.jpg

    My assumption is that he needed a column, so I added the column and also applied the rules naming - nothing.

    Table_Props_Unique_Constraint_w_Column.jpg

    Is my wrong assumption on these constraints being appointed through the models?  If this is not the case, what naming rules is in this context?

    The same behavior is evident when you try to create index.

    I get not all comments on my posts.  Are these bugs or just user error?

    Hello

    Thank you to report the problem, I logged a bug. You can get 'Rules of naming' works properly if you press the button 'Apply' before that.

    I get not all comments on my posts.

    I don't think that anyone (or any job) has been ignored on this forum. Depending on the complexity of the problem and our current commitment (other urgent tasks, holidays, time zone), you can get answer almost immediately or after a certain time.

    It is useful for us, if you mark your messages as replied if you get the right answer.

    Philippe

  • Can we create a Unique constraint on DFF attribute of a Standard Oracle Table

    Hi all

    Can we create a Unique constraint on DFF attribute of a Standard Oracle Table.

    There will be problems of integrity of the data in this case?

    Any help will be greatly appreciated.

    Best regards

    gt1942

    You should not. The same field of de FACTO forces might be used beyond business groups/associations causing cross-functional problems. This would be considered a direct customization and may affect Oracle features seeded depending on where you want to add it.

    Kind regards

    Arif.

  • Unique constraint violation error

    Hi all

    I have a procedure called - FHM_DASHBOARD_PROC which inserts data into a table called FHM_DASHBOARD_F retrieve records in multiple tables. However, for a particular type of record, these data are not inserted because of the Unique constraint violation

    the procedure is:
    create or replace
    PROCEDURE FHM_DASHBOARD_PROC AS
    
    DB_METRICS_CNT1Z number;
    --V_PODNAME varchar2(10);
    V_KI_CODE_DB_STATSZ varchar2(50);
    V_ERRORSTRING varchar2(100);
    
    --CURSOR PODNAME_CUR IS SELECT PODNAME,SHORTNAME FROM CRMODDEV.POD_DATA WHERE PODSTATUS_ID=1 AND PODTYPE_ID=1 ORDER BY PODNAME;
    
    
    -- DB STATS
    
    BEGIN 
    
      -- OPEN PODNAME_CUR;
        --   LOOP
          --   FETCH PODNAME_CUR INTO V_PODNAME,V_POD_SHORTNAME ;
            -- EXIT WHEN PODNAME_CUR%NOTFOUND;
    
               BEGIN
               
                     SELECT COUNT(*) INTO DB_METRICS_CNT1Z FROM FHM_DB_METRICS_F A, FHM_DB_D B where A.DBNAME=B.DBNAME and PODNAME=V_PODNAME AND DB_DATE=TRUNC(SYSDATE-1);
                               DBMS_OUTPUT.PUT_LINE('DB_METRICS_CNT1Z :'|| DB_METRICS_CNT1Z);
                               IF DB_METRICS_CNT1Z >0 THEN
                             
                        DBMS_OUTPUT.PUT_LINE('DB STATS');
                                  
                       INSERT INTO FHM_DASHBOARD_F(PODNAME,DASH_DATE,KI_CODE,KI_VALUE,KI_STATUS)
                                  
                          (SELECT PODNAME, DASH_DATE AS CU_DATE, KI.KI_CODE, NVL(PF.KI_VALUE,0), 
                                                                  CASE
                                                                   WHEN PF.KI_VALUE = ki.warning_threshold then 2
                        when PF.KI_VALUE=0 then 0
                        ELSE 1 
                        END  AS ALERT_STATUS
                        
                        FROM 
                        
                        (SELECT PODNAME,DB_DATE AS DASH_DATE,decode(a.stats_last_status,'SUCCEEDED',1,'FAILED',2,'STOPPED',2,NULL,0) KI_VALUE from  
                        FHM_DB_METRICS_F a,fhm_db_d b where a.dbname=b.dbname and podname='XYZ' and db_date=TRUNC(SYSDATE-1) and dbtype='OLTP')PF,
                        FHM_KEY_INDICATOR_D KI where PF.PODNAME=KI.POD_NAME AND KI.TIER_CODE=3 AND KI.KI_NAME='DB_STATS'
                        AND (PF.PODNAME,TRUNC(PF.DASH_DATE),KI.KI_CODE) NOT IN (SELECT PODNAME,DASH_DATE,KI_CODE FROM FHM_DASHBOARD_F)); 
                                 COMMIT;
                     
                             ELSE
                                    SELECT KI_CODE INTO V_KI_CODE_DB_STATSZ FROM FHM_KEY_INDICATOR_D WHERE POD_NAME=V_PODNAME AND KI_NAME='DB_STATS';
                                     DBMS_OUTPUT.PUT_LINE('V_KI_CODE_DB_STATSZ :'||V_KI_CODE_DB_STATSZ);
                                     INSERT INTO FHM_DASHBOARD_F(PODNAME,DASH_DATE,KI_CODE,KI_VALUE,KI_STATUS) VALUES(V_PODNAME,TRUNC(SYSDATE-1),V_KI_CODE_DB_STATSZ,0,0); 
                                     COMMIT; 
                                     
                             END IF;
                            
         EXCEPTION
                            WHEN OTHERS THEN
                            V_ERRORSTRING :='INSERT INTO FHM_DASHBOARD_F_ERROR_LOG(POD_NAME,KI_NAME,ERRORNO,ERRORMESSAGE,DATETIME) VALUES
                   ('''||V_PODNAME||''',''DB_STATS'','''||SQLCODE||''','''||SQLERRM||''',SYSDATE)';                         
                   EXECUTE IMMEDIATE  V_ERRORSTRING;
                            COMMIT;
              END;
    
          --END LOOP;
      --CLOSE PODNAME_CUR;
    
    
    END;
    
    
    END FHM_DASHBOARD_PROC;
    and the table where data integration is
    CREATE TABLE "CRMODDEV"."FHM_DASHBOARD_F"
      (
        "PODNAME" VARCHAR2(25 BYTE) NOT NULL ENABLE,
        "DASH_DATE" DATE,
        "KI_CODE"   NUMBER NOT NULL ENABLE,
        "KI_VALUE"  NUMBER,
        "KI_STATUS" NUMBER,
        CONSTRAINT "FHM_DASHBOARD_F_DATE_PK" PRIMARY KEY ("DASH_DATE", "PODNAME", "KI_CODE") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 NOLOGGING COMPUTE STATISTICS STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CRMODDEV_IDX" ENABLE,
        CONSTRAINT "FHM_DASHBOARD_F_KI_CODE_FK" FOREIGN KEY ("KI_CODE") REFERENCES "CRMODDEV"."FHM_KEY_INDICATOR_D" ("KI_CODE") ENABLE
      )
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS NOLOGGING STORAGE
      (
        INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
      )
      TABLESPACE "CRMODDEV_TBL" ENABLE ROW MOVEMENT ;
    the constraint primary key is FHM_DASHBOARD_F_DATE_PK and is on 3 columns of the table, DASH_DATE, PODNAME, KI_CODE



    And it's the query used in the procedure to insert the data into the table
    (SELECT  PODNAME, DASH_DATE AS CU_DATE, KI.KI_CODE, NVL(PF.KI_VALUE,0), 
                                   CASE
                                   WHEN PF.KI_VALUE = ki.warning_threshold then 2
    when PF.KI_VALUE=0 then 0
    ELSE 1 
    END  AS ALERT_STATUS
    From 
    (Select  Podname,Db_Date As Dash_Date,Decode(A.Stats_Last_Status,'SUCCEEDED',1,'FAILED',2,'STOPPED',2,Null,0) Ki_Value From  -- Added Distinct
    FHM_DB_METRICS_F a,fhm_db_d b where a.dbname=b.dbname and podname in ('XYZ') and db_date = TRUNC(SYSDATE-2) and dbtype='OLTP')PF,
    Fhm_Key_Indicator_D Ki Where Pf.Podname=Ki.Pod_Name And Ki.Tier_Code=3 And Ki.Ki_Name='DB_STATS'
    And (Pf.Podname,Trunc(Pf.Dash_Date),Ki.Ki_Code) Not In (Select Podname,Dash_Date,Ki_Code From Fhm_Dashboard_F));
    It gives * record * 2 suite
    ---------------------------------------
    XYZ JANUARY 20 12 2521 1 1
    XYZ JANUARY 20 12 2521 1 1

    It gives the Unique constraint violation error when inserting. Then, I changed in the above insertion code by adding a distinct clause. Once the query gives only a SINGLE record accordingly. However, this record is not be inserted into the table and give the same error.

    Now the question is how should I insert that record into the table with success?


    If the message is too long, however, I gave you the real structure of the object or procedure and error.

    Thank you in advance.

    When you have 5 columns in the game adding THAT SEPARATE is n ot solution that you can still get the same error once.

    Check the target table if the data exists before inserting... If this is not the case, check the structure of the table for a unique constraint created on other columns.

    select *from 
    where
    DASH_DATE=date '2012-01-20'
    and PODNAME='XYZ'
    and  KI_CODE=2521;
    
  • But UNIQUE constraint with a condition?

    Hello!

    Is it possible to define a unique constraint in a table that would apply only to a condition (according to the content of the line only)?

    For example:
    CREATE TABLE example
    (
      pk number,
      a number,
      b number,
      c VARCHAR2(10),
      x number
    );
     
    The constraint would be UNIQUIE (a, b), but only when x is > 10.
    So if x is not greater than 10, then the same values for a and b nd should be allowed.

    Maybe with a view?


    Like this?
    create view example_view  ( unique (a,b)) AS
    select a,b from example where x > 10
     with read only; -- ??? needed? 
    Kind regards
    David

    You can create an index based on a function. This takes advantage of the fact that Oracle does not store the NULL entries in an index b-tree

    CREATE UNIQUE INDEX idx_example
        ON example(
          (CASE WHEN x > 10 THEN a ELSE NULL END),
          (CASE WHEN x > 10 THEN b ELSE NULL END)
        );
    

    Justin

  • Unique constraint shot while refreshing in the MERGE statement.

    Hi guys

    I have a question that I can't solve. Would appreciate any help on this. The configuration of the data and the script is as below.
    SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 4 11:46:02 2011
    
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    
    SQL> 
    
    create table table_1
    (id number,
     id_name varchar2(20));
     
    Alter table table_1 add primary key(id);
    
    create table table_2
    (id number,
     id_name varchar2(20));
     
     insert into table_2 values (1, 'id_1');
     insert into table_2 values (2, 'id_2');
     insert into table_2 values (1, 'id_1_upd');
    
    SQL> select * from table_1;
    
    no rows selected
    
    SQL> select * from table_2;
    
            ID ID_NAME
    ---------- --------------------
             1 id_1
             2 id_2
             1 id_1_upd
    
    SQL> 
    
    SQL>  merge into table_1 target
      2   using (select id, 
      3                 id_name
      4            from table_2) source
      5   on (source.id = target.id)
      6   when matched then
      7      update set target.id_name = source.id_name
      8   when not matched then
      9      insert(id,
     10             id_name)
     11      values(source.id,
     12             source.id_name);
     merge into table_1 target
    *
    ERROR at line 1:
    ORA-00001: unique constraint (SYS_C00137508) violated
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  select constraint_type, table_name, status
      2*   from user_constraints where constraint_name = 'SYS_C00137508'
    SQL> /
    
    C TABLE_NAME                     STATUS
    - ------------------------------ --------
    P TABLE_1                        ENABLED
    Can someone help me please to solve this as the actual code that I am developing has the same configuration and I am constantly getting this error. As long as the same record does not come to the top in the 'source' table, MERGE performs an update or an insert.
    But as a "duplicate" coming soon to update, I get the error of unique constraint.

    Thank you
    -K.B.

    Dear Sir

    ERROR at line 1:
    ORA-00001: unique constraint (SYS_C00137508) violated
    

    You think two things

    (a) coherent reading: what was the situation of table_1 when the maching clause was initially assessed. There were 0 insert rows that correspond to which means that the merge operation will be all
    (b) your corresponding clause has a problem: the join column must be unique in both tables the case the merger will be ambiguous. You do not have a unique key on the source table
    (c) think that the merge operation will never insert id = 1 and then update id = 1 within the same operation. Will never happen

    Hope this helps

    Mohamed Houri

  • ORA-01031: insufficient privileges during the activation of a unique constraint

    Hello
    DB is Oracle 10 g.
    I have a problem, which allows a unique constraint on a table using a stored procedure.
    The procedure travels a few queried from the view all_constraints primary key constraints allowing them without any problem.

    Then, on the first unique constraints, it throws the exception
    ORA-01031: insufficient privileges

    The sql line built at the source of the problem is
    run immediately ' alter table 'My_Schema_Name '. "' My_TableName ' enable the 'UNIQUE_Myconstraint_UQ' CONSTRAINT '.

    What confuses me, is that the same line (without "immediate execution") run from the console window of the sql developers, which was used to make the appeal process that has failed, will succeed.

    The user used to make the call is not owner of the scheme, but has Alter_Any_Table system permissions (and, as mentioned above, the call will succeed if entered directly in the sql developer worksheet).

    Stored procedures running in a different (limited) security context (sorry if the setting isn't right) than that of the calling user?
    Or what is the problem here?

    Any help is appreciated.
    Markus.

    Note:
    Before, I don't have the name of constraint in quotes and allowing the primary key failed with error ORA-02430: impossible to enable the constraint (PK_ConstraintName) - no such constraint 02430. 00000 - "could not activate constraint (%s): no such constraint ', which is an interesting problem in itself, but now fixed. In any case, thoughtI would mention it

    Hello

    This means that alter table system privilege is given to the user through certain roles. If it's true that the roles has no effect when executing stored procedures. You must give the direct privilege to this user and not by role.

    With regard to your note:
    This means that you created the constraint in lower case or mix of lower and upper case in quotes. Therefore you should now always return in the same case in quotes each time you reference any object. So it is always advisable to create objects on top of case (if the use of the quotes) or do not use quotation marks.

    Concerning
    Anurag

  • Make case-insensitive oracle database

    Hi all

    I use oracle 10g EE that my front end and database backend is in c# .NET. I want to make my oracle database to perform any case comparison insensibly. I searched the net and found several ways to achieve

    1. use the upper function in procedures - cannot afford
    2. order of the function - cannot afford
    3. setting session parameters

    ALTER SESSION SET NLS_COMP = ANSI;
    ALTER SESSION SET NLS_SORT = BINARY_CI;

    The 3rd is promising and can save a lot of time. I have several question

    1 is there a way I can adjust these settings in .NET?
    2 is it possible I can set both and will do only my case insensitive database?

    any link, reference is very appreciated.

    Thank you

    You can create a unique index of the feature based on this column to avoid that these records.

    I don't see that should be case-insensitive database here.

  • Violation of unique constraint in JPA in multiple threads

    I get the following error message when you use APP to create a record in my database:
    # < 14 October 2009 10:13:14 AM CDT > < Info > < EJB > < lharding pc > < AdminServer > < ExecuteThread [ASSET]: '3' for queue: '(self-adjusting) weblogic.kernel.Default' > < < anonymous > > < BEA1 003262EA920A3057A4BD > <>< 1255533194632 > < BEA-010227 > < EJB Exception occurred during invocation of home or business: weblogic.ejb.container.internal.StatelessEJBHomeImpl@589d49 threw the exception : javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse - 1.1.0.r3338 - M8 persistence Services): org.eclipse.persistence.exceptions.DatabaseException
    Inner exception: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (BDSS. CONN_USER_DOMAIN_STATE_PK) violated

    Error code: 1
    Call: INSERT INTO USER_CONTEXT_STATES (ID, TEMP_FLG, STATE_INDEX, LAST_SYNC_TS, USER_CONTEXT_ID) VALUES (?,?,?,?,?)
    link = > [12701, 100003, T, null, null]
    Query: InsertObjectQuery (oracle.bdss.datamodel.UserContextStates@a4af11) >


    I do the work of an EJB on Weblogic Server and I used the JDev "Entities of Tables" Wizard to generate the code for each table.

    The code works fine most of the time. However when there are multiple threads using the EJB, I think that the allocation of the sequence becomes the same set IDS on different threads. The Session Cache for my persistence has the default "(soft low)".

    Everyone seems it before and you know a solution?

    The annotations that I use for the generation of PK for the ID column (where the unique constraint is violated) are:

    @Id
    @Column (nullable = false)
    @TableGenerator (name = "UserContextStatesSeq", table = "SÉQUENCE",
    scheme = "SDE", pkColumnName = "SEQ_NAME,"
    valueColumnName = "SEQ_COUNT"
    pkColumnValue = "BDSS. USER_CONTEXT_STATES «(, allocationSize = 50).
    @GeneratedValue (strategy = GenerationType.TABLE,
    generator = "UserContextStatesSeq")
    Private Long id;


    The code for the EJB is shown below (only the relevant parts):


    @Stateless (name = "RuntimeEJBBean")
    @Local
    public class RuntimeEJBBean
    implements RuntimeEJBLocal
    {
    @PersistenceContext (unitName = "persist")
    Private EntityManager em;

    public RuntimeEJBBean()
    {
    }

    Private Sub createNewContextState()
    throws the Exception
    {
    NewState UserContextStates = null;
    Try
    {
    newState = new UserContextStates();
    EM. Persist (newState);
    ...
    EM. Flush();
    catch (System.Exception e)
    {
    ...
    }
    }

    According to your annotation you use table named SEQUENCE to generate the id I suggest switching to sequence if you use Oracle.

    So instead of

    @TableGenerator (name = "UserContextStatesSeq", table = "SÉQUENCE",
    scheme = "SDE", pkColumnName = "SEQ_NAME,"
    valueColumnName = "SEQ_COUNT"
    pkColumnValue = "BDSS. USER_CONTEXT_STATES «(, allocationSize = 50).
    @GeneratedValue (strategy = GenerationType.TABLE,
    generator = "UserContextStatesSeq")

    use

    @SequenceGenerator (name = "UserContextStatesSeq", sequenceName = "USER_CONTEXT_STATES_ID", allocationSize = 1)
    @GeneratedValue (generator = "UserContextStatesSeq")

    and db to create sequences:

    CREATE THE SER_CONTEXT_STATES_ID MINVALUE SEQUENCE 1 WITH AN INCREMENT BY 1 1 COVER 50 ALL;

    allocationSize = 1 in @SequenceGenerator with CACHE 50 in phrase makes any id generation caching done at Oracle no ORM.

    If go to the sequence isn't an option, I would check if all error a bind ID with values such as XXXX01 or XXXX51. If Yes, then taking into account the fact that you have allocationSize = 50, it would mean that EclipseLink does not correctly synchronize award of the new id if that's the case then maybe change allocationSize 1 would help.

  • Unique constraint with conditions?

    Hi all!

    I have the following scenario... I need column UNIQUE Serial_number forced but only when the STATUS column = 'Y '. Serial_number can be non-unique, where the STATE has another value or is set to null. So, I couldn't en with this:

    SERIAL_NUMBER | STATUS
    --------------------------------------
    123456789 N
    123456789 N
    123456789 IS

    but a new line with 123456789 and 'Y' should not be allowed.

    Is this possible with a UNIQUE constraint, or what I have to set in a trigger? I was playing with the UNIQUE constraint for a while, but neither DECODE, WHERE clauses seem to be accepted...

    Thanks in advance!

    Try this:

    create unique index a1 on tab(case when STATUS = 'Y' then SERIAL_NUMBER else null end);
    

    Amiel

  • a unique index or unique constraint on the issue of view Matt

    10.2.0.3

    I have an OLTP table and a matte view to fast refresh of the table in the warehouse. I have unique indexes on the matte view just as I have on the OLTP table. Of course, it's a bad idea because the updating Oracle on mattress views mechanism does not apply to the dml in the same order that it occurred on the side of OLTP? Should I get rid of all the unique indexes on views mattress in my warehouse and create regular index because of their unique nature will just happen because the side OLTP has a unique index? What will be the impact on the performance of the queries? Here's the alert log...

    Journal of owp2 alerts
    =======================
    ORA-12012: error on auto work 1595
    ORA-12008: error path refresh materialized view
    ORA-00001: unique constraint (SMS_AR. IU02_ROUTE_REF_MRKR) violated
    ORA-06512: at "SYS." DBMS_SNAPSHOT", line 510
    ORA-06512: at line 1
    ORA-00001: unique constraint (SMS_AR. IU02_ROUTE_REF_MRKR) violated
    ORA-00610: internal error Code
    ORA-12012: error on auto work 260282
    ORA-30439: updating of the ' ORA-30439: updating of the 'SMS_AR MV_ROUTE_REF_MRKR' failed due to the ORA-12008: error in the path of refresh materialized view
    ORA-00001: unique constraint (SMS_AR. IU02_ROUTE_REF_MRKR) violated
    ORA-06512: at "SYS." DBMS_SNAPSHOT", line 2254
    ORA-06512: at "SYS." DBMS_SNAPSHOT", line 2460
    ORA-06512: at "SYS." DBMS_SNAPSHOT", line 2429
    ORA-06512: at "SMS_AR.PA_PIES_WAREHOUSE", line 44
    ORA-06512: at line 2
    ORA-20000: index 'SMS_AR '. "' I01_MV_PIES_INV_REFMKR ' or the partition of this index is unusable

    Mark Reichman wrote:
    I think that this problem is resolved... Unless someone has something else to add. I have not tried yet... But it seems to be valid. I did a test and a unique constraint can be delayed in fact creates a non-unique index. So I need to remove my unique index on my matte view and create unique constraints can be delayed.

    Or...

    forget the unqiue part and simply change the indexes not unique because the main table has a unique index and guarantees uniqueness for me and the matte view will simply copy whats in the main table.

    Mark,

    the solution seems reasonable. Just a note: If you use a "reportable" unique constraint Oracle ignores any attempt to perform a direct-path insert of access and still stations conventional insert generating undo and many more again.

    As long as you do only a 'rapid' refresh, it should not matter, but in case you deal with refreshs full large MVs, this could make a difference when running not atomic refreshs (who can take advantage of the direct-path inserts / DML etc. at the same time)...

    Then you can consider using only non-unique index rather than the constraint may be delayed if performance can matter and given the fact that you should never see duplicates in the MV because of the constraint on the base table.

    Furthermore, you can use a non-unique index to apply a not reportable unique/primary key constraint as well, it is supported. You just need to create the index yourself before you set the constraint or using explicit syntax "CREATE INDEX" of the constraint clause.

    For more information, I wrote a note on this problem "may be deferred" some time ago:

    http://Oracle-Randolf.blogspot.com/2008/07/Deferrable-constraints-and-direct-path.html

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

  • How do the function of table 1 d search case-insensitive for the array of strings

    How do the function of table 1 d search case-insensitive for the array of strings

    Hi Karine,.

    convert the two (table and search for the string) to lowercase before using this feature...

  • correct handling of foreign keys in unique constraints for operations ON DELETE SET NULL

    During my troubleshooting at a client site, I came across an interesting setup where I would like to ask your opinion.


    Consider two tables ADTB and TBLB.

    ADTB:

    INT COLA1

    COLA2 INT

    TBLB:

    COLB1 INT

    COLA2 is COLB1 as a foreign key ON DELETE SET NULL value.

    COLA1 and COLA2 are combined into a UNIQUE for the BATTERY constraint.

    I have two records of TBLB:

    (1)

    (2)

    and two DRUM recordings:

    (1, 1)

    (2, 2)

    so far, all the constraints are valid.

    During my research, I learned that I can not put COLA2 null in ADTB for two lines at the same time:

    TBLA UPDATE set COLA2 = NULL where COLA1 = 1;

    -> OK

    TBLA UPDATE set COLA2 = NULL where COLA1 = 2;

    -> VIOLATED UNIQUE CONSTRAINT

    Unfortunately, it's something my application needs, anyway. In order to get this resolved, but I try to understand, what would happen if I:

    REMOVE THE TBLB;

    ?

    It should set COLA2 in ADTB "Null" on the two lines, which is not allowed due to the UNIQUE CONSTRAINT.

    Can someone shed light on this issue? Thank you.


    Yours,

    Ronny

    Unfortunately, as you say, you can't not NULL values in such a unique constraint.  It would be the same as if you had a composite primary key and try to allow one of the columns will be null in several rows with the same value in the other column.  NULL is treated as an "unknown" value, it is possible that it could be the same value (it may or may not be, but Oracle does not know), so it must assume that it might be and that's why treat it as if there is the potential for a duplicate... so it's not unique.

    In short, do not allow null values in your unique constraints.

    The default is in the drawing, not in the way that Oracle is the treatment.  Fix the design if you do not have NULL values.

    In terms of relational database design, it seems that you are trying to transform the 1:M relations M:M relations, and which requires an intermediate table if you have M:1 and 1:M between 3 tables instead.

  • Unique constraint on the values in both directions

    I'm looking to create a unique constraint that works in two ways. Say I got a constraint unique in columns 1 and 2. I want it to be impossible for the two lines below the two exist at the same time. Is there a way to do this? I googled around for a while now and I found nothing that works so far.

    Header 1 Header 2
    DogCAT
    CATDog

    Hello

    You can create an index based on a single function:, like this:

    CREATE UNIQUE INDEX table_x_header_1_header_2

    ON table_x (LESS (header_1, header_2)

    More LARGE (header_1, header_2)

    );

    How will you use these values?  You might be better to simply create a regular old unique constraint, but also have a CHECK constraint to ensure that header_1<= header_2. ="" that="" way,="" when="" you="" want="" to="" search="" for="" the="" combination="" ('cat',="" 'dog')="" you="" won't="" have="" to="" search="" for="" ('dog',="" 'cat')="">

Maybe you are looking for