|
楼主 |
发表于 2016-12-5 18:18:42
|
显示全部楼层
JAVA:
public static BigDecimal getDecimalFromSQL(String SQLString){
Map<String, String> sql = new HashMap<String, String>();
sql.put(SQL.DEFAULT_DB_NAME, SQLString);
// 执行SQL并传入参数
Table table = SQL.select(sql, null, "/lab/common/data");
// 从返回的Table对象里面,获取返回值
BigDecimal rs;
Iterator<Row> rows = table.iterator();
if (rows.hasNext()) {
Row row = rows.next();
rs = row.getDecimal(0);
System.out.println(rs); //能显示出正确值,如:124.00
} else {
rs = null;
//throw new RuntimeException("无返回值!");
}
return rs;
}
JS:
getDecimalFromSQL : function(SQL, context) {
var params = new biz.Request.ActionParam();
params.setString("SQLString", SQL);
var rs = null;
biz.Request.sendBizRequest({
"context" : context,
"action" : "getDecimalFromSQL",
"parameters" : params,
"callback" : function(result) {
result.ignoreError = false;
if (result.state) {
rs = result.response; // 返回读取值
alert(rs); //显示返回值为:124, 小数位被去掉了
}
}
});
return rs;
}, |
|