2013年10月11日 星期五

groovy_6

"import groovy.sql.Sql
import java.sql.Timestamp
//jdbc:sqlserver://" + dbHost + ":" + dbPort + ";databaseName=" + dbName + ";";

//MSSQL
sqlmssql =Sql.newInstance('jdbc:sqlserver://192.168.22.66:1433;databaseName=LYTDB00','sa','80485934',
'com.microsoft.sqlserver.jdbc.SQLServerDriver' )

//PostgreSQL
sqlpostgresql =Sql.newInstance('jdbc:postgresql://192.168.22.90/idempiere','adempiere','adempiere','org.postgresql.Driver' )

def isActive='Y'
def H_ID=1000000
def m_created = new Timestamp(System.currentTimeMillis());
def t_start = System.currentTimeMillis()
sqlmssql.eachRow( 'select * from spdt' )
{ println "$it.sd_sfg -- ${it.sd_date} -- ${it.sd_spno} -- ${it.sd_seq} -- ${it.sd_wkord} -- ${it.sd_skno} -- ${it.sd_sknm} -- ${it.sd_pfg} -- ${it.sd_wsno} -- ${it.sd_wsnm} -- ${it.sd_ucost} -- ${it.sd_skqty} -- ${it.sd_qty} -- ${it.sd_bqty} -- ${it.sd_memo} -- ${it.sd_ncost} -- ${it.sd_ufg} -- ${it.sd_ufgnm} -- ${it.sd_rqty} -- ${it.sd_fml1} -- ${it.sd_fml2} -- ${it.sd_hpfg} -- ${it.sd_hwsno} --  "  //讓程式在背景執行
sqlpostgresql.execute('INSERT INTO z_spdt(sd_sfg, sd_date, sd_spno, sd_seq, sd_wkord, sd_skno, sd_sknm, sd_pfg, sd_wsno, sd_wsnm, sd_ucost, sd_skqty, sd_qty, sd_bqty, sd_memo, sd_ncost, sd_ufg, sd_ufgnm, sd_rqty, sd_fml1, sd_fml2, sd_hpfg, sd_hwsno) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',[it.sd_sfg, it.sd_date, it.sd_spno, it.sd_seq, it.sd_wkord, it.sd_skno, it.sd_sknm, it.sd_pfg, it.sd_wsno, it.sd_wsnm, it.sd_ucost, it.sd_skqty, it.sd_qty, it.sd_bqty, it.sd_memo, it.sd_ncost, it.sd_ufg, it.sd_ufgnm, it.sd_rqty, it.sd_fml1, it.sd_fml2, it.sd_hpfg, it.sd_hwsno])}
def t_end = System.currentTimeMillis()
result="執行完成: " + (t_end - t_start)"

沒有留言:

張貼留言