2013年10月11日 星期五

groovy_5

"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 sphd' )
{ println "$it.sh_sfg -- ${it.sh_gfg} -- ${it.sh_date} -- ${it.sh_spno} -- ${it.sh_mnno} -- ${it.sh_skno} -- ${it.sh_sknm} -- ${it.sh_afno} -- ${it.sh_dsno} -- ${it.sh_opfg} -- ${it.sh_owsno} -- ${it.sh_owsnm} -- ${it.sh_owkord} -- ${it.sh_pfg} -- ${it.sh_wsno} -- ${it.sh_wsnm} -- ${it.sh_wkord} -- ${it.sh_sskno} -- ${it.sh_ssknm} -- ${it.sh_qty} -- ${it.sh_ufg} -- ${it.sh_rqty} -- ${it.sh_pcost} -- ${it.sh_ecost} -- ${it.sh_wchg} -- ${it.sh_inno} -- ${it.sh_bno} -- ${it.sh_memo} -- ${it.sh_tcost} -- ${it.sh_acost} -- ${it.sh_dtqty} -- ${it.sh_ncost} -- ${it.sh_tfg} -- ${it.sh_psno} -- ${it.sh_dpno} -- ${it.sh_dpnm} -- ${it.sh_tlno} -- ${it.sh_ifg} -- ${it.sh_rate_nm} -- ${it.sh_rate} -- ${it.sh_mcost} --  "  //讓程式在背景執行
sqlpostgresql.execute('INSERT INTO z_sphd(sh_sfg, sh_gfg, sh_date, sh_spno, sh_mnno, sh_skno, sh_sknm, sh_afno, sh_dsno, sh_opfg, sh_owsno, sh_owsnm, sh_owkord, sh_pfg, sh_wsno, sh_wsnm, sh_wkord, sh_sskno, sh_ssknm, sh_qty, sh_ufg, sh_rqty, sh_pcost, sh_ecost, sh_wchg, sh_inno, sh_bno, sh_memo, sh_tcost, sh_acost, sh_dtqty, sh_ncost, sh_tfg, sh_psno, sh_dpno, sh_dpnm, sh_tlno, sh_ifg, sh_rate_nm, sh_rate, sh_mcost) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',[it.sh_sfg, it.sh_gfg, it.sh_date, it.sh_spno, it.sh_mnno, it.sh_skno, it.sh_sknm, it.sh_afno, it.sh_dsno, it.sh_opfg, it.sh_owsno, it.sh_owsnm, it.sh_owkord, it.sh_pfg, it.sh_wsno, it.sh_wsnm, it.sh_wkord, it.sh_sskno, it.sh_ssknm, it.sh_qty, it.sh_ufg, it.sh_rqty, it.sh_pcost, it.sh_ecost, it.sh_wchg, it.sh_inno, it.sh_bno, it.sh_memo, it.sh_tcost, it.sh_acost, it.sh_dtqty, it.sh_ncost, it.sh_tfg, it.sh_psno, it.sh_dpno, it.sh_dpnm, it.sh_tlno, it.sh_ifg, it.sh_rate_nm, it.sh_rate, it.sh_mcost])}
def t_end = System.currentTimeMillis()
result="執行完成: " + (t_end - t_start)"

沒有留言:

張貼留言