Autor Beitrag
OlliWausD
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 212

Win 2000/XP
Delphi 5 Professional - Interbase/Firebird
BeitragVerfasst: Mi 17.11.04 14:05 
hi leutz,

brächte mal kurz eure hilfe.

folgendes:

ich hab einen SQL-Befehl:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
SELECT 
  Artikel.NR,
  ((SELECT FeldA * FeldB FROM Tabelle2
  WHERE .....)
  +
  (SELECT FeldX * FeldY FROM Tabelle3
  WHERE .....))
FROM
  Artikel
WHERE
  .....


Sobald aber in einem der 2 Selectabfragen der Wert <null> rauskommt, ist das Endergebnis aus den beiden Abfragen (F_1) immer <null>

Wieso????? In der Mathematik ist doch auch 3+0 = 3 und 3+{} auch 3

Hab ich vielleicht irgendwas falsch interpretiert oder denk ich wieder zu komplex

OlliW

EDIT: Getestet auf Interbase, Firebird 1.0 und Firebird 1.5

_________________
Take it easy
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mi 17.11.04 14:09 
Das hat mich auch schon häufig in den Wahnsinn getrieben, aber es ist nun mal so.

NULL könnte man als "Wert Unbekannt" betrachten, und wenn du zu einem unkekannten Wert etwas addierst, tja, dann ist die Summe leider auch "unbekannt".

Cu,
Udontknow
OlliWausD Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 212

Win 2000/XP
Delphi 5 Professional - Interbase/Firebird
BeitragVerfasst: Mi 17.11.04 14:13 
hm.... ok,

ich schreibs mal in eine Stored Procedure um.

thanks

mfg

OlliW

_________________
Take it easy
OlliWausD Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 212

Win 2000/XP
Delphi 5 Professional - Interbase/Firebird
BeitragVerfasst: Mi 17.11.04 14:41 
so! hat alles geklappt !

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
CREATE PROCEDURE SP_ABC (
    EINGABE CHAR(16))
RETURNS (
    ARTIKEL_ABC CHAR(16),
    VER1 DOUBLE PRECISION,
    VER2 DOUBLE PRECISION,
    VER3 DOUBLE PRECISION)
AS
begin
for
  select artikel.nr from artikel
  where ..... into:Artikel_ABC
do
begin
  select sum(FeldA*FeldB)
  from Tabelle2
  where
    .....
  into: Var1;

  select
    sum(FeldX*FeldY)
  from
    Tabelle3
  where
    .....
  into :VER2;

  if (VER1 is null) then VER1 = 0;
  if (VER2 is null) then VER2 = 0;
  VER3 = VER1 + VER2;

  suspend;
end
end


mfg

OlliW

_________________
Take it easy