首页 > 数据库技术 > 详细

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

时间:2019-04-04 22:25:16      阅读:175      评论:0      收藏:0      [点我收藏+]

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

procedure TForm1.Button3Click(Sender: TObject);
begin
  var json:string:=‘‘+
‘{‘+
    ‘"deltas":‘+
    ‘[‘+
        ‘{‘+
			      ‘"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.JsonsToSql(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‘,‘人‘ )

  

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

原文:https://www.cnblogs.com/hnxxcxg/p/10657022.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!