Autor Beitrag
recall
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 449



BeitragVerfasst: So 17.08.03 17:58 
Ich habe in einer Prozedur folgendes geschrieben:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
  if Linked then
  begin
    if trans.InTransaction then
      trans.Commit;
    trans.StartTransaction;
    if not query.Prepared then
      query.Prepare;
    query.SQL := SQLText;
    query.ExecSQL;
    Trans.Commit;
    Result := True;
  end
  else
    Result := False;

Linked überprüft u.a., ob meine IBDatabase verbunden ist.
SQLText ist eine Übergabe-Variable, die folgenden Wert hat:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
CREATE TABLE "OLM15_TEST" 
(
  "ID"       INTEGER NOT NULL,
  "NAME"       TSTR25, 
  "VORNAME"       TSTR25,
  "STRASSE"       TSTR30,
  "PLZ"       TPLZ,
  "ORT"       TSTR30,
  "EMAIL"       TSTR30,

CONSTRAINT "PK_OLM15_TEST" PRIMARY KEY ("ID")
);

Wenn ich dieses Script direkt ausführe (IBConsole), dann funktioniert es :) .
Nur wenn ich das mit obiger Routine mache, dann sagt er Empty SQL-Statement. Das es aber nicht leer ist habe ich überprüft: Wenn ich noch folgenden Befehl hinzufüge (am Ende):
ausblenden Quelltext
1:
CREATE GENERATOR "GEN_OLM15_Test";					

..., dann sagt er ERROR: unknown "CREATE" in line 14 Pos -1 (oder so ähnlich).

Was soll das denn ?
Wer kann mir helfen ?

Danke schonmal.

Viele Grüsse.
P.S.: Für schnelle Hilfe wäre ich sehr dankbar :roll: (wieder mal)


Zuletzt bearbeitet von recall am Mo 18.08.03 14:28, insgesamt 1-mal bearbeitet
Lemmy
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 792
Erhaltene Danke: 49

Windows 7 / 10; CentOS 7; LinuxMint
Delphi 7-XE10.1, VS 2015
BeitragVerfasst: Mo 18.08.03 08:35 
Hi,

warum machst Du ein
Query.prepare;

???? Das kann doch gar nicht gehen, wenn die Query leer ist. Zudem ist das bei diesem SQL-statement absolut überflüssig....

GRüße
Lemmy
recall Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 449



BeitragVerfasst: Mo 18.08.03 12:53 
Zitat:
???? Das kann doch gar nicht gehen, wenn die Query leer ist.

Stimmt, Mist (*grummel*)

Danke.

Viele Grüsse.
recall Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 449



BeitragVerfasst: Mo 18.08.03 13:00 
Tja, jetzt habe ich das Prepare weggelöscht, aber es hat sich NIX geändert :( .
Viele Grüsse.
Lemmy
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 792
Erhaltene Danke: 49

Windows 7 / 10; CentOS 7; LinuxMint
Delphi 7-XE10.1, VS 2015
BeitragVerfasst: Mo 18.08.03 13:26 
Hi,

was genau funktioniert denn jetzt nicht? Du kannst übrigends in einer TIBQuery nicht zwei SQL-Statements auf einmal ausführen lassen, deshalb kommt auch die Fehlermeldung "Error unknown "CREATE"...."

Kannst Du mal die genaue Zeile angeben wo es klemmt....???
Grüße
Lemmy
recall Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 449



BeitragVerfasst: Mo 18.08.03 14:08 
Hallo,

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
  if Linked then 
  begin 
    if trans.InTransaction then 
      trans.Commit; 
    trans.StartTransaction; 
    query.SQL := SQLText; 
    query.ExecSQL;         {hier klemmt es: siehe besagte Fehlermeldung !}
    Trans.Commit; 
    Result := True; 
  end 
  else 
    Result := False;


Viele Grüsse.
recall Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 449



BeitragVerfasst: Mo 18.08.03 14:30 
Es lag daran, dass ich aus Versehen meiner query einen datasource (und eine IBDatabase) zugewiesen habe :( . Mist.

Danke nochmal Lemmy.

Viele Grüsse.