Announcement

Collapse
No announcement yet.

Falscher Wert beim Typ Numeric.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Falscher Wert beim Typ Numeric.

    Hallo,

    ich möchte über eine Stored Procedure einen Wert übergeben (z. B. 3.123) in der Datenbank kommt aber der Wert 3.1299990653992 an. Wie kann ich das ändern?

    Das Feld in der Tabelle ist als TFloat deklariert. (TFloat wurde mit <i> Create Domain TFloat Numeric(10,3) Default 0 Not NULL; </i> angelegt.)

    Die Stored Procedure verwendet als Parameter <i> i_Laenge Numeric(10,3) </i>

    In Delphi rufe ich mithilfe einer TStoredProc Komponente die Stored Procedure mit <i> With Params.CreateParam (ftFloat, 'i_Laenge', ptInput) do AsFloat := 0;
    </i> auf.

    Verwendet wird:
    Delphi 4.0,
    Windows NT4.0,
    BDE

  • #2
    Hallo Michael,

    mit welcher IB-Version und mit welchem SQL-Dialekt arbeitest Du denn. So wie es aussieht wird es wohl eine SQL-Dialekt 1 Datenbank sein.

    Auszug aus dem "IB-DataDefinition Guide"
    <pre>
    How InterBase stores fixed-decimal datatypes
    When you create a domain or column with a NUMERIC or DECIMAL datatype, InterBase
    determines which datatype to use for internal storage based on the precision and scale
    that you specify and the dialect of the database.
     NUMERIC and DECIMAL datatypes that are declared without either precision or scale are
    stored as INTEGER.
     Defined with precision, with or without scale, they are stored as SMALLINT, INTEGER,
    DOUBLE PRECISION or 64-bit integer. Storage type depends on both the precision and the
    dialect of the database. Table 4.2 describes these relationships.
    Precision Dialect 1 Dialect 3
    1 to 4 • SMALLINT for NUMERIC datatypes
    • INTEGER for DECIMAL datatypes SMALLINT
    5 to 9 INTEGER INTEGER
    10 to 18 DOUBLE PRECISION INT64

    TABLE 4.2 How InterBase stores NUMERIC and DECIMAL datatypes
    </pre>

    Als Fazit Wechsel auf Dialekt 3 (ab IB 6.0) oder ändern der Domain auf "Numeric(9,3)".

    Gruß

    Torste

    Comment


    • #3
      Hallo Torsten,

      erstmal Danke für die schnelle Antwort.

      Ich benutze den Interbase Server 5.6 und kann nicht so ohne weiters auf Version 6.0 ändern.

      Wenn ich die Domain auf Numeric(9,3) ändere steht anstelle des 3.123 in der Datenbank nur 3.

      MfG

      Michael M

      Comment

      Working...
      X