ich mache zurzeit meine ersten vorsichtigen Schritte mit SQL in Verbindung mit Lazarus. Wie sonst auch, hat jede meiner Tabellen eine Spalte ID, welche ganz normal via AUTO_INCREMENT hochgezählt werden soll.
Dies ist mein Code:
Code: Alles auswählen
{ Create property table }
SQLQuery1.SQL.Text := 'CREATE TABLE IF NOT EXISTS prop (PID int AUTO_INCREMENT PRIMARY KEY, name varchar(255) NOT NULL, val varchar(255) NOT NULL)';
SQLQuery1.ExecSQL;
SQLTransaction1.Commit;
{ Add test property }
SQLQuery1.SQL.Text := 'INSERT INTO prop (PID, name, val) VALUES (NULL, "Prop1", "Val1.1")';
SQLQuery1.ExecSQL;
SQLTransaction1.Commit;
Nun habe ich testweise mehrere Properties in die Tabelle eingespeichert. Allerdings habe ich festgestellt, dass alle Datensätze die PID 0 haben. Es scheint, als würde das AUTO_INCREMENT ohne Wirkung sein. Auch ein Test mit IDENTITY(0, 1) zählt die ID nicht hoch.
Eine Suche im Internet hat nichts ergeben. Wisst ihr, was das Problem ist?
Grüße