Autor Beitrag
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Do 15.03.12 15:45 
Moin,

wie regelmäßig verzweifle ich mal wieder. Ich versuche eine Abfrage durchzuführen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
    
  fQuery.SQL.Add('UPDATE article SET');
  fQuery.SQL.Add(format('"barcode" = "%s", "name" = "%s", "notes" = "%s", "img_ID" = "%d",',[fBarcode, fName, fNotes, fImgID]));
  fQuery.SQL.Add(format('"group_ID" = "%d" , "category_ID" = "%d", "chain_ID" = "%d", ',[fGroupID, fCategoryID, fChainID]));
  fQuery.SQL.Add(format('"amount" = "%n" , "unit" = "%s"',[fAmount,fUnit]));
  fQuery.SQL.Add('WHERE "ID" = ' + QuotedStr(IntToStr(fID)));


Das Formatieren klappt auch. Ich erhalte folgenden SQL-String:

ausblenden SQL-Anweisung
1:
2:
3:
UPDATE article SET
"barcode" = "4009412813""name" = "Frische Milch...""notes" ="1.5 % Fett, pasteurisiert" , "img_ID" = "0""group_ID" = "0""category_ID"="1""chain_ID"="1","amount"="1,00" , "unit"="Liter"
WHERE "ID"="3"


Nun Beschwert sich irgendeine Überprüfungseinheit :"Der Parameter barcode hat keinen Standardwert"

Ich kann aber nirgends erkennen, wo ich versuche einen Standardwert zu schreiben o.Ä.

Um Lösungsvorschläge wird gebeten.

LG
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Do 15.03.12 16:23 
gegen was für eine Datenbank fährst Du denn, die "" um Feldbezeichner und Werte kommen mir seltsam vor.
Funktioniert der beiliegende SQL in der Datenbankoberfläche?

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS

Für diesen Beitrag haben gedankt: FinnO
FinnO Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Do 15.03.12 16:27 
Moin Bummi

habe die Anführungszeichen mal überarbeitet. Wenn ich direkt folgenden SQL-String execute:

ausblenden SQL-Anweisung
1:
2:
3:
UPDATE article SET
barcode = "12371273" , articlename="test" 
WHERE ID = 3


Funktioniert das blendend.

Ändert nur nichts an der Fehlermeldung, wenn ich es wie oben angegeben durchführe.

EDIT: Gnade mir Gott - das Feld heißt "articlename" und nicht "name" - Ich verrecke. Danke Trotzdem. Funktionierender code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
    fQuery.SQL.Add('UPDATE article SET');
    fQuery.SQL.Add(format('barcode = "%s", articlename = "%s", notes = "%s", img_ID = %d,',[fBarcode, fName, fNotes, fImgID]));
    fQuery.SQL.Add(format('group_ID = %d , category_ID = %d, chain_ID = %d, ',[fGroupID, fCategoryID, fChainID]));
    fQuery.SQL.Add(format('amount = "%n" , unit = "%s"',[fAmount,fUnit]));
    fQuery.SQL.Add('WHERE ID = ' +IntToStr(fID));
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Do 15.03.12 17:45 
Die falschen Quotes sinds immer noch ;)
Für Strings sind die einfachen '' zuständig - dann auch noch die String-Werte durch QuotedStr jagen.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
FinnO Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Do 15.03.12 18:44 
Stört aber glücklicherweise meine Datenbank nicht :)
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Do 15.03.12 18:49 
Access ??

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS
FinnO Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Do 15.03.12 19:04 
Jo !!
vagtler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 96
Erhaltene Danke: 24


Delphi 2010, C# (VS 2012), Objective-C, Java
BeitragVerfasst: Fr 16.03.12 08:22 
Ach so, ich dachte hier war die Rede von einer Datenbank. :mrgreen:

Für diesen Beitrag haben gedankt: Martok