Autor Beitrag
jo-freaky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24



BeitragVerfasst: Di 27.06.06 17:45 
Hi,

habe mal wieder ein kleines Problemchen:
DB: Firebird Embedded 1.5

Ich will ein Datum in eine Tabelle einfügen und dachte mir das ungefähr so:

Insert into TABLE (DATUM) VALUES (12.12.2001); // In IBExpert funktioniert's

das hat leider nicht funktioniert, hab' auch schon Insert into TABLE (DATUM) VALUES (12.12.2001 AS DATE); versucht - fehlanzeige.

Danke im Vorraus!

Gruß
Johannes


Zuletzt bearbeitet von jo-freaky am Di 27.06.06 19:36, insgesamt 1-mal bearbeitet
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Di 27.06.06 17:52 
Ich kann mir nicht vorstellen, das es ohen Quotes funktioniert.
ausblenden SQL-Anweisung
1:
Insert into TABLE (DATUM) VALUES ('12.12.2001');					

_________________
Markus Kinzler.
jo-freaky Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24



BeitragVerfasst: Di 27.06.06 19:17 
Mhrm das hatte ich auch schon alle versucht, dann müsste das ja so aussehen oder?

ausblenden Delphi-Quelltext
1:
ReCreateQ.SQL.Add('INSERT INTO RECHNUNGEN (REDAT) Values ('12.12.2001')');					


dann muckt allerdings der compiler:

Operator oder Semikolon fehlt.


Gruß
Johannes
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 27.06.06 19:34 
du musst das auch dementsprechend formatieren:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
function DateTimetoSQL(DateTime:TDateTime):string;
begin
     result := formatdatetime('yyyy-mm-dd hh:nn:ss',DateTime);
end;


und wenn du IN einem String ein einfaches Anführungszeichen haben willst musst du es verdoppeln: ''
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 27.06.06 19:38 
ausblenden Delphi-Quelltext
1:
ReCreateQ.SQL.Add('INSERT INTO RECHNUNGEN (REDAT) Values (' + QuotedStr('12.12.2001') + ')');					

Eine andere Möglichkeit wäre die Nutzung von Parametern.
jo-freaky Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24



BeitragVerfasst: Di 27.06.06 20:04 
Ich hab's jetzt mal so gemacht wie jascoul:

ausblenden Delphi-Quelltext
1:
ReCreateQ.SQL.Add('INSERT INTO RECHNUNGEN (KDNR,REDAT) Values ('+QuotedStr('424')+',' + QuotedStr('12.12.2001') + ');');					


Der Compiler meckert nichtmehr jedoch kriege ich jetzt folgende Exception:

Exception der Klasse EZSQLException, 'Cannot retrieve Resultset data'.

Verwendete Komponenten: ZeosLib


Thx

Gruß
Johannes
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Di 27.06.06 20:22 
Hast du Query.Open; gemacht? Ein Insert liefert keinen ResultSet. Du mußt query.ExecSQL; ausführen

_________________
Markus Kinzler.
jo-freaky Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24



BeitragVerfasst: Di 27.06.06 20:43 
Vielen Dank!

Genau das wars!
Wo kann ich den Unterschied zwischen .Open und ExecSQL nachlesen?

Gruß
Johannes
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Di 27.06.06 20:47 
.Open wird nur bei Select-Statements verwendet; es wird ein Ergebnis zurückgeliefert. .ExecSQL wird für alle Abfrage verwendet, welche kein Ergebnis zurückliefern.

_________________
Markus Kinzler.
jo-freaky Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24



BeitragVerfasst: Di 27.06.06 21:33 
Dann lag ich mit meiner Vermutung also richtig.

Vielen Dank für eure prompte kompetente Hilfe!!!!

Gruß
Johannes