Hi Lukas,

  That's not going to work.... There is no FOO.A, FOO.B etc... it looks 
like this

Table<Record> foo = table("SELECT A, B, C, D FROM Foo"); 

The table I'm inserting into is class that extends TableImpl<Record> so 
it's well defined.
But the table I'm selecting from is just string. I used DSL.table() to 
create it.






On Friday, March 24, 2017 at 5:24:50 PM UTC-4, Lukas Eder wrote:
>
> You're close.
>
> Replace:
>
>     selectFrom(foo)
>
> With
>
>     select(FOO.A, FOO.B, FOO.C, FOO.D).from(FOO)
>
> If the individual column types match, you're done.
>
> Hope this helps,
> Lukas
>
> 2017-03-24 22:02 GMT+01:00 Max Kremer <[email protected] <javascript:>>
> :
>
>> Hi,
>>
>>    What I'm trying to accomplish is to build a simple INSERT INTO (....) 
>> SELECT ... FROM type query.
>>
>> The table I'm inserting into has a TableImpl<Record> implementation. The 
>> select query does not, its a SQL string I've wrapped in DSL.table().
>>
>> My jooq TableImpl<Record> look like this:
>>
>> public class TenantTable extends TableImpl<Record> {
>>
>> public static final TenantTable TENANT_TABLE = new TenantTable();
>> public final TableField<Record, String> API_TOKEN = 
>> createField("api_token", SQLDataType.VARCHAR.length(36), this);
>> public final TableField<Record, EventType> EVENT_TYPE = 
>> createField("event_type", SQLDataType.VARCHAR.length(16), this, null, 
>> EventTypeConverter.INSTANCE);
>> public final TableField<Record, Integer> YEAR = createField("year", 
>> SQLDataType.INTEGER, this);
>> public final TableField<Record, Integer> MONTH = createField("month", 
>> SQLDataType.INTEGER, this);
>> public TenantTable() {
>> super("tenant_table");
>> }
>> }
>>
>> And my table-like subquery look like this
>>
>> Table<Record> foo = table("SELECT A, B, C, D FROM Foo"); 
>>  //simplification but u get the idea
>>
>> I'm trying to do something like this....
>>
>> dslContext.insertInto(TENANT_TABLE, TENANT_TABLE.EVENT_TYPE, TENANT_TABLE
>> .API_TOKEN, TENANT_TABLE.MONTH, TENANT_TABLE.YEAR).select(selectFrom(foo
>> ));
>>
>>
>> Obviously its nowhere near compiling...
>>
>> ultimately I'm trying to generate the following SQL:
>>
>> INSERT INTO tenant(api_token, event_type, year, month) select A,B,C,D 
>> FROM Foo;
>>
>>
>> How do I accomplish the above?
>>
>> Thanks!
>>
>>
>>
>>
>>
>> -- 
>> 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 [email protected] <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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to