![]() |
Datenbank: Oracle • Zugriff über: ?
Fehler in SQL Statement?
Guten Morgen,
Ich hab da mal 2 SQL Statements, die bei mir Fehler verursachen. Vielleicht sieht ja jemand den Fehler. Zum einen: Rechtes Anführungszeichen fehlt.
Delphi-Quellcode:
Und zum Anderen ein allgemeiner SQL Fehler.
with TQuery( DS ) do
begin SQL.Clear; SQL.Add(' Select REKV_ID as COLUMN1, REKV_TYP as COLUMN2, LF_NAME as COLUMN3, REKV_URSACHE as COLUMN4, REKV_URSACHE_CODE as COLUMN5 from REK_VERU, LF_STM '); SQL.Add(' where ( REKV_REKF_ID = :REKF_ID ) and ( REKV_TYP = ''L'' ) and ( REKV_REF_ID = LF_ID (+)) union '); SQL.Add(' Select REKV_ID as COLUMN1, REKV_TYP as COLUMN2, KD_NAME as COLUMN3, REKV_URSACHE as COLUMN4, REKV_URSACHE_CODE as COLUMN5 from REK_VERU, KD_STM '); SQL.Add(' where ( REKV_REKF_ID = :REKF_ID ) and ( REKV_TYP = ''K'' ) and ( REKV_REF_ID = KD_ID (+)) union '); SQL.Add(' Select REKV_ID as COLUMN1, REKV_TYP as COLUMN2, QM_ABTEILUNG as COLUMN3, REKV_URSACHE as COLUMN4, REKV_URSACHE_CODE as COLUMN5 from REK_VERU, QM_ABT '); SQL.Add(' where ( REKV_REKF_ID = :REKF_ID ) and ( REKV_TYP = ''I'' ) and ( REKV_REF_ID = QM_ABT_ID (+)) union '); SQL.Add(' Select REKV_ID as COLUMN1, REKV_TYP as COLUMN2, '' as COLUMN3, REKV_URSACHE as COLUMN4, REKV_URSACHE_CODE as COLUMN5 from REK_VERU, KD_STM '); SQL.Add(' where ( REKV_REKF_ID = :REKF_ID ) and ( REKV_TYP in ( ''S'',''O'' ) ) '); SQL.Add(' order by 2,3 '); end;
Delphi-Quellcode:
with TQuery( DS ) do
begin SQL.Add(' select fd.*, fst.CA_FS_BEZ, ms.CA_MS_NR '); SQL.Add(' from '); SQL.Add(' REK_FD_PPM fd, CA_FERT_ST fst, CA_MASCH ms '); SQL.Add(' where '); SQL.Add(' ( fd.REKFD_REKF_ID = :REKF_ID ) and '); SQL.Add(' ( fd.REKFD_FS_ID = fst.CA_FS_ID (+)) and '); SQL.Add(' ( fd.REKFD_MAS_ID = ms.CA_MS_ID (+)) '); SQL.Add(' order by REKFD_DATUM desc '); end; |
Re: Fehler in SQL Statement?
Auch guten Morgen.
Der erste Fehler sitzt hier:
Delphi-Quellcode:
Es muss '''' as COLUMN3 heißen.
...
SQL.Add(' Select REKV_ID as COLUMN1, REKV_TYP as COLUMN2, '' as COLUMN3, REKV_URSACHE as COLUMN4, REKV_URSACHE_CODE as COLUMN5 from REK_VERU, KD_STM '); ... Grüße vom marabu |
Re: Fehler in SQL Statement?
Zu Fehler 2: Kann es sein, dass das Feld "REKFD_DATUM" in mehreren Tabellen vorkommt?
Dann müsstest du die Zeile "SQL.Add(' order by REKFD_DATUM desc '); " entsprechend mit dem Tabellenprefix ergänzen, so a la "SQL.Add(' order by fd.REKFD_DATUM desc '); " Greets, Ken |
Re: Fehler in SQL Statement?
Also Fehler 1 ist behoben.
Vielen Dank. Aber Fehler 2 bleibt. Habs ausprobiert, aber funzt nich. Außerdem dürfte die Spalte in keiner weiteren Tabelle auftauchen. |
Re: Fehler in SQL Statement?
Hmm.. Der SQL Code sollte eigentlich stimmen. Ich denke du hast sicherlich ausprobiert, ob er im TOAD oder so funktioniert.
Könnte mir höchstens vorstellen, dass der Parameter "REKF_ID" vielleicht falsch gesetzt wird, als String statt Integer oder sowas... Greets, Ken |
Re: Fehler in SQL Statement?
Ist in Abfrage 2 das SQL-Statement tatsächlich gelöscht, bevor du mit Add neue Zeilen einfügst?
Grüße Mikhal |
Re: Fehler in SQL Statement?
Oh Nein! :wall:
Bin ich blöd. Da hat tatsächlich ein SQL.Clear gefehlt. Das ist nicht das erste mal, dass ich sowas übersehe. :oops: Aber Vielen Dank. |
Re: Fehler in SQL Statement?
Ich hätte da nochmal einen.
Und zwar: Ungültiges Schlüsselwort Symbol-String: (+) Zeilennummer 6
Delphi-Quellcode:
Die Fehlerbeschreibung ist ja schon sehr präzise, dennoch hab ich keine Ahnung warum der Fehler auftritt.
with Query_Verteiler do
begin SQL.Clear; SQL.Add( 'select VT.*, A.QM_ABTEILUNG ' ); SQL.Add( ' from '); SQL.Add( ' REK_VERT VT, QM_ABT A ' ); SQL.Add( ' where ' ); SQL.Add( ' ( REKVT_REK_ID = :inREK_ID ) and ' ); SQL.Add( ' ( REKVT_TYP = :TYP ) and ( REKVT_ABT_ID = A.QM_ABT_ID (+) )' ); SQL.Add( ' order by ' ); SQL.Add( ' QM_ABTEILUNG, REKVT_MA_NAME '); ParamByName( 'inREK_ID' ).DataType := ftInteger; ParamByName( 'TYP' ).DataType := ftString; ParamByName( 'TYP' ).asString := 'V'; end; |
Re: Fehler in SQL Statement?
Zitat:
|
Re: Fehler in SQL Statement?
Zitat:
Also scheint mit dem SQL statement etwas nicht zu stimmen. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:29 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz