"import java.sql.Timestamp
import java.math.BigDecimal
import java.sql.PreparedStatement
import java.sql.ResultSet
import org.compiere.util.DB
import org.compiere.model.MBPartner
int v_count = 0;
String sql = "SELECT a.ct_no, a.ct_name, b.ct_sname, b.ct_unino from (SELECT max(ct_no) as ct_no, ct_name FROM adempiere.z1_pcust where ct_class = '1' group by ct_class,ct_name order by ct_no, ct_name) a inner join adempiere.z1_pcust b on a.ct_no = b.ct_no order by b.ct_no";
PreparedStatement pstmt = DB.prepareStatement(sql, A_TrxName);
// pstmt.setInt(1, A_AD_Client_ID);
ResultSet rs = pstmt.executeQuery();
// 只試作 10筆
while (rs.next()) {
String value = rs.getString("ct_no");
String name = rs.getString("ct_name");
String name2 = rs.getString("ct_sname");
String duns = rs.getString("ct_unino");
MBPartner bp = new MBPartner(A_Ctx, 0, A_TrxName);
bp.setAD_Client_ID (1000000);
bp.setC_BP_Group_ID (1000000);
bp.setValue (value);
bp.setName (name);
bp.setName2 (name2);
bp.setDUNS (duns);
bp.setIsCustomer (true);
bp.setIsVendor (false);
bp.setIsEmployee (false);
bp.save();
}
rs.close();
pstmt.close();
result="""
沒有留言:
張貼留言