Subject | RE: [firebird-support] Re: Copy records |
---|---|
Author | Planles |
Post date | 2004-08-05T12:34:44Z |
Thanks again.
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"
But the records are inserted in MATCONTI table any way.
Why is that so ?
Regards,
Primoz
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"
But the records are inserted in MATCONTI table any way.
Why is that so ?
Regards,
Primoz
> -----Original Message-----
> From: Svein Erling Tysvær [mailto:svein.erling.tysvaer@...]
> Sent: Thursday, August 05, 2004 1:57 PM
> To: firebird-support@yahoogroups.com
> Subject: [firebird-support] Re: Copy records
>
>
> Hi Primoz!
>
> M2 is just an alias ensuring that the two instances of 'master' are
> considered separate (I don't think it is needed in this case, but I
> wasn't certain so I put it in), and you could equally well write
>
> INSERT INTO master (ID, Name, Town)
> SELECT 'ID2', Primoz.Name, Primoz.Town
> FROM master Primoz
> WHERE Primoz.ID = 'ID1';
>
> Firebird doesn't have any autoincrement fields, but if you mean a
> field that is populated through a trigger using a generator (the
> 'normal' way to simulate an autoincrement field), then you would
> simply leave it out of the insert statement altogether:
>
> INSERT INTO master (Name, Town)
> SELECT Primoz.Name, Primoz.Town
> FROM master Primoz
> WHERE Primoz.ID = 'ID1';
>
> HTH,
> Set
>
> >INSERT INTO master (ID, Name, Town)
> >SELECT 'ID2', M2.Name, M2.Town
> >FROM master M2
> >WHERE M2.ID = 'ID1';
> >
> > Thanks for both answers.
> >
> > What does M2 stand for ?
> >
> >
> > What if ID is an autoincrement field ? What should I put instead of
> > 'ID2' ?
> >
> >
> > Regards,
> > Primoz
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>