How to solve the issue in mysql duplicate keys - on-duplicate-key

java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '102' for key 'placement.PRIMARY'

Related

Use foreign keys to update/ delete matching records in multiple tables in Talend Open Studio for Data Integration

I'm struggling with deleting and updating multiple tables from the same input data.
Here is a screenshot of the job.
I'm comparing the rm table in the v24 MSSQL db and in the v26, if a record was deleted in the v24, it has to be deleted in the v26. This is what's happening with tMap_1 and it works. It finds the matching bl_id, fl_id and rm_id as keys.
But before deleting that record in the rm table, the three keys are used as foreign keys in other tables records and have to be deleted or updated.
In this case, I create a second row from tMap_1 which holds the bl_id, fl_id, rm_id that have to be adapted. I link it to a first table 'rmpct' and use a delete, it seems to work even though it's primary key is not used (I adapted the field options for the deletion keys).
But now what I'm trying to do is in the tables that have matching keys, I need to update the values of these keys in the record (they have to become empty). I tried it with another table here "activity_log" but it doesn't find the matching rows based on the foreign keys and I don't know how to update these values with different values than the input row.
Can somebody help me please?
Thanks!

Circular foreign keys in PostgreSQL

I'm having a bit of an issue with circular foreign keys. I have a table posts with a uid column that is a BIGINT NOT NULL PRIMARY KEY, and I need to reference that in the last_seen_post column of my users table. The problem is that there's a sender_id column in posts that references users(user_id), meaning that I can't use both foreign keys at the same time because depending on the order of table definition, one of them will not be defined. Any fixes other than to drop the foreign key on the last_seen_post column?
I really would rather avoid dropping either foreign keys because the data integrity for this backend is mission critical. I know I could probably make another table to achieve this, but I was really hoping to get away with this since it's way cheaper in terms of space and search time
For context, the last_seen_post column is supposed to help the backend figure out what the user's "feed" is, i.e. the collection of posts from users they follow that they have not downloaded yet.
Alright, I figured it out, so I'm gonna leave the solution here if others need it in the future. The easiest thing to do is to create the column without the foreign key constraint and then do ALTER TABLE yourtbl ADD FOREIGN KEY (yourcolumn) REFERENCES othertbl(othercolumn); once both tables have been created!

AQT(Advanced Query Tool) Unable to convert an index (employee_id) to primary key

Working with optimizing my database and I have a problem when trying to edit a table where the employee id is already assigned as a unique index but not a primary key which is what I want.
I get the error message when trying to convert it into a primary key: ”Error during ExecDirect: S1000(2261)[Oracle][ODBC][ORA]ORA-02261: primary key already exists in the table”
The answer is a bit complicated but you have to undo the unique index before being able to delete it, and if it's associated/linked with another table's indexes delete them first, and then you can delete it.

Symmetricds error Unable to reload rows for missing foreign key data for table 'ir_model_fields'

I'm using symmetricds and i have this problem Unable to reload rows for missing foreign key data for table 'ir_model_fields'
Make sure you're syncing all tables that are referenced through foreign keys.

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '5-default-theme596-104' for key in CE

I have been trying to create static block in magento and when saving this block got the following error.
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '5-default-theme596-104' for key UNQ_CORE_LAYOUT_LINK_STORE_ID_PACKAGE_THEME_LAYOUT_UPDATE_ID'
I don't know why this is happening. Please help me!
Thanks.
There is a unique key constraint in your database table which saves a unique combination of layout, link, store id, packet theme update id.
You are saving this entry again ..
5-default-theme596-104
2 ways to solve this issue.
1) Remove the entry which has this combination and try again
2) Change the values and try again

Resources