Autor Beitrag
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: So 06.07.03 20:41 
Hi,

Ich habe ein Insert, welches funktioniert. Nur was ist, wenn ein Datensatz in der DB schon drinne ist, so daß eigentlich ein Update nötig wäre ? Muß ich da mit Select und IsEmpty vorher das prüfen oder wie?

Und dann eben entscheiden: neuer Datensatz / vorhandener ? Oder kann ich eine Fehlermeldung auswerten ?

_________________
Gruß
Hansa
lkz633
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 136

WinXP, Suse Linux 8.2 (unter VMWare)
D7 Prof, K3 Prof
BeitragVerfasst: So 06.07.03 20:57 
Ich habe mal ein Datenbank-Synchronisationsprogramm geschrieben, dort habe ich es so gemacht: erst den Quell- Datensatz ausgelesen und damit ein select-statement erzeugt. Dieses dann in der zieltabelle ausgefuehrt. Falls
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
  if RecordCount=0 then 
    "insert into" 
  else
    if RecordCount=1 then 
     "update"
  else
     "Tabelle ist kaputt :-(


Gruss lkz633
hansa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: So 06.07.03 21:06 
Dafür habe ich doch "IsEmpty". Dann, falls true : insert, false : update. Vorrausgesetzt, das SELECT stimmt. Gut, ich frage mal andersrum: Was ist eigentlich, falls ein Insert auf einen bestehenden Datensatz durchgeführt wird, mit gleichem Primary-Key Wert :?:

Ich ahne schon, ohne Select wirds nicht gehen, oder doch ?

_________________
Gruß
Hansa
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: So 06.07.03 21:10 
Dann meldet Interbase einen Fehler und bricht die Transaktion ab....
hansa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: So 06.07.03 22:59 
ja und dann ?

_________________
Gruß
Hansa