Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Delphi Firebird Sql Syntax Problem (https://www.delphipraxis.net/97367-firebird-sql-syntax-problem.html)

Schuster 9. Aug 2007 11:38

Datenbank: Firebird • Version: 1.5 • Zugriff über: Zeos

Firebird Sql Syntax Problem
 
Liste der Anhänge anzeigen (Anzahl: 2)
Hy Leute,

habe ein kleines Problem mit der Umstellung von MySql auf Firebird 1.5:

Bei meiner kleinen Kundendatenbank bekomme ich bei folgenden Code diese Meldung (siehe Anhang Fehler.jpg):

Code:
with DataModule1.ZQuery_Kd_such do
        begin
            sql.Clear;
            sql.Add('Insert into kdaten (Anrede,Titel,FamName,VorName,Strasse,Plz,Ort,'+
                    'GebDat,FamStand,Staatsbuerger,Beruf,Arbeitgeber,Beamter,Betreuer,'+
                    'Bemerkungen,Kundennr) values ('+
                    QuotedStr(Cmb_Kd_Speichern_Anrede.Text)+','+
                    QuotedStr(Cmb_Kd_speichern_Titel.Text)+','+
                    QuotedStr(Edt_Kd_speichern_FamName.Text)+','+
                    QuotedStr(Edt_Kd_speichern_VorName.Text)+','+
                    QuotedStr(Edt_Kd_speichern_Strasse.Text)+','+
                    QuotedStr(Edt_Kd_speichern_Plz.Text)+','+
                    QuotedStr(Edt_Kd_speichern_Ort.Text)+','+
                    QuotedStr(MeineFunktion.Datumformatieren(Edt_Kd_speichern_GebDat.Text))+','+
                    QuotedStr(Cmb_Kd_speichern_FamStand.Text)+','+
                    QuotedStr(Cmb_Kd_speichern_StBuerger.Text)+','+
                    QuotedStr(Edt_Kd_speichern_Beruf.Text)+','+
                    QuotedStr(Edt_Kd_speichern_Arbeitgeber.Text)+','+
                    QuotedStr(OeffD)+','+
                    QuotedStr(Cmb_Kd_speichern_Betreuer.Text)+','+
                    QuotedStr(Memo_Kd_speichern_Sonstiges.Text)+','+
                    QuotedStr ('1')+')');
            ExecSQL;
        end;  //Ende Kundendaten speichern
Wie die DB aufgebaut ist seht ihr im Anhang Datenbank.jpg

mkinzler 9. Aug 2007 12:03

Re: Firebird Sql Syntax Problem
 
Irgend ein Feld ist kleiner als der einzufügenden Wert. Stutze mal dien Inhalt auf die maximale Länge.

Pfoto 9. Aug 2007 12:05

Re: Firebird Sql Syntax Problem
 
Hier habe ich einen Link gefunden, der diesen Fehler beschreibt:
http://www.firebirdsql.org/dotnetfir...1_archive.html

Zitat:
Zitat:

Arithmetic exception, numeric overflow or string truncation (Firebird error)

This error is one of the most frequent ones.

Possible causes:

* Too long string assigned to a VARCHAR variable in a stored procedure (usually hidden because of joining string using || operator).
* Mismatch of stored procedure variable type and field type (shorter varchar(x) in the stored procedure declaration)
Vielleicht hilft das ja weiter

Gruß
Pfoto

Hansa 9. Aug 2007 12:10

Re: Firebird Sql Syntax Problem
 
Und noch ein Versuch mit "Hand-Insert" usw. :zwinker: Auf ähnlichen Salat wollte ich noch gestern hier hinweisen :lol:

http://www.delphipraxis.net/internal...=760226#760226

Gleiches gilt hier auch :

benutze eingebaute Methoden und erfinde sie nicht selber neu. Bin mir allerdings nicht sicher, ob die Zeos überhaupt TDataset kompatibel sind. Falls ja, dann mache es gleich mit Parametern :

Delphi-Quellcode:
Dataset.Insert;
Dataset.FieldByName('ANREDE').AsString := Cmb_Kd_Speichern_Anrede.Text;
...
Dataset.Post;
Geht das mit Zeos, dann sind gleich mehrere Fehlerquellen weg. Zumindest aber ein falsch gesetztes + im String, ein vergessenes ' usw.

Da die "QuotedStr" den Source noch zusätzlich unübersichtlicher machen, würde ich mir das hier auch mal überlegen (ist wenigstens Dialect 3 eingestellt ?) :

Zitat:

Zitat von Firebird
Double-quoted identifiers
Before the SQL-92 standard, it was not legal to have object names (identifiers) in a database that duplicated keywords in the language, were case-sensitive or contained spaces. SQL-92 introduced a single new standard to make any of them legal, provided that the identifiers were defined within pairs of double-quote symbols (ASCII 34) and were always referred to using double-quote delimiters.

The purpose of this “gift” was to make it easier to migrate metadata from non-standard RDBMSs to standards-compliant ones. The down-side is that, if you choose to define an identifier in double quotes, its case-sensitivity and the enforced double-quoting will remain mandatory.

Firebird does permit a slight relaxation under a very limited set of conditions. If the identifier which was defined in double-quotes:

was defined as all upper-case,

is not a keyword, and

does not contain any spaces,

...then it can be used in SQL unquoted and case-insensitively. (But as soon as you put double-quotes around it, you must match the case again!)

Warning
Don't get too smart with this! For instance, if you have tables "TESTTABLE" and "TestTable", both defined within double-quotes, and you issue the command:

SQL>select * from TestTable;
...you will get the records from "TESTTABLE", not "TestTable"!

Unless you have a compelling reason to define quoted identifiers, it is usually recommended that you avoid them. Firebird happily accepts a mix of quoted and unquoted identifiers – so there is no problem including that keyword which you inherited from a legacy database, if you need to.

Warning
Some database admin tools enforce double-quoting of all identifiers by default. Try to choose a tool which makes double-quoting optional.


Schuster 9. Aug 2007 12:20

Re: Firebird Sql Syntax Problem
 
Danke das wars :-D

Warum immer so lange Fehlermeldungen bei so einen einfachen Fehler :wall:

mkinzler 9. Aug 2007 12:44

Re: Firebird Sql Syntax Problem
 
Was war es genau?

Schuster 9. Aug 2007 12:51

Re: Firebird Sql Syntax Problem
 
Meine DB-Felder waren zu kurz :-D


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:45 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz