2013年10月11日 星期五

groovy_2

"// A_Tab.setValue("Help", 'abcdefg'.getAt( 3 ))
 import org.compiere.util.DB
 import groovy.sql.Sql
 import java.util.List
 def sql = " select name||','||value from m_product where m_product_id=? ";
 String r  = DB.getSQLValueString(null, sql, [50002]  );
 // String r  = DB.getSQLValueString(null," select name||','||value from m_product where m_product_id=? ",50002);
 if (r==null) r = "Can't Find, nothing";
 def  s = r.tokenize(',;') ;
//  'he,she;it,;they'.tokenize(',;') ;
//  def dt = Date.parse("E MMM dd H:m:s z yyyy", "Tue Aug 10 16:02:43 PST 2010");

 def date = new Date()
 def formattedDate = date.format('yyyy-MM-dd')

Date date1 = Date.parse("dd-MM-yyyy","31-12-2010")
String out1 = date.format("MM-dd-yyyy")

Calendar calendar = GregorianCalendar.instance
calendar.set(2010,3,1) // 1st April 2010

def lastDay = calendar.getActualMaximum(GregorianCalendar.DAY_OF_MONTH)
// assert lastDay == 30

sql=Sql.newInstance('jdbc:sqlserver://127.0.0.1:1433;databaseName=compiere','compiere','compiere', 'com.microsoft.sqlserver.jdbc.SQLServerDriver' )
// sql=Sql.newInstance("jdbc:postgresql://127.0.0.1:5432/tg1004","adempiere", "adempiere","org.postgresql.Driver" )

sql.eachRow( 'select * from compiere.AD_Table' ) { println "$it.AD_Table_id-- ${it.TableName} --" }

A_Tab.setValue("Help", s.first()+"  ,  "+s.last() + " , " + formattedDate )

"

沒有留言:

張貼留言