DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: sprblck
今日帖子: 10
在线用户: 12
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 chencong5025 (Nicosoft) ▲▲▲△△ -
普通会员
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 会报错 不认识->>

有大佬遇到过么
----------------------------------------------
-
作者:
男 chencong5025 (Nicosoft) ▲▲▲△△ -
普通会员
2023/3/27 22:12:31
1楼: 新测试
使用函数可以 SELECT * FROM userj WHERE json_extract(haha,'$.name') ='19';
使用-> ->>语法糖不行
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
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
作者:
男 chencong5025 (Nicosoft) ▲▲▲△△ -
普通会员
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
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
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
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2023/3/30 0:21:08
5楼: screnshot
此帖子包含附件:
PNG 图像
大小:46.3K
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行78.125毫秒 RSS