2013年10月11日 星期五

groovy_11

"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.MBPartnerLocation

String sql = "select bp.c_bpartner_id, l.c_location_id, l.address1, p.ct_tel, p.ct_fax  from adempiere.c_bpartner bp inner join adempiere.z1_pcust p on p.ct_no = bp.value inner join c_location l on p.ct_addr1 = l.address1 order by p.ct_no";
PreparedStatement pstmt = DB.prepareStatement(sql, A_TrxName);
// pstmt.setInt(1, A_AD_Client_ID);
ResultSet rs = pstmt.executeQuery();
// 只試作 10筆
while (rs.next()) {

  int c_bpartner_id= rs.getInt("c_bpartner_id");
  int c_location_id = rs.getInt("c_location_id");
  String address1 = rs.getString("address1");
  String tel = rs.getString("ct_tel")
  String fax = rs.getString("ct_fax")
 
  MBPartnerLocation MBlocation = new  MBPartnerLocation(A_Ctx, 0, A_TrxName);
  MBlocation.setAD_Client_ID (1000000);
  MBlocation.setC_BPartner_ID (c_bpartner_id);
  MBlocation.setC_Location_ID (c_location_id);
  MBlocation.setName (address1);
  MBlocation.setPhone (tel);
  MBlocation.setFax (fax);  
  MBlocation.save();
   }
rs.close();
pstmt.close();

result="""

沒有留言:

張貼留言