2012年11月19日 星期一

groovy:ImportData


import groovy.sql.Sql
import java.sql.Timestamp
//  sqlinformix = Sql.newInstance('jdbc:informix-sqli://192.168.170.211:1534/hisipddb:informixserver=hisipdsrv','informix','db@w94u6', 'com.informix.jdbc.IfxDriver' )
// sqlOracle = Sql.newInstance( 'jdbc:oracle:thin:@192.168.170.251:1521:orcl',  'adempiere','adempiere','oracle.jdbc.OracleDriver' )
//"jdbc:postgresql://hostname:port/dbname","username", "password");

sqlPostgres=Sql.newInstance('jdbc:postgresql://192.168.0.101:5433/adempiere', "adempiere", "adempiere","org.postgresql.Driver")
def m_created = new Timestamp(System.currentTimeMillis())
def  table_id=0
def v_IsActive="Y"
sqlPostgres.eachRow( 'SELECT *  FROM ADEMPIERE.M_Product' )
{
  table_id=table_id+1
  println "$it.Value -- ${it.Name} --"
 sqlPostgres.execute(
 'INSERT INTO ADEMPIERE.M_Product_T(M_Product_T_ID,AD_Client_ID,AD_Org_ID,Updated, UpdatedBy,Created,CreatedBy, IsActive,M_Product_ID,Value,Name,Description,C_UOM_ID,M_Product_Category_ID,C_TaxCategory_ID)'
 +'VALUES ( ?, 11, 11, now(), 0, now(), 0, ?, ?, ?, ?, ?,?,?,? )' ,
 [table_id, v_IsActive, it.M_Product_ID,it.Value,it.Name,it.Description,it.C_UOM_ID,it.M_Product_Category_ID,it.C_TaxCategory_ID]  )
}
result=""

沒有留言:

關於我自己

我的相片
Skype:ADempiere/Compiere MSN:albert_a_chen@yahoo.com