Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   FreePascal Foreign key in SQLite aktivieren? (https://www.delphipraxis.net/181943-foreign-key-sqlite-aktivieren.html)

AlexII 19. Sep 2014 13:30

Datenbank: SQLite • Version: 3 • Zugriff über: Lazarus SQLite3Connection

Foreign key in SQLite aktivieren?
 
Man muss in der SQLite die FKs bei jeder DB-Verbindung aktivieren.

Zitat:

PRAGMA foreign_keys = ON;
Wie mache ich das mit dem Query? Wie schickt man diesen Befehl ab?

Damit klappt das irgendwie nicht, es wird geschluckt, aber wohl in der DB nicht ausgeführt.
Delphi-Quellcode:
SqlQuery1.Close;
SqlQuery1.SQL.Text := 'PRAGMA foreign_keys = ON;';
SqlQuery1.ExecSQL;
SqlTransaction1.Commit;
Danke!

Klaus01 19. Sep 2014 14:50

AW: Foreign key in SQLite aktivieren?
 
Hallo,

vielleicht, hilft Dir dieser Beitrag.

Grüße
Klaus

jobo 19. Sep 2014 14:51

AW: Foreign key in SQLite aktivieren?
 
Zitat:

Tip: If the command "PRAGMA foreign_keys" returns no data instead of a single row containing "0" or "1", then the version of SQLite you are using does not support foreign keys (either because it is older than 3.6.19 or because it was compiled with SQLITE_OMIT_FOREIGN_KEY or SQLITE_OMIT_TRIGGER defined).
Ansonsten kannst Du auch mal probehalbe das Semicolon im Befehl weglassen. Das gilt eigentlich immer (glaubich:)

AlexII 19. Sep 2014 14:58

AW: Foreign key in SQLite aktivieren?
 
Hab's anders gemacht. In den Params von SQLite3Connection eingetragen, und zwar:

Code:
foreign_keys=on;
und kein bisschen anders, ohne Leerzeichen und MIT Semikolon, sonst funkt nix.


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:15 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz