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" // PL No.,
def s2="null" // 客戶單號,
def s3="null" // 料號,
def s4="null" // 船公司,
def s5="null" // 船名,
def s6="null" // 航次,
def s7="null" // S/O no.,
def s8="null" // 貨櫃號碼,
def s9="null" // 起運港,
def s10="null" // 結關日,
def s11="null" // 預定開航日,
def s12="null" // 實際開航日,
def s13="null" // 抵達港,
def s14="null" // 預計抵港日,
def s15="null" // 實際抵港日,
def s16="null" // 清關日
if (fields[0] != null) s1=fields[0]
if (fields[1] != null) s2=fields[1]if (fields[2] != null) s3=fields[2]
if (fields[3] != null) s4=fields[3]
if (fields[4] != null) s5=fields[4]if (fields[5] != null) s6=fields[5]
if (fields[6] != null) s7=fields[6]
if (fields[7] != null) s8=fields[7]if (fields[8] != null) s9=fields[8]
if (fields[9] != null) s10=fields[9]
if (fields[10] != null) s11=fields[10]if (fields[11] != null) s12=fields[11]
if (fields[12] != null) s13=fields[12]
if (fields[13] != null) s14=fields[13]
if (fields[14] != null) s15=fields[14]
if (fields[15] != null) s16=fields[15]
if (v1 > 0) {
String sql = "INSERT INTO zztest(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16)
) VALUES ("
+" '" +s1
+"', " +s2
+" , " +s3
+" , " +s4
+" , " +s5
+" , " +s6
+" , " +s7
+" , " +s8
+" , " +s9
+" , " +s10
+" , " +s11
+" , " +s12
+" , " +s13
+" , " +s14
+" , " +s15
+" , " +s16
+")";
DB.executeUpdateEx( sql, A_TrxName);
println sql
}
v1 = v1+1
// people.add
// s1: fields[0],
// n1: fields[1] )
}
沒有留言:
張貼留言