Hi Nakamura,

 

Yes, you can.

 

Here’s how to do it:

 

// Define the query

DBCommand cmd = db.createCommand();

cmd.select(...);

cmd.join(...);

cmd.where(...);

 

// Get the INSERT INTO command phrase

List<DBColumnExpr> destCols = new ArrayList();

destCols.add(DEST_TABLE.COL1);

destCols.add(...);

String sql = cmd.getInsertInto(db.DEST_TABLE, destCols);

// Execute the statement

db.executeSQL(sql, conn);

 

 

another way of doing it is:

 

//Define the query

DBCommand cmd = db.createCommand();

cmd.select(SRC_COL1.as(DEST_COL1.Name));

cmd.select(SRC_COL2.as(DEST_COL2.Name));

cmd.join(...);

cmd.where(...);

 

// Get the INSERT INTO command phrase

String sql = cmd.getInsertInto(db.DEST_TABLE);

// Execute the statement

db.executeSQL(sql, conn);

 

 

Regards,

Rainer

 

 

Kenji Nakamura wrote:

re: insert into ... select statement support? 

 

Hi, 

 

I’m wondering if I can execute “insert into table_a (column_a1, column_a2…) 
select column_b1, column_b2 from table_b where…” statement from empire-db. 

If it is not supported out of the box, is it possible to extend DBCommand class 
and add the capability? 

 

Thanks, 

 

Kenji Nakamura

Reply via email to