"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.MUser
String sql = "select bp.c_bpartner_id, bpl.c_bpartner_location_id, p.ct_contact from c_bpartner bp inner join adempiere.z1_pcust p on p.ct_no = bp.value inner join adempiere.c_bpartner_location bpl on bpl.c_bpartner_id = bp.c_bpartner_id where length(p.ct_contact) > 1";
PreparedStatement pstmt = DB.prepareStatement(sql, A_TrxName);
// pstmt.setInt(1, A_AD_Client_ID);
ResultSet rs = pstmt.executeQuery();
// 只試作 10筆
while (rs.next()) {
String name = rs.getString("ct_contact");
int c_bpartner_id= rs.getInt("c_bpartner_id");
int c_bpartner_location_id= rs.getInt("c_bpartner_location_id");
MUser user = new MUser(A_Ctx, 0, A_TrxName);
user.setAD_Client_ID (1000000);
user.setName (name);
user.setValue (name);
user.setC_BPartner_ID (c_bpartner_id);
user.setC_BPartner_Location_ID (c_bpartner_location_id);
user.save();
}
rs.close();
pstmt.close();
result="""
沒有留言:
張貼留言