2014年6月28日 星期六

C:\idempiere-server groovy:H_Search_IPD1

//groovy:H_Search_IPD1


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");

def t_start= System.currentTimeMillis()
String ss= DB.getSQLValueString(null,"select value from h_search where h_search_id = ?", A_Record_ID );
// DB.executeUpdateEx( "delete from h_searchline where h_search_id="+A_Record_ID+ " " , A_TrxName);

def postsql = Sql.newInstance('jdbc:postgresql://127.0.0.1/taya1201','adempiere','adempiere','org.postgresql.Driver' )
def ptable= postsql.dataSet("h_searchline")   //上傳
def informix = Sql.newInstance( 'jdbc:informix-sqli://192.168.170.211:1534/hisipddb:informixserver=hisipdsrv;CLIENT_LOCALE=zh_tw.big5;','informix','db@w94u6', 'com.informix.jdbc.IfxDriver' );
def metadata = informix.connection.metaData
String[] tableTypes = ["TABLE"]
ResultSet rs = metadata.getTables(null, null, null, tableTypes );  //"userlist"
// getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types)
// "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
String tblName = null;
while(rs.next()){
   tblName = rs.getString('TABLE_NAME');
   println ">>>>>> "+tblName
   ResultSet tblMetadata = metadata.getColumns(null, '%', tblName, null);
// ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)  throws SQLException
   while(tblMetadata.next()){
      String TABLE_SCHEM= tblMetadata.getString("TABLE_SCHEM");
      String TABLE_NAME= tblMetadata.getString("TABLE_NAME");
      String COLUMN_NAME= tblMetadata.getString("COLUMN_NAME");
      println TABLE_SCHEM +"."+TABLE_NAME+"."+COLUMN_NAME;

   } // while(tblMetadata.next())
} // while(rs.next())
def t_end = System.currentTimeMillis()
result="執行完成: " + (t_end - t_start)

沒有留言:

張貼留言