metamodel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Kingsbury <Tim.Kingsb...@sas.com>
Subject RE: INSERT with a SELECT subquery
Date Thu, 11 Jan 2018 13:22:22 GMT
Excellent. Thank you!!


Tim

-----Original Message-----
From: Kasper Sørensen [mailto:i.am.kasper.sorensen@gmail.com] 
Sent: Wednesday, January 10, 2018 11:07 PM
To: dev@metamodel.apache.org
Subject: Re: INSERT with a SELECT subquery

EXTERNAL

Hi there,

No that's not available. But you do get something quite equivalent with
this:

Table table = dataContext.getTableByName("us_south_es_etg");
dataContext.executeUpdate(callback -> {
  try (DataSet ds =
dataContext.query().from("us_south").selectAll().execute()) {
    while (ds.next()) {
      callback.insertInto(table).values(ds.getRow()).execute();
    }
  }
});


2018-01-10 10:15 GMT-08:00 Tim Kingsbury <Tim.Kingsbury@sas.com>:

> Hello,
>
> Using Metamodel, is it possible to build an INSERT statement that is 
> paired with a SELECT subquery?  For example:
>
> INSERT TABLE `us_south_es_etg`
> SELECT
>    `lon`,
>    `lat`,
>    `number`,
>    `street`,
>    `unit`,
>    `city`,
>    `district`,
>    `region`,
>    `postcode`,
>    `id`,
>    `hash`
> FROM us_south;
>
>
> Any suggestions would be greatly appreciated!
>
>
> Tim
>
>
Mime
View raw message