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;
标签:end,res,db,查询,json,jo,qry From: https://www.cnblogs.com/hnxxcxg/p/17120518.html