Autor Beitrag
Cube
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: So 02.01.05 19:20 
Hallo,
habe eine kurze Frage zum Thema SQL. Und zwar habe ich folgendes Problem:
Ich habe eine Personentabelle mit dem Primärschlüssel 'PID'. Nun möchte ich jedesmal, wenn eine neue Person hinzugefügt wird, den Primärschlüssel von der jeweiligen Person auslesen und diesen gleichzeitig in eine Variable speichern, zum Beispiel (Bevor das Auslesen stattfindet, wurde die Person schon hinzugefügt). Das müsste doch eigentlich mit einer normalen Select-Anweisung realisierbar sein, oder?
Nun weiß ich auch nicht, mit welcher Anweisung ich genau den Rückgabewert erhalte, also die Zahl.

Ich hoffe, mir kann jemand helfen,
Schon mal Danke...

Gruß,
Cube
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: So 02.01.05 19:25 
SELCET PID FROM TABELLE WHERE NAME="Neue Person";
Cube Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: So 02.01.05 19:31 
Hab ich schon probiert, ich bekomme aber kein Rückgabewert
Also den Wert 0 bekomme ich leider
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: So 02.01.05 19:36 
Du solltest diese Abfrage auch erst dann ausführen, wenn der Eintrag in der Datenbank abgespeichert ist und der Vorgang abgeschlossen ist.
Cube Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: So 02.01.05 19:52 
jaja...der Vorgang sollte auch eigentlich mit execsql abgeschlossen sein. Danach habe ich folgendes eingefügt:

ausblenden Delphi-Quelltext
1:
2:
DataModule3.Person.SQL.clear;
temp:=DataModule3.Person.SQL.add('Select PID FROM Person WHERE (PersonalausweisNr = Edit9.Text)');

Wenn ich dann beispielsweise showmessage machen, ergibt der Eintrag immer noch null.
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: So 02.01.05 20:11 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
DataModule3.Person.SQL.clear;
DataModule3.Person.SQL.add(DataModule3.Person.SQL.add('Select PID FROM Person WHERE (PersonalausweisNr ="' + Edit9.Text + '")');
Open;
Active := True;
temp:=Fields[0].AsInteger;   // AsString verwenden, wenn PID ein Stringfeld ist
Active:=False;
DataModule3.Person.SQL.clear;
Cube Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: So 02.01.05 20:55 
ahh....klappt wunderbar.
Ich danke dir vielmals...danke! :wink:

Gruß,
Cube
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: So 02.01.05 21:09 
Bitte nichts zu danken.