How to create unique constraint on a col which has duplicate values

Hi all,
how can i create a unique constraint on a field which have duplicate vaules with no validate clause.
My table name is "ACCT"
Regards
Message was edited by:
53637

Check out following
SQL>DROP TABLE TEST;
Table dropped.
SQL>CREATE TABLE TEST
  2  (
  3     ID          NUMBER
  4    ,NAME        VARCHAR2(30)
  5    ,CITY        VARCHAR2(30)
  6  );
Table created.
SQL>INSERT INTO TEST VALUES(1,'Rajesh','Gurgaon');
1 row created.
SQL>INSERT INTO TEST VALUES(1,'Rajesh','Gurgaon');
1 row created.
SQL>INSERT INTO TEST VALUES(2,'Dinesh','Delhi');
1 row created.
SQL>INSERT INTO TEST VALUES(1,'Rajan','Pune');
1 row created.
SQL>INSERT INTO TEST VALUES(1,'Rajan','Pune');
1 row created.
SQL>COMMIT;
Commit complete.
SQL>ALTER TABLE test ADD CONSTRAINTS uk_on_test UNIQUE(ID,NAME,CITY) DEFERRABLE NOVALIDATE ;
Table altered.
SQL>ALTER TABLE test
  2  ENABLE NOVALIDATE CONSTRAINT uk_on_test;
Table altered.
SQL>INSERT INTO TEST VALUES(1,'Rajesh','Gurgaon');
INSERT INTO TEST VALUES(1,'Rajesh','Gurgaon')
ERROR at line 1:
ORA-00001: unique constraint (AIP.UK_ON_TEST) violatedRegards
Arun

Similar Messages

  • How to Create a datatype for a storeprocedure which has got array ?

    Hi All,
    Please tell me how to create a datatype for a storeprocedure which has got an array structure ?
    Thanks,
    Sindhu.

    Hi Sindhu.
    You would have to use a JDBC Cursor for this but it's possible only Output parameters, not Input parameters.
    It's describle in a help link:
    Defining an EXECUTE Statement  http://help.sap.com/saphelp_nwpi711/helpdata/en/44/7b72b2fde93673e10000000a114a6b/frameset.htm
    The following SQL data types are supported:
    INTEGER, BIT, TINYINT, SMALLINT, BIGINT, FLOAT, REAL, DOUBLE, NUMERIC, DECIMAL, CHAR, VARCHAR, STRING, LONGVARCHAR, DATE, TIME, TIMESTAMP, BINARY, VARBINARY, LONGVARBINARY, BLOB (input and output), CLOB (input and output), CURSOR (output; only in connection with the Oracle JDBC driver)
    I think you can execute your StoreProcedure many times depends of array occurs.
    Regards.
    Bruno.

  • How to create unique constraint in ODI

    Hi
    I have view at source side, I want to store source data to target interface table.
    For that I need to create UNIQUE constraint at source side to identify the unique records.
    I have composite primary key example as follow
    desc Test_V;
    orderID NUMBER,
    itemNumber NUMBER,
    productId NUMBER,
    quantity NUMBER,
    lot_number varchar2(80)
    where
    PRIMARY KEY (orderID, itemNumber,lot_number);
    Some times, lot_number can be null, So, I can't use lot_number in composite key (as per requirement)
    Please any body can help me on it
    Thanks
    Phani

    Hi
    Hope this may help
    http://mhimu.wordpress.com/2009/05/04/odi-incremental-update-and-surrogate-key-using-database-sequence/
    but some cases it is not working
    Thanks
    Phani

  • How to create Unique constraint

    Hi,
    How can I create a unique constraint on a column in a table which has already been created.
    Thanks

    ALTER TABLE your_table ADD CONSTRAINT yrt_uk UNIQUE (some_col)
    /You may find it illuminating to read the online documentation.
    Cheers, APC

  • How would i create a constraint for date joined which has to be less than date left?

    CONSTRAINT
    [CK_Member_DateJoined_todayorpast]
    CHECK
    (len(DateJoined)<=getdate()[DateLeft]>[DateJoined])
    I tried this but it will not work someone please help :))

    Hi,
    The Transact-SQL  Forums will be a better forums for you to ask this question. And I will help you to move your case to Transact-SQL  Forums.
    Thank you very much for your understanding.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to create a folder (in unified folders) which contains all the messages of inboxes and outboxes

    Hi, i've searched without success how to create a folder (in unified folders) which contains all the messages of inboxes and outboxes (as it exists in Windows Live Mail).
    For me, it would be very useful to search in only one folder when i try to find something in sent and received mails.
    Thank's

    This is what Unified Folders does. I'm not sure what exactly you're trying to achieve.
    http://kb.mozillazine.org/Global_Inbox#Unified_Folders
    You might take a look at this article.
    https://support.mozilla.org/en-US/kb/global-search

  • SD How to create IDoc once Sales Order Invoice (Billing) has been created ?

    Hi,
    How to create IDoc once Sales Order Invoice (Billing) has been created ?
    I.e Once you click on save button of Invoice , IDoc Should genrate Automatically.
    Thanks

    Hello,
    Go to T.code VV31 and select the billing output type and select the access sequence required and in the details screen of create condition records give all the required entries for eg: may be Billing Type, Sales Organsiation etc.and in the medium choose the option as 6(EDI) and time select as 4 that is immediately after saving the document.Also please ensure that particular partners for whom idoc should be generated they need to have partner profile setup with the billing message types. Hope this helps.

  • How to create IDoc once Sales Order Invoice (Billing) has been created

    Hi,
    How to create IDoc once Sales Order Invoice (Billing) has been created   ?
    I.e Once you click on save button of Invoice , IDoc Should genrate Automatically.
    Thanks.

    Hi,
    We need to do custom configuration for this scenario such that an output type will be attached when ever an INVOICE is created.
    Refer to application V3 in NACE. The Output type should contain an entry with transmission medium: Distribution (ALE).
    for example check the customization done for an output type in NACE.
    Goto NACE ---> Select an application V3 ---> Click on processing routines ---> select the output type (Eg: RD00) ---> Click on Details button  (CNTRL + SHFT + F2) which gives the configuration info.
    For example we can generate the IDOC based on the settings in partner profiles for the customer (Sold To)
    With Regards,
    Dwaraka.S
    Edited by: Dwarakanath Sankarayogi on Jan 29, 2009 8:16 AM

  • How to create an interactive 3D model? Which software should we need to do that?

    How to create an interactive 3D model? Which software should we need to do that?

    you can crate 3d models in any number of graphics programs.  swift3d is especially designed to use with flash.
    i'm not sure what kind of interaction you want but that would probably be coded in flash.

  • How can i export the data to excel which has 2 tables with same number of columns & column names?

    Hi everyone, again landed up with a problem.
    After trying a lot to do it myself, finally decided to post here..
    I have created a form in form builder 6i, in which on clicking a button the data gets exported to excel sheet.
    It is working fine with a single table. The problem now is that i am unable to do the same with 2 tables.
    Because both the tables have same number of columns & column names.
    Below are 2 tables with column names:
    Table-1 (MONTHLY_PART_1)
    Table-2 (MONTHLY_PART_2)
    SL_NO
    SL_NO
    COMP
    COMP
    DUE_DATE
    DUE_DATE
    U-1
    U-1
    U-2
    U-2
    U-4
    U-4
    U-20
    U-20
    U-25
    U-25
    Since both the tables have same column names, I'm getting the following error :
    Error 402 at line 103, column 4
      alias required in SELECT list of cursor to avoid duplicate column names.
    So How can i export the data to excel which has 2 tables with same number of columns & column names?
    Should i paste the code? Should i post this query in 'SQL and PL/SQL' Forum?
    Help me with this please.
    Thank You.

    You'll have to *alias* your columns, not prefix it with the table names:
    $[CHE_TEST@asterix1_impl] r
      1  declare
      2    cursor cData is
      3      with data as (
      4        select 1 id, 'test1' val1, 'a' val2 from dual
      5        union all
      6        select 1 id, '1test' val1, 'b' val2 from dual
      7        union all
      8        select 2 id, 'test2' val1, 'a' val2 from dual
      9        union all
    10        select 2 id, '2test' val1, 'b' val2 from dual
    11      )
    12      select a.id, b.id, a.val1, b.val1, a.val2, b.val2
    13      from data a, data b
    14      where a.id = b.id
    15      and a.val2 = 'a'
    16      and b.val2 = 'b';
    17  begin
    18    for rData in cData loop
    19      null;
    20    end loop;
    21* end;
      for rData in cData loop
    ERROR at line 18:
    ORA-06550: line 18, column 3:
    PLS-00402: alias required in SELECT list of cursor to avoid duplicate column names
    ORA-06550: line 18, column 3:
    PL/SQL: Statement ignored
    $[CHE_TEST@asterix1_impl] r
      1  declare
      2    cursor cData is
      3      with data as (
      4        select 1 id, 'test1' val1, 'a' val2 from dual
      5        union all
      6        select 1 id, '1test' val1, 'b' val2 from dual
      7        union all
      8        select 2 id, 'test2' val1, 'a' val2 from dual
      9        union all
    10        select 2 id, '2test' val1, 'b' val2 from dual
    11      )
    12      select a.id a_id, b.id b_id, a.val1 a_val1, b.val1 b_val1, a.val2 a_val2, b.val2 b_val2
    13      from data a, data b
    14      where a.id = b.id
    15      and a.val2 = 'a'
    16      and b.val2 = 'b';
    17  begin
    18    for rData in cData loop
    19      null;
    20    end loop;
    21* end;
    PL/SQL procedure successfully completed.
    cheers

  • How to export data from a spread sheet which has multiple work sheets?

    How to export data from a spread sheet which has multiple work sheets to a single text file with fixed length fields?

    Hello s1,
    saving them as CSV will not give a fixed legth output but, as the naming says, a Character Separated Value file.
    Regards
    Marcus

  • How to remove payment block for AP invoices which has been cleared

    How to remove payment block for AP invoices which has been cleared
    Thanks
    Chiru

    Hi,
    Thanks for immediate response in fb02 is in deable mode
    mrbr unable to change
    please provide to to remove blocking code i will assign points
    Thnaks
    Chiru

  • How can I use Airdrop in my iMac which has OX 10.9.2

    How can I use Airdrop in my iMac which has OX 10.9.2

    If you have an iPhone5 and an IMac,
    - you should have your photos in phototstream (last 1000)
    - your iphone should have your icloud account linked
    - your imac should have your icloud account linked
    more info http://support.apple.com/kb/HT4486

  • Create unique constraint on table

    Hello experts,
    Is it possible to define a unique constraint on table fields that aren't part of the primary key?
    Thank you in advance.

    One way is to create an index on the field and make it unique (SE11->GOTO->Indexes). Then in your programs Inserts, Appends and Updates would fail giving you a non zero SY-SUBRC when a program tries to enter a value that already exists.
    Don't forget to include MANDT in the index otherwise you'll end up with uniqueness across all clients

  • How to Catch Unique Constraint in Exception

    Hi,
    I am writing a trigger TR_EMP on a table EMP which has columns EMP_ID, EMP_NAME, ALT_EMP_ID.
    Now I am updating ALT_EMP_ID for an EMP_ID(PK) which is unique.
    If ALT_EMP_ID is null
    then
          :new.ALT_EMP_ID = l_alt_emp_id;
    end if;As this ALT_EMP_ID is unique, same ID shouldn't be inserted again here. When data being inserted with 2 different sessions for 2 different EMP_ID there is a possible chance of inserting same ALT_EMP_ID for both which results in Unique error. I need to handle this exception. DUP_VAL_ON_INDEX or OTHERS Execption not able to handle this.
    Can you help me out on how to handle such exception?

    >
    jeneesh wrote:
    I am able to use dup_val_on_index
    >
    Can you please write an Exception for this query?
    If ALT_EMP_ID is null
    then     
          :new.ALT_EMP_ID = l_alt_emp_id;
    end if;jeneesh wrote:
    Moreover, what is your requirement? This design seems to be flawed. If you can explain teh actual requirement, forum members will be able to help you better..
    >
    Alternate Emp ID will be populated for Every employee. If on a same session when this ID is populated for 2 different Emplyoees then it will throw Unique constraint error, which should be handled.

Maybe you are looking for

  • OAM Session timeout

    Hi All, I have the following set up configured. 1)Deployed a web application in a plain(non oim suite related) weblogic domain 2)Installed OHS,OAM,OIM and OUD 3)Configured OHS,OAM,OIM and OUD for SSO in OAM with the external URL from the independent

  • IPSEC packets are not encrypted

    Hello (and Happy Thanksgiving to those in the USA), We recently swapped our ASA and re-applied the saved config to the new device. There is a site-to-site VPN that works and a remote client VPN that does not. We use some Cisco VPN clients and some Sh

  • Oracle 8i (8.1.7) Personal Edition on Windows Millenium wont install

    I try to install Oracle 8i (8.1.7) Personal Edition on my Windows Millenium laptop (PIII, 256MB, 30GB). When running universal installer, after first initial screen when installer has loaded G:\stage\products.jar (G drive is my CD drive), I got the f

  • Adding a field for a view on SM30

    We would like to add a field to a standard table and use it as maintanable via SM30. This standard table gets gets is data entries usually when  4-5 views are maintained through IMG customization/SM30. We would like to add one more fields on any of t

  • Removed Nouveau, installed Nvidia, black login screen

    Hi there! Seems like I was just here yesterday...  But seriously, it's coming together. Today I hooked up my second monitor and tried to get the "one big monitor" effect with noveau, but it wasn't recognizing my setup.  I've had success with installi