AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken Delphi BDE - SQL - Select - Rundungsproblem
Thema durchsuchen
Ansicht
Themen-Optionen

BDE - SQL - Select - Rundungsproblem

Ein Thema von stahli · begonnen am 31. Mai 2011 · letzter Beitrag vom 1. Jun 2011
Antwort Antwort
Benutzerbild von stahli
stahli

Registriert seit: 26. Nov 2003
Ort: Halle/Saale
4.336 Beiträge
 
Delphi 11 Alexandria
 
#1

BDE - SQL - Select - Rundungsproblem

  Alt 31. Mai 2011, 16:50
Datenbank: Paradox • Version: D7 • Zugriff über: BDE
In einem ALTEN Projekt will ich eine SQL-Abfrage anpassen:

Code:
QueryAw1.SQL.Add('where ... ((p.Gesamtpreis/p.Menge)<>p.Einzelpreis))');
Hier ergeben sich u.U. offenbar 1000tel Rundungsdifferenzen. Die angezeigten Werte im DBGrid sind identisch.
"Round" und "Abs" unterstützt die BDE offenbar nicht.

Kennt einer von den älteren Herren noch eine einfache Lösung?
Stahli
http://www.StahliSoft.de
---
"Jetzt muss ich seh´n, dass ich kein Denkfehler mach...!?" Dittsche (2004)
  Mit Zitat antworten Zitat
omata

Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
 
Delphi 7 Enterprise
 
#2

AW: BDE - SQL - Select - Rundungsproblem

  Alt 31. Mai 2011, 17:04
Vielleicht so...
SQL-Code:
SELECT *
FROM ...
WHERE CAST(Gesamtpreis / Menge * 100 AS INTEGER) / 100.0 <> Einzelpreis
  Mit Zitat antworten Zitat
jobo

Registriert seit: 29. Nov 2010
3.072 Beiträge
 
Delphi 2010 Enterprise
 
#3

AW: BDE - SQL - Select - Rundungsproblem

  Alt 31. Mai 2011, 18:32
Wenn der Vorschlag von Omata nicht funktioniert, kannst Du noch cast versuchen oder mit istwert < sollwert + delta arbeiten.

BDE SQL heißt local sql und hier gibts Infos dazu:
(sorry, hab die Links vergessen)
http://www.thedbcommunity.com/index.php
http://www.thedbcommunity.com/index....=106&Itemid=46

Auf alten Delphi Installationen fiindest Du vielleicht auch was zum Thema Funktionen (LocalSQL.HLP)

Hier eine Schnippsel aus DER Paradox community:
Zitat:
Functions: Simple Functions

Simple Functions (scalar functions) are generally included in most SQL dialects as an extension to the SQL Standard. They operate on column values in a single row and produce a single value which is included in the result set. Local SQL has several such functions, including:

CAST Convert values from one data type to another. For example, convert a number to a character.
EXTRACT Extract the year, month, or day from a date as an integer.
SUBSTRING Extract a portion of a character column.
UPPER Convert a character column value to all uppercase letters.
LOWER Convert a character column value to all lowercase letters.
TRIM Removes any leading spaces, trailing spaces, or both from a character column value.

Note that these functions are not available with QBE.

Suppose we need to generate a list of all company names, but instead of mixed caps, we need them in all upper case. We can generate a result set containing a capitalized list of all company names using the following query:

SELECT Upper(Company) Company
FROM Customer

Our ANSWER table will have a single column containing the Company name for each company, all in uppercase characters. In the above example, we explicitly named the new column ‘COMPANY’.

These functions are described in detail in the LocalSQL.HLP file. They will be explored in detail in a later article.


Summary

The SQL SELECT statement creates a result set (i.e., an ANSWER table) consisting of specific rows and columns of a table. The result set can consist of simple columns derived from the queried table, calculated expressions or the result of a SQL function. There are two types of SQL functions, aggregate functions, which operate across multiple rows, and simple functions, which operate on single rows. Result set columns may have different names assigned to them during the SQL query using the AS operator in the query.
Gruß, Jo

Geändert von jobo (31. Mai 2011 um 19:18 Uhr) Grund: älterer Herr
  Mit Zitat antworten Zitat
FredlFesl

Registriert seit: 19. Apr 2011
293 Beiträge
 
Delphi 2009 Enterprise
 
#4

AW: BDE - SQL - Select - Rundungsproblem

  Alt 1. Jun 2011, 06:24
SQL-Code:
select * from p
where (p.Gesamtpreis/p.Menge) between p.Einzelpreis-0.005 and p.Einzelpreis+0.005;

select * from p
where ((p.Gesamtpreis/p.Menge) > p.Einzelpreis-0.005)
and ((p.Gesamtpreis/p.Menge) < p.Einzelpreis+0.005);
Das Bild hängt schief.

Geändert von FredlFesl ( 1. Jun 2011 um 06:25 Uhr) Grund: Tags ersetzt
  Mit Zitat antworten Zitat
Benutzerbild von stahli
stahli

Registriert seit: 26. Nov 2003
Ort: Halle/Saale
4.336 Beiträge
 
Delphi 11 Alexandria
 
#5

AW: BDE - SQL - Select - Rundungsproblem

  Alt 1. Jun 2011, 10:06
Ok vielen Dank!

Der Hinweis auf LocalSQL.hlp ist sehr nützlich (D7 kennt das selbst scheinbar nicht) und mein Problem war mit BETWEEN lösbar.
Stahli
http://www.StahliSoft.de
---
"Jetzt muss ich seh´n, dass ich kein Denkfehler mach...!?" Dittsche (2004)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:02 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