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

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','人' )
-
-fishchan-
忘记一个人,并非不再想起,而是偶尔想起,心中却不再有波澜。
5
发布数
3
关注者
12217
累计阅读

热门教程文档

MySQL
34小节
QT
33小节
Swift
54小节
Flutter
105小节
Vue
25小节
广告