Delphi FireDAC 下的 Sqlite(十二) 備忘錄

來源:互聯網
上載者:User

該話題的繼續延伸主要就是 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 thenAResult := SQLITE_DENY  elseAResult := 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
class="Delphi">procedure TForm1.FormCreate(Sender: TObject);begin  with FDMemTable1.FieldDefs.AddFieldDef do  beginName := 'word';    DataType := ftString;    Size := 50;  end;  with FDMemTable1.FieldDefs.AddFieldDef do  beginName := 'ph';    DataType := ftString;    Size := 50;  end;  with FDMemTable1.FieldDefs.AddFieldDef do  beginName := 'note';    DataType := ftString;    Size := 255;  end;  with FDMemTable1.FieldDefs.AddFieldDef do  beginName := '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

Author:cnblogs 萬一

更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Delphi/

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.