metamodel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "gowri.tn" <gowri...@nic.in>
Subject Re: INSERT with a SELECT subquery
Date Wed, 17 Jan 2018 09:55:11 GMT


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