Supportnet / Forum / Datenbanken
Oracle IsNull
Frage
Hallo zusammen.
ich habe bei einer Abfrage ein Problem. Und zwar gekomme ich bei einem Feld der Wert NULL zurück, möchte aber, wenn er NULL zurück gekommt, dass er einen angegebenen Standardwert nimmt. Wie es z.B. unter Pervasiv funktioniert (IsNull(Feldname, Standardwert)). Hat da einer von euch ne Lösung?
Mfg Max
Antwort 1 von draack
Hi,
NVL(e1, e2) : Wenn e1 NULL dann e2 sonst e1
Tschö,
Volker
NVL(e1, e2) : Wenn e1 NULL dann e2 sonst e1
Tschö,
Volker
Antwort 2 von Max83
Danke in der Abfrge Funktioniert es, solange der Funktion nicht in der where-Klausel benutz wird. da bringt er mir auch nichts entsprechendendes zurück.
Hier mal die Abfrage:
Bei ´01-Jan-2006´ habe ich auch schon ´01.01.06´ und ´01-01-06´ versucht....
Hier mal die Abfrage:
select distinct "BV"."BVID", "BV"."AZ" from "BV" where
("BV"."fristdatea" is not Null and "BV"."fristerldatea" is not null) and
("BV"."fristdateb" is not Null and "BV"."fristerldateb" is not null) and
("BV"."fristdatec" is not Null and "BV"."fristerldatec" is not null) and
("BV"."fristdated" is not Null and "BV"."fristerldated" is not null) and
("BV"."fristdatee" is not Null and "BV"."fristerldatee" is not null) and
("BV"."fristdatef" is not Null and "BV"."fristerldatef" is not null) and
(SYSDATE - "BV"."dateingangsb") - (("BV"."fristerldatea" - "BV"."fristdatea") +
("BV"."fristerldateb" - "BV"."fristdateb") + ("BV"."fristerldatec" - "BV"."fristdatec") +
("BV"."fristerldated" - "BV"."fristdated") + ("BV"."fristerldatee" - "BV"."fristdatee") +
(NVL("BV"."fristerldatef", ´01-Jan-2006´) - NVL("BV"."fristdatef", ´01-Jan-2006´))) > 45Bei ´01-Jan-2006´ habe ich auch schon ´01.01.06´ und ´01-01-06´ versucht....
Antwort 3 von draack
Hi,
wieso die ganzen "? Hast du die Abfrage vielleicht mit MS Access zusammengestoppelt? Die Klammern sind größtenteils auch überflüssig (und wohl auch falsch gesetzt) - und to_date() verwenden:
Ohne Gewähr - ungetestet.
Tschö,
Volker
wieso die ganzen "? Hast du die Abfrage vielleicht mit MS Access zusammengestoppelt? Die Klammern sind größtenteils auch überflüssig (und wohl auch falsch gesetzt) - und to_date() verwenden:
SELECT DISTINCT bv.bvid, bv.az
FROM bv
WHERE bv.fristdatea IS NOT NULL
AND bv.fristerldatea IS NOT NULL
AND bv.fristdateb IS NOT NULL
AND bv.fristerldateb IS NOT NULL
AND bv.fristdatec IS NOT NULL
AND bv.fristerldatec IS NOT NULL
AND bv.fristdated IS NOT NULL
AND bv.fristerldated IS NOT NULL
AND bv.fristdatee IS NOT NULL
AND bv.fristerldatee IS NOT NULL
AND bv.fristdatef IS NOT NULL
AND bv.fristerldatef IS NOT NULL
AND (
(SYSDATE - bv.dateingangsb) - (
(bv.fristerldatea - bv.fristdatea)
+ (bv.fristerldateb - bv.fristdateb)
+ (bv.fristerldatec - bv.fristdatec)
+ (bv.fristerldated - bv.fristdated)
+ (bv.fristerldatee - bv.fristdatee)
+ (nvl(bv.fristerldatef,to_date(´01.01.2006´,´dd.mm.yyyy´)) - nvl(bv.fristdatef,to_date(´01.01.2006´,´dd.mm.yyyy´)))
)
) > 45;
Ohne Gewähr - ungetestet.
Tschö,
Volker

