导航:
论坛 -> DELPHI技术
斑竹:liumazi,sephil
作者:
2023/3/27 21:47:56
标题:
Firedac 不支持SQL的JSON语法[mysql,sqlite]
浏览:723
加入我的收藏
楼主:
Sqlite mysql 都支持了新的JSON语法 比如 SELECT * FROM userj WHERE haha->>'$.name' ='19'; 但是Fdac的 connection.execsql 会报错 不认识->> 有大佬遇到过么
----------------------------------------------
-
作者:
2023/3/27 22:12:31
1楼:
新测试 使用函数可以 SELECT * FROM userj WHERE json_extract(haha,'$.name') ='19'; 使用-> ->>语法糖不行
----------------------------------------------
-
作者:
2023/3/27 23:56:22
2楼:
FDQuery -> MACRO usage: ---------- select !column from !tab where !id !Sign !idValue -------- try this: var MyMacro:TFDMacro; begin qryMain.Macros.Clear; // MyMacro:= qryMain.Macros.Add; MyMacro.Name := 'xxxxx'; MyMacro.DataType := TFDMacroDataType.mdString; MyMacro.Value := 'xxxxx'; // qryMain.Macros.Add; qryMain.Macros[ n ].DataType := mdInteger; qryMain.Macros[ n ].Value := 'xxxx';
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
2023/3/29 17:26:07
3楼:
@emailx45 My quession is how to support Json . like SELECT * FROM userj WHERE haha->>'$.name' ='19'; haha field is Json.have name member
----------------------------------------------
-
作者:
2023/3/30 0:19:31
4楼:
https://dev.mysql.com/doc/refman/8.0/en/json.html --------- I DONT USE/HAVE MySQL in my PC ---------- procedure TForm1.Button1Click(Sender: TObject); var LFDMacro : TFDMacro; begin // // using SQLite DB in "memory" for test... // each DB have your syntax and types... // FDConnection1.ExecSQL('create table Employee(MyId char(5), MyNames varchar(20));'); FDConnection1.ExecSQL('insert into Employee(MyId, MyNames) values(''1'', ''hello 1 world'');'); FDConnection1.ExecSQL('insert into Employee(MyId, MyNames) values(''2'', ''hello 2 world'');'); // FDQuery1.SQL.Text := 'select !PMyFields from &PMyTable &PMyWhere &PMyOrderBy'; // // mdRAW (asRAW) = ' as is ' // FDQuery1.Macros.Clear; LFDMacro := FDQuery1.Macros.Add; LFDMacro.Name := 'PMyFields'; LFDMacro.DataType := TFDMacroDataType.mdRaw; LFDMacro.AsRaw := 'MyId, MyNames'; // LFDMacro := FDQuery1.Macros.Add; LFDMacro.Name := 'PMyTable'; LFDMacro.DataType := TFDMacroDataType.mdRaw; LFDMacro.AsRaw := 'Employee'; // LFDMacro := FDQuery1.Macros.Add; LFDMacro.Name := 'PMyWhere'; LFDMacro.DataType := TFDMacroDataType.mdRaw; LFDMacro.AsRaw := 'where MyId=2'; // LFDMacro := FDQuery1.Macros.Add; LFDMacro.Name := 'PMyOrderBy'; LFDMacro.DataType := TFDMacroDataType.mdRaw; LFDMacro.AsRaw := 'ORDER by 1'; // for var M in FDQuery1.Macros do Memo1.Lines.Add(M.Index.ToString + ' ' + M.DisplayName + '=> ' + TFDMacro(M).AsString); // FDQuery1.Open; end;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
2023/3/30 0:21:08
5楼:
screnshot
此帖子包含附件: 大小: 46.3K
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3