import groovy.sql.Sql
import java.sql.Timestamp
import org.compiere.util.DB
// def sql = Sql.newInstance("jdbc:postgres://localhost:5432/taya1107", "adempiere", "adempiere", "org.postgresql.Driver")
// def people = sql.dataSet("ZZTEST")
int v1=0
new File("d:\\test\\1.csv").splitEachLine(",")
{fields ->
def s1="NULL"
def n1="NULL"
def n2="NULL"
if (fields[0] != null) s1=fields[0]
if (fields[1] != null) n1=fields[1]
if (fields[2] != null) n2=fields[2]
if (v1 > 0) {
String sql = "INSERT INTO ZZTEST(S1,N1,N2) VALUES ('"+s1+"'," + n1+ ","+n2+")";
DB.executeUpdateEx( sql, A_TrxName);
println sql
}
v1 = v1+1
// people.add
// s1: fields[0],
// n1: fields[1] )
}
沒有留言:
張貼留言