metamodel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kasper Sørensen <i.am.kasper.soren...@gmail.com>
Subject Re: INSERT with a SELECT subquery
Date Thu, 18 Jan 2018 03:38:40 GMT
I don't know what you're doing here since your formatting is very strange
looking.
I do see that you're dropping a table, which I don't understand why. Is it
failing because you're trying to insert into the table that was just
dropped?
Regardless, if you want help fixing your issues, please also provide an
exception stack trace.

2018-01-17 1:55 GMT-08:00 gowri.tn <gowri.tn@nic.in>:

>
>
> Table table = dataContext.getTableByQualifiedLabel("test");
>
>
> dc.executeUpdate(new UpdateScript() {
>
>  @Override
>
>  public void run(UpdateCallback callback) {
>
>  callback.dropTable(schema.getTableByName("test")).execute();
>
>  }
>  });
>
>
> while(ds.next()) {
>
> >
> >  System.out.println(">>> " + Arrays.toString(ds.getRow().getValues()));
> >
>
>
> >
> >  callback.insertInto(table).values(ds.getRow()).execute();
> >
>
> >
>
>
>
> }
>
> OUTPUT:
>
> Excel sheet:(ds.getRow())
>  >>> [1, abi, female, 21]
> >>> [2, banu, female, 16]
> >>> [3, cibi, female, 18]
> >>> [4, divi, female, 20]
> >>> [5, elakiya, female, 21]
> >>> [6, fahir, true, 25]
> >>> [7, goki, male, 21]
> >>> [8, deep, male, 19]
> >>> [9, false, female, raja]
>
> >
>
> Here is our output for the previous code for getting rows from Excel
> Datasheet. We are not able to insert the values into a Postgresql Table
> with the code given by your last mail The method, public void
> run(UpdateCallback callback) is not working Please help us in this regard.
>
> With regards,
>
> Gowri
>
>
>
>
> On 01/11/18 09:36 AM, Kasper Sørensen  <i.am.kasper.sorensen@gmail.com>
> wrote:
> >
> > 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message