json查询
json查询
procedure TFunc1549.select(req, res: TSerialize); var db: tdb; pool: tdbpool; jo: variant; begin try try pool := GetDBPool('1'); db := pool.Lock; db.qry.Close; db.qry.SQL.Clear; db.qry.SQL.Text := 'select * from tunit'; db.qry.Open; TDocVariant.New(jo); jo.status := 200; jo.message := 'success'; jo.tunits := _json(db.qry.ToJSONArrayString); res.asStr['res'] := VariantSaveJSON(jo); except on E: Exception do begin jo.status := 500; jo.message := 'fail'; jo.exception := E.Message; res.asStr['res'] := VariantSaveJSON(jo); end; end; finally pool.Unlock(db); end; end;
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/17120518.html