Subject Re: [firebird-support] Re: Copy records
Author Lester Caine
Planles wrote:

>>I have one problem. Here is exactly what I put in dataset:
>>
>>INSERT INTO MATCONTI (MC_MAT_KEY, MC_MAT_KC, MC_QTY)
>>SELECT 'new_key', M2.MC_MAT_KC, M2.MC_QTY
>>FROM MATCONTI M2
>>WHERE M2.MC_MAT_KEY = 'old_key'
>>
>>After ExecSQL I get an error message:
>>
>>Violation of PRIMARY or UNIQUE KEY constraints "INTEG_94" on table
>>"MATCONTI"
>
> Maybe I should tell before, that both MC_MAT_KEY and MC_MAT_KC are primary
> keys.
>
> What should I change to get it work properly ?

Well that is quite important. If MC_MAT_KC must be unique as well as
MC_MAT_KEY then you need to change both in the select.

If just the combination should be unique then the PRIMARY KEY should
contain both, but if MC_MAT_KEY is a generator, the it will always be
unique, so just drop MC_MAT_KC from the primary key.

--
Lester Caine
-----------------------------
L.S.Caine Electronic Services