Perfect, thank you. (to copy it from one db to another, create2 was 
missing....)
    List<Field<?>> fields = new ArrayList<>(Arrays.asList(KTO.fields()));
    fields.removeAll(KTO.getPrimaryKey().getFields());
        
        create1.insertInto(Tables.KTO).columns(fields).select(
               create2.select(fields).from(KTO)
        ).execute();

For one row i do it this way:
    MyRecord my1 = create2.selectFrom(KTO).fetchAny();
    my1.set(KTO.KTOID,null);
    create1.insertInto(KTO).set(my1).execute();

This works for some fields, but some are null. The ID gets generated, most 
of the data stored, but I dont understand why it works for some fields, and 
for some not.
Is this wrong way to insert one Record from one DB to another? Or one Table 
to another?
Thx
C

Am Donnerstag, 28. März 2019 11:10:22 UTC+1 schrieb Lukas Eder:
>
> You can easily extract a set of columns without the primary key as follows:
>
>     List<Field<?>> fields = new ArrayList<>(Arrays.asList(KTO.fields()));
>     fields.removeAll(KTO.getPrimaryKey().getFields());
>
>     create1.insertInto(KTO).columns(fields).select(
>         select(fields).from(KTO)
>     ).execute();
>
> Hope this helps,
> Lukas
>
> On Thu, Mar 28, 2019 at 9:39 AM Christian Master <spe...@gmail.com 
> <javascript:>> wrote:
>
>> I try to copy the records from one database to another.
>>
>> create1.insertInto(Tables.KTO).select(
>>                     create2.select().from(Tables.KTO)
>>             ).execute();
>>
>> Since I have a primary key with auto_increment this wont work.
>>
>> In pure SQL it is not possible to exclude the primary key in create2. 
>> Is it possible with jooq?
>> I don't want to write all the fields into a "insertInto" method.
>>
>> If it is not possible, is there a way to copy the values from SomeRecord 
>> a to SomeRecord b without doing it field by field?
>>
>> Thx
>> Chris
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "jOOQ User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to jooq...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jooq-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to