Discussions
Categories
- 196.9K All Categories
- 2.2K Data
- 239 Big Data Appliance
- 1.9K Data Science
- 450.3K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 545 SQLcl
- 4K SQL Developer Data Modeler
- 187K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.6K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 440 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
duplicate name

i have a supplier master , where i have a primary key on supplier id column , but i need to put a check on supplier name as well for avoiding the duplicate names.
supplier id supplier name
1 Test
2 Test
in the above case 2 names are identical. we should avoid them.
Best Answer
-
Hi, @af_2017
i cannot put a unique constraint on this table , as i dont have rights to modify any table in ERP.
Can you create a unique index on the table?
If not, then create an INSTEAD OF trigger (or a procedure) and only allow INSERTs and UPDATEs through that trigger (or procedure).
Answers
-
Hi, @af_2017
i have a supplier master , where i have a primary key on supplier id column , but i need to put a check on supplier name as well for avoiding the duplicate names.
If you want to make sure than no two rows in a table have the same value, you can put a UNIQUE constraint on that column. For example
CREATE TABLE supplier_master ( supplier_id NUMBER PRIMARY KEY , supplier_name VARCHAR2 (20) UNIQUE );
-
Thanks @Frank Kulash , i cannot put a unique constraint on this table , as i dont have rights to modify any table in ERP. i am thinking of writing a pl/sql block and throwing some exception by comparing the given supplier name with that name that is existing in the table , something like upper(supplier_name) = upper(p_supplier_name).
-
Hi, @af_2017
i cannot put a unique constraint on this table , as i dont have rights to modify any table in ERP.
Can you create a unique index on the table?
If not, then create an INSTEAD OF trigger (or a procedure) and only allow INSERTs and UPDATEs through that trigger (or procedure).
-
Thanks @Frank Kulash , i have never tried instead of trigger earlier , let me google and write it accordingly.