JSON序列——根据JSON生成事务性SQL

JSON序列——根据JSON生成事务性SQL

procedure TForm1.Button5Click(Sender: TObject);
begin
  var json: string :='' +
        '{'+
			  '"table":"tunit",'+
            '"rows":'+
            '['+
                '{"action": "modify", "original": {"unitid":"11","unitname":"个"}, "current": {"unitid":"11","unitname":"中"}},'+
                '{"action": "delete", "original": {"unitid":"66","unitname":"国"}},'+
                '{"action": "insert", "current":{"unitid":"13","unitname":"人"}}'+
            ']'+
        '}';
  var serial: TynJsonCross := TynJsonCross.Create;
  try
    Memo1.Text := serial.JsonToSql(json);
  finally
    serial.DisposeOf;
  end;
end;

  生成的事务性SQL:

update tunit set unitid='11',unitname='中' where unitid='11' and unitname='个'
delete from tunit where unitid='66' and unitname='国'
insert into tunit (unitid,unitname) values ('13','人' )

  

猜你喜欢

转载自www.cnblogs.com/hnxxcxg/p/10657013.html