I am using Informatica to finally write in the oracle table after performing certain logical operations on the data.
The problem is that if a certain ID was already previously processed and is present in the target table then it is not inserted again.
Please suggest a workaround.
Hi, This is because you might have same primary key in the source which is available in the target. Look into primary key columns and try loading them.
Altering your target table
alter table target_table_name drop constraint constraint name;
Related
I have two tables, SRC and TGT. I want to populate all my foreign key values in TGT from the target lookups. However, I'm getting nulls into the target. I have used all natural keys for lookup conditions. Can anyone please explain why I am seeing nulls?
For instance, I want to populate foreign key values for MPNG_ID, SESN-ID, WRKFLW-ID from lookup tables based on repository name and version number.
Did you validate if all your Join Conditions are working fine? Probably try to replicate same query in DB and check if its giving you the same result. I assume some Join might have messed up which might result in Null values. Ensure that even the spaces are in sync if you are using Varchar value.
I'm adapting a really big query (MySQL to SQL) that creates lots of tables and relationships. The problem is that it always check if a table exists prior to adding a foreign key referencing to that table.
So I have to reorder the queries to avoid this problem, and my question is if there's a instruction that can turn that check off, so it'll create the tables and add references without stopping the query with every error it encounters.
I'm working with SQL in an Azure DB.
Thank you.
Easiest way is to create all tables first and then add constraints using ALTER TABLE.
For example:
CREATE TABLE a(id INT PRIMARY KEY IDENTITY(1,1), b_id INT, c CHAR(10));
CREATE TABLE b(id INT PRIMARY KEY IDENTITY(1,1), z INT);
ALTER TABLE a ADD CONSTRAINT FK_a_b_id_b FOREIGN KEY (b_id) REFERENCES b(id);
Rextester Demo
I'm inserting from a source table to the target table. If the source record already exists in the target, then it will update else insert. I have done this without using Update strategy. In session properties, I have set as treat rows as 'Update' and in the mapping target properties, I selected 'Insert' and 'Update Else Insert' checkbox. Also, I have chosen a primary key in the target table as well. But while running the session every time, it is always inserting the same rows again and again. I.e. duplicate rows are inserting instead of update the record. am I doing anything wrong?
The database table should have primary keys defined for this to work.
I am trying to update a specific field in the "Claims" table of my 2010 Access Database. I keep receiving an error message that says there are key violations. Here is the SQL:
UPDATE Claims SET Claims.LS_Name = "JPN"
WHERE (((Claims.Responsibility2)=0));
Is there any reason, based on the above code, that it is not working?
Thanks in advance!
My first guess would be that there is a unique key on Claims.LS_Name and your update hits more than one row.
OK, I ran into this issue as well in Microsoft Access and think I have ways to solve versions of this. The intermediate table may not be necessary. My experience is that autonumber is the issue so conversion to number seems to work, but you have to delete relationships for Access to allow this change.
remove all relationships to the destination table.
change from autonumber to number.
make new empty tablethatincrements starting with the next higher key https://superuser.com/questions/288087/how-do-i-set-the-first-value-of-autonumber-in-access
update/query to the tablethatincrements table instead of destination.
update/merge from tablethatincrementsto to the destination table, including new higher keys.
remake relationships
OR In certain situations. (for mine the new keys matched the old)
something like this (may not be exact steps)
remove all relationships to the destination table.
delete ID/primary key in destination
merge/update to destination
create new ID/Primary key in destination (so it can be autonumber to renumber keys)
remake relationships
Anyway my next research item is to see how to never use autoincrement and do the unique keys using other methods so relationships do not have to be removed to change from autoincrement to number.
I am trying to run multiple alter table statements for adding foreign keys on my database
I am using RazorSQL
this are my sql statement
ALTER TABLE SPO999.AVTVRSTEPLACILAPOD
ADD CONSTRAINT SQL100419145030510 FOREIGN KEY
(AVP_VRSTEPLACILA)
REFERENCES SPO999.VRSTEPLACILA
(VP_ID_VP)
ON DELETE NO ACTION
--ON UPDATE NO ACTION
ENFORCED
ENABLE QUERY OPTIMIZATION;
-- DDL Statements for foreign keys on Table SPO999.AVTVRSTEPLACILAVRPL
ALTER TABLE SPO999.AVTVRSTEPLACILAVRPL
ADD CONSTRAINT SQL100419145030630 FOREIGN KEY
(AVV_VRSTEPLACILA)
REFERENCES SPO999.VRSTEPLACILA
(VP_ID_VP)
ON DELETE NO ACTION
--ON UPDATE NO ACTION
ENFORCED
ENABLE QUERY OPTIMIZATION;
If I run one at a time it works, while if trying to run both at I get an SQL Error -104 a token,character or clause is invalid or missing.
I can not find a problem/solution
any suggestions?
thank you
I think it is likely that you can't have these two foreign key definitions referencing the same column within a single transaction.
Try adding commit; between the statements.
(Your SQL editor, depending on its settings, may automatically send a commit after each chunk of statements that you execute. That would explain the difference between the two cases).