Hello,

This is currently not supported by jOOQ and we probably won't support it as
PostgreSQL documentation recommends using the CREATE TABLE AS syntax
instead of SELECT INTO.

Note that other databases including the SQL standard specify SELECT INTO as
follows:

<select statement: single row> ::=
  SELECT [ <set quantifier> ] <select list>
    INTO <select target list>
    <table expression>

<select target list> ::=
  <target specification> [ { <comma> <target specification> }... ]


So, INTO expects column references or parameters, for instance, not table
references.

Now, CREATE TABLE AS can be used with jOOQ using plain SQL as follows:

DSL.using(configuration)

   .execute("CREATE TABLE xx AS {0}", select);


Where select is your jOOQ SELECT statement.

In any case, the CREATE TABLE AS statement would be a useful addition to
the newly introduced set of DDL statements in jOOQ. I have added it to the
roadmap for jOOQ 3.5:
https://github.com/jOOQ/jOOQ/issues/3381

Cheers
Lukas

2014-07-09 11:16 GMT+02:00 <[email protected]>:

> Hi,
>
> postgres has a select into which allows defining a new table from the
> results of a query. Is there any way i can do this in jooq?
>
> http://www.postgresql.org/docs/9.3/static/sql-selectinto.html
>
> i have a use case where i create a complex query containing a number of
> joins and a number of conditions to get a result set.
> On this result set i need to compute different aggregate values which are
> then used for plotting a graph.
>
> I thought it would be more efficent to push the results of the first query
> into a temp table and then do the later computation on the temporary table.
>
> Thanks,
> Gokul
>
> --
> 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.
>

-- 
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