我有一个文本文件:
ACTION = NEW
NEW_NUMBER = '123456'
TEXT_NAME1 = 'TEST1'
TEXT_NAME2 = 'TEST2'
TEXT_NAME3 = 'TEST3'
我想在我的代码中进行多个 INSERT 查询。我怎么能这样做?
def sqlstr = new Properties().with { props ->
new File( '/path/to/file' ).withReader { r ->
load( r )
switch( props.ACTION ) {
case 'NEW':
"INSERT INTO TABLE1.DB (NUMBER, NAME1, NAME2, NAME3) VALUES ($NEW_NUMBER, $TEXT_NAME1, $TEXT_NAME2, $TEXT_NAME3)"
"INSERT INTO TABLE2.DB (NUMBER, NAME1, NAME2, NAME3) VALUES ($NEW_NUMBER, $TEXT_NAME1, $TEXT_NAME2, $TEXT_NAME3)"
break
}
}
}
// Assuming sql is set up right:
sql.execute sqlstr