// 建立 '資料表' 來接受上傳 String tableName = '船期與貨況追蹤' String tableDefinition = "" "CREATE TEXT TABLE $tableName (
packinglist_id NUMERIC(10,0),
"船公司" VARCHAR(40),
"船名" VARCHAR(40),
"航次" VARCHAR(20),
shippingorder VARCHAR(20),
"貨櫃號碼" VARCHAR(20),
"起運港" VARCHAR(40),
"結關日" DATE,
"預定開航日" DATE,
"實際開航日" DATE,
"抵達港" VARCHAR(40),
"預定抵港日" date,
"實際抵港日" date,
"清關日" date,
ad_client_id NUMERIC(10,0) NOT NULL,
ad_org_id NUMERIC(10,0) NOT NULL,
isactive CHAR(1) NOT NULL DEFAULT 'Y'::bpchar,
created timestamp without time zone NOT NULL DEFAULT now(),
createdby NUMERIC(10,0) NOT NULL,
updated timestamp without time zone NOT NULL DEFAULT now(),
updatedby NUMERIC(10,0) NOT NULL,
"船期與貨況追蹤_id" NUMERIC(10,0),
"船期與貨況追蹤_uu" VARCHAR(36)
// atomic_number INTEGER PRIMARY KEY, ); "" " //create a new file database and a table corresponding to the csv file Sql sql = Sql.newInstance( "jdbc:hsqldb:file:${testdbDir.absolutePath}/testdb" , 'sa' , '' , 'org.hsqldb.jdbcDriver' ) sql.execute(tableDefinition) //set the source to the csv file sql.execute( "SET TABLE elements SOURCE '${TEST_FILE_NAME};all_quoted=true'" .toString()) //querying the database that's wrapping our CSV file def elementsOver200Mass = sql.rows( "SELECT * FROM $tableName WHERE atomic_mass > ?" , [ 200 ]) def elementsBetween10And20 = sql.rows( "SELECT * FROM $tableName WHERE atomic_mass <= ? AND atomic_mass >= ?" , [ 20 , 10 ]) //simple db aggregates def count = 0 sql.eachRow( "SELECT count(1) FROM $tableName WHERE atomic_mass <= ?" , [ 20 ]){row-> count = row[ 0 ] } def avg = 0 sql.eachRow( "SELECT avg(atomic_mass) FROM $tableName" .toString()){row-> avg = row[ 0 ] }
|
2013年11月11日 星期一
idempiere ERP '船期與貨況追蹤'
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言