fdLocalSql使用方法
fdLocalSql可以对fdMemTable内存表进行SQL查询(可以对多个fdMemTable内存表进行联表查询哦),fdLocalSql使用SQLITE引擎,而FIREDAC驱动SQLITE,连SQLITE驱动DLL都不需要附带的。
1)设置fdConnection为SQLITE
2)设置TfdLocalSQL
3)创建内存表,Brands,Models:TfdMemTable
procedure TfrmMain.FormCreate(Sender: TObject); begin with Brands do begin with FieldDefs do begin Clear; Add('Code', ftInteger); Add('Name', ftString, 20); end; Active := True; AppendRecord([1, 'Audi']); AppendRecord([2, 'BMW']); AppendRecord([3, 'Mercedes']); end; with Models do begin with FieldDefs do begin Clear; Add('Brand', ftInteger); Add('Name', ftString, 20); Add('ModelYear', ftInteger); Add('Price', ftCurrency); end; Active := True; AppendRecord([1, 'A4', 2012, 40000]); AppendRecord([1, 'A6', 2012, 50000]); AppendRecord([1, 'Q7', 2012, 70000]); AppendRecord([2, '3', 2012, 40000]); AppendRecord([2, '5', 2012, 50000]); AppendRecord([2, 'X5', 2012, 70000]); AppendRecord([3, 'C', 2012, 40000]); AppendRecord([3, 'E', 2012, 50000]); AppendRecord([3, 'G', 2012, 70000]); end; end;
4)FDQUERY进行SQL内存表查询