When I want append source table to destination table by FDbatchMove component , Delphi rise this exception:
"[FireDac][Phys][SQLite] ERROR: UNIQUE constraint failed:AG2.M_key."
AG2.M_Key is primary key of my Table.
If I can exclude primary key from batchmove, maybe can solve problem.
How can I do that?
By this cod i can exclude 'm_key' field from FDbatchmove append:
var ind:integer;
begin
FDBatchMove1.Mappings.Clear;
FDBatchMove1.Mappings.AddAll;
ind:=FDBatchMove1.Mappings.IndexOfName('m_key');
if ind<>-1 then
FDBatchMove1.Mappings.Delete(ind);
FDBatchMove1.Execute;
end
Related
Hope for help because of the following problem. Assume we have a table
CREATE TABLE [dbo].[dummy](
[id] [char](36) NOT NULL,
[name] [varchar](50) NOT NULL
) ON [PRIMARY]
If I create a primary key like this (version 1)
ALTER TABLE dummy ADD CONSTRAINT PK_dummy PRIMARY KEY (ID);
I get a unique name. In this case PK_dummy.
But if I create a primary key like this (version 2)
ALTER TABLE dummy ADD PRIMARY KEY Clustered (ID);
The name changes with every recreation of this primary key.
The format is always PK__dummy__"a dynamic number"
What is the meaning of this number?
And how can I identify primary keys created with version 2 in a hugh database?
Thanks for hints.
What is the meaning of this number?
This depends on product version - it is either based on a unique id or generated randomly.
how can I identify primary keys created with version 2 in a huge database?
SELECT *
FROM sys.key_constraints
WHERE is_system_named = 1
If you don't define the name of a constraint, index, key, etc, SQL Server will give it a name. To ensure uniqueness across the database, it therefore will add "random" characters at the end.
If having a consistent name is important then define the name in your statement, as you did in the first statement.
I have a ValidationTable like
and OrderProcessing table like
I want to create foreign key constraint on OrderProcessing table on column OrderType that references first 3 rows of ValidationTable (of ValidationType = "orders"). Is this possible? I referred similar questions but those did not really help.
I don't believe it is possible to link a specific set of rows.
The constraint has to be for the whole column.
Issue
I have to table "Account_Manager" and "Partner" and both table contains foreign Key of each other and now I want to add data and it show the error Foreign Key conflict issue.
Guide me how I can insert data into these two table.
Table 1
Table 2
Make both columns (designated as FKs) nullable. Thats only way you can make circular reference/FK
Hi I am using pentaho to insert some values from one DB to another DB. In my source I have an attribute which is the primary key of that table. At my destination I have the same attribute as a unique constraint. But still I get a ORA-00001: unique constraint violated error while inserting. I am not sure why this is can anyone help ?
Source:
table
(
empid(PK),
empname
)
Destination:
table1
(
empgroupid(PK)
empid(unique)
)
source to destination error: ORA-00001: unique constraint violated
You likely don't want "table1"."empid" to be unique; you probably want it to be a foreign key to "table"."empid". Especially if an employee can be in more than one group at once.
I am trying to modify the size of a column in a table, however that column is a primary key column and is used in other table ( which would need to have its size modified too)
I have a table called table1 with a column named column1 as primary key
I also have table2,table3 and table4 that has table2column1, table3column1 and table4column1 respectively.
table2column1,table3column1 and table4column1 are foreign keys ( reference column1 from table1) and they are also used as a composite primary key in their respective table.
I tried doing this to alter the size of the column
ALTER TABLE UtilisateurNotes ALTER COLUMN IDNotes nvarchar(250)
It did not work.
This is the error message : Cannot alter a column that is part of a key or an index.
Anyone has an idea what I should do? thank you Gibit
You have to drop the foreign keys and primary key index in order to modify the column and then rebuild them after.
If you're in SQL Server Management Studio and you use the Object Explorer then you can right click on the specific Primary Key or Foreign Key specified in the error message and use Script as > CREATE AND DROP to help you generate the necessary scripts for the update.