unique-constraint

Given a 'java.sql.SQLIntegrityConstraintViolationException' is it possible to determine column('s) in error

三世轮回 提交于 2019-12-10 22:43:49
问题 Given I have an exception of type 'java.sql.SQLIntegrityConstraintViolationException' Is it possible to programmatically determine the column (or columns) in error? I ask this because I would like to map the error back to the client's data model to indicate field in error (for example a violation of a unique key). For example given a duplicate value is attempted to be inserted on a table, the 'java.sql.SQLIntegrityConstraintViolationException' exception would be thrown with the following

Hibernate Natural ID duplicate issue

夙愿已清 提交于 2019-12-10 14:16:58
问题 I'm new to Hibernate and DBs in general, so pardon the elementary question. I am working with the DIS protocol and specifically the Open-DIS implementation of DIS. In DIS, each EntityStatePdu (containing the state of an entity in the simulation) has an EntityId object, a tuple of 3 integers. I want to use this object as a Natural Id, and maintain a standard surrogate ID as well. My problem is I cannot figure out how to ensure that the DB determines that a given EntityId already exists and use

Storing and comparing unique combinations

女生的网名这么多〃 提交于 2019-12-10 11:44:07
问题 I need search functionality on a website where among other things you should be able to select multiple categories. The searches will be stored in the database but each unique combination of search parameters should only be stored once, this also includes the unique combination of selected categories. The problem is that I cannot figure out how to store the combinations of selected categories. I have looked at arrays and found this http://blog.2ndquadrant.com/postgresql-9-3-development-array

Core Data (After Adding Unique Constraint) : annotation: repairing missing delete propagation for to-many relationship

倖福魔咒の 提交于 2019-12-09 09:37:32
问题 This issue started occurring after we added Unique key i.es Constraint. Frequently updating Meeting managed object deletes the event managed object which has a to-one inverse relationship from meeting managed object. Error CoreData: annotation: repairing missing delete propagation for to-many relationship meetingList on object 0x60c00009c4d0 (0x60c000621e40 ) with bad fault 0x60800009ac20 (0x60800023a360 ) Data Model I have three entities in my core data model i.es (CDEvent, CDMeeting,

How to find out line number, procedure name in PL/SQL in case of an error

人盡茶涼 提交于 2019-12-09 04:22:28
I am using a D2k 6i form and getting the error on form from stored database(oracle9i) procedure ORA-00001:Unique constraint(.) violated but i m not able to trace out from which procedure it is coming. can anybody help me regarding this For posterity, here is the solution the OP found: ok in D2k forms there is an ON-ERROR trigger where you can use the function DBMS_ERROR_TEXT to get the procedure,package name line number of the statement from where the error is coming I've come across this pattern after much research, head banging and gnashing of teeth: CREATE OR REPLACE PACKAGE BODY my_schema

how to insert nextval to trigger inside for loop

℡╲_俬逩灬. 提交于 2019-12-08 23:29:27
Hi here is a code for trigger and it have a for loop. When trigger is fired ( INSERT OR UPDATE)there's another table data must include it is MICL_SUP OPEN projMgrsCursor; LOOP FETCH projMgrsCursor INTO projMgr; select micl_sup_id_seq.nextval into SUPID from dual; insert into MICL_SUP VALUES ((SUPID), (SELECT SYSDATE FROM DUAL), :NEW.ENTRYADDEDBY_EMP_NO, 3000, 0,projMgr, NULL,:NEW.EMP_NO); END LOOP; CLOSE projMgrsCursor; This is the table structure . Sup_ID primary and unique key . I cant do any changers to table structure SUP_ID -primary key ASSIGNED_DATE ASSIGNED_BY_EMP_NO AMOUNT_LIMIT IS

Core Data “Unique Constraint” raises exceptions when it works?

戏子无情 提交于 2019-12-08 13:50:21
问题 Several years ago, Core Data added a feature in data models which, with zero code, during save, automatically merges new insertions with existing objects when certain attributes which you specify have equal values. This feature is called Unique Constraint . Very nice. But it seems to raise exceptions when it does this merging. I forked a little project demonstrating this feature which was written by Zachary Orr in 2015 in Objective-C. This project is discussed in the first answer of this

How to update in SQL to get distinct tuples / not to violate a unique constraint

元气小坏坏 提交于 2019-12-08 10:28:49
问题 I have a mapping table with a unique contraint on the tuple (c_id, t_id) . Here's some sample data to illustrate the situation: id c_id t_id ---------------- 1 10 2 2 10 3 3 10 7 4 12 2 5 13 3 I wrote a merge function for t_ids (x,y -> z OR x,y -> x). If my content ( c_id ) has both t_ids , then I'm of course violating the constraint by using this statement: UPDATE mapping_table SET t_id = '$target_tid' WHERE t_id = '$t1_id' OR t_id = '$t2_id'; The result would be: id c_id t_id --------------

Save multiple objects with a unique attribute using Django formset

点点圈 提交于 2019-12-07 16:30:57
问题 TL;DR: How do you save/validate multiple objects with a unique attribute using a formset? Let's say I have a Machine which has multiple Setting s (see models below). These settings should have a unique ordering within the machine. This can be accomplished by defining a unique_together attribute in the Meta class of the Setting model: unique_together = (('order', 'machine'), ) However, I'm using an inline formset to update all the Setting s of a Machine . Assume I have the following info in my

Unique constraint on two columns regardless of order

两盒软妹~` 提交于 2019-12-07 13:02:57
问题 I have the following table definition: CREATE TABLE [Car] ( CarID int NOT NULL PRIMARY KEY IDENTITY(1,1), FirstColorID int FOREIGN KEY REFERENCES Colors(ColorID), SecondColorID int FOREIGN KEY REFERENCES Colors(ColorID), UNIQUE(FirstColorID, SecondColorID) ) I want the two Color columns to be unique, regardless of the combination they appear in. E.g. attemping: INSERT INTO Car (FirstColorID, SecondColorID) VALUES (1, 2); --should succeed but then trying the same after that first record exists