2014年6月28日 星期六

iDempiere Oracle HIS SAP 系統轉換 groovy:Import H_PT_INFO

//groovy:Import H_PT_INFO


import groovy.sql.Sql
import java.sql.Timestamp
import java.sql.PreparedStatement
import java.sql.ResultSet
import java.sql.Types
import org.compiere.util.Env
import org.compiere.util.DB

int client=Env.getContextAsInt(A_Ctx, "AD_Client_ID");
int org=Env.getContextAsInt(A_Ctx, "AD_Org_ID");
int uid=Env.getContextAsInt(A_Ctx, "#AD_User_ID");

sqlinformix = Sql.newInstance( 'jdbc:informix-sqli://192.168.170.211:1534/hisipddb:informixserver=hisipdsrv','informix','db@w94u6', 'com.informix.jdbc.IfxDriver' )
// sqlOracle = Sql.newInstance( 'jdbc:oracle:thin:@192.168.170.251:1521:orcl', 'adempiere','adempiere', 'oracle.jdbc.OracleDriver' )
def postsql = Sql.newInstance('jdbc:postgresql://127.0.0.1/ad20140605','adempiere','adempiere','org.postgresql.Driver' )
def ptable= postsql.dataSet("H_PT_INFO")   //上傳

def isActive='Y'
def H_PT_INFO_ID=0
def m_created = new Timestamp(System.currentTimeMillis());
sqlinformix.eachRow( 'select * from ptinfo order by chartno' )
{  // H_PT_INFO_ID= H_PT_INFO_ID+1
      println " $it.chartno "
      /*
      postsql.query("select adempiere.nextid(1000004, 'N') as id , adempiere.generate_uuid() as uu ")
      { ResultSet rsuu -> if (rsuu.next()) {
                 id = rsuu.getInt('id')
                 uu = rsuu.getString('uu')  }   }

      ptable.add(
      ad_client_id:client, ad_org_id:org,  isactive: 'Y', createdby:uid,  updatedby:uid,
      h_pt_info_id:id, h_pt_info_uu:uu,
      value: it.chartno,
      name: it.chartno
      )
      */
   // postsql.execute('insert into H_PT_INFO('
   //       +'H_PT_INFO_ID, AD_Client_ID, AD_Org_ID, Updated, UpdatedBy, Created, CreatedBy, IsActive,'
   //        +'chartno) values (?, 11, 11, SYSDATE, 0, SYSDATE, 0, ?, ?)',  [ H_PT_INFO_ID,isActive,   it.chartno])
}
result=""

沒有留言:

張貼留言