程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> FireDAC 下的 Sqlite [12]

FireDAC 下的 Sqlite [12]

編輯:Delphi


該話題的繼續延伸主要就是 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

//並發相關: http://docwiki.embarcadero.com/RADStudio/XE6/en/Using_SQLite_with_FireDAC#Locking_and_Concurrent_Updates


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved