码迷,mamicode.com
首页 > 数据库 > 详细

FireDAC 下的 Sqlite [12] - 备忘录(草草结束这个话题了).

时间:2019-11-06 12:56:26      阅读:97      评论:0      收藏:0      [点我收藏+]

标签:custom   size   color   prim   type   exe   并发   tab   ase   

该话题的继续延伸主要就是 SQL 的语法了, 草草收场的原因是现在的脑筋已经进入了 IntraWeb 的世界.



相关备忘会随时补充在下面:


 

//连接多个数据库的参考代码:
FDConnection1.ExecSQL(‘ATTACH ‘‘c:\hr.sdb‘‘ AS hr‘);
FDConnection1.ExecSQL(‘ATTACH ‘‘c:\cust.sdb‘‘ AS cust‘);
FDQuery1.Open(‘select * from "Orders" o ‘ +
  ‘left join hr."Employees" e on o.EmployeeID = e.EmployeeID ‘ +
  ‘left join cust."Customers" c on o.CustomerID = c.CustomerID‘);


//SQLite_OnAuthorize 参考代码:
procedure TForm1.FormCreate(Sender: TObject);
begin
  FDConnection1.Connected := True;
  TSQLiteDatabase(FDConnection1.ConnectionIntf.CliObj).OnAutorize := DoAuthorize;
  FDQuery1.Open;
end;

procedure TForm1.DoAuthorize(ADB: TSQLiteDatabase; ACode: Integer; const AArg1, AArg2, AArg3, AArg4: String; var AResult: Integer);
begin
  Memo1.Lines.Add(Format(‘%d - %s - %s - %s - %s‘, [ACode, AArg1, AArg2, AArg3, AArg4]));
  if ACode = SQLITE_DELETE then
    AResult := SQLITE_DENY
  else
    AResult := SQLITE_OK;
end;


//SQLite_OnUpdate 参考代码:
procedure TForm1.FormCreate(Sender: TObject);
begin
  FDConnection1.Connected := True;
  TSQLiteDatabase(FDConnection1.ConnectionIntf.CliObj).OnUpdate := DoUpdate;
  FDQuery1.Open;
end;

procedure TForm1.DoUpdate(ADB: TSQLiteDatabase; AOper: Integer; const ADatabase, ATable: String; ARowid: sqlite3_int64);
begin
  Memo1.Lines.Add(Format(‘%d - %s - %s - %u‘, [AOper, ADatabase, ATable, ARowid]));
end;


//快速选择到行:
SELECT * FROM Orders WHERE ROWID = :RID

//TFDMemTable 代替 TClientDataSet
procedure TForm1.FormCreate(Sender: TObject);
begin
  with FDMemTable1.FieldDefs.AddFieldDef do
  begin
    Name := ‘word‘;
    DataType := ftString;
    Size := 50;
  end;

  with FDMemTable1.FieldDefs.AddFieldDef do
  begin
    Name := ‘ph‘;
    DataType := ftString;
    Size := 50;
  end;

  with FDMemTable1.FieldDefs.AddFieldDef do
  begin
    Name := ‘note‘;
    DataType := ftString;
    Size := 255;
  end;

  with FDMemTable1.FieldDefs.AddFieldDef do
  begin
    Name := ‘num‘;
    DataType := ftInteger;
  end;

  FDMemTable1.IndexDefs.Add(‘Index_1‘, ‘word‘, [ixPrimary]);
  FDMemTable1.CreateDataSet;
end;

//并发相关: http://docwiki.embarcadero.com/RADStudio/XE6/en/Using_SQLite_with_FireDAC#Locking_and_Concurrent_Updates

FireDAC 下的 Sqlite [12] - 备忘录(草草结束这个话题了).

标签:custom   size   color   prim   type   exe   并发   tab   ase   

原文地址:https://www.cnblogs.com/yjhb/p/11804285.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!