Announcement

Collapse
No announcement yet.

datum überprüfen

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

  • datum überprüfen

    Hey Leute!

    Wie schaffe ich es in PL/SQL ein Datumswert auf Richtigkeit zu überprüfen?
    Beispielsweise will ich prüfen ob das Datum 21.11.2008 besteht oder nicht?

    Könnt ihr mir fa helfen?

  • #2
    Könnt ihr mir fa helfen?
    Fa helfen?

    Prüfen kannst Du es, indem Du einfach versuchst ein solches Datum zu erzeugen:
    Code:
    BEGIN
      select to_date('32.02.2009','DD.MM.YYYY') from dual;
    EXCEPTION WHEN OTHERS THEN
      IF SQLCODE=-1847 THEN
      --Aktionen für ein falsches Datum ausführen
      ELSE
        RAISE;
    END;
    Da du BEGIN END Blöcke beliebig schacheln kannst, ist das praktisch eine try-catch Anweisung wie in java o.ä.

    Dim
    Zitat Tom Kyte:
    I have a simple philosophy when it comes to the Oracle Database: you can treat it as a black box and just stick data into it, or you can understand how it works and exploit it as a powerful computing environment.

    Comment


    • #3
      da helfen

      Also prüft der Fehler 1847 automatisch ab ob es ein richtiges datum ist oder nicht?

      ICh kann mir das nicht so richtig vorstellen...

      Comment


      • #4
        Also prüft der Fehler 1847 automatisch ab ob es ein richtiges datum ist oder nicht?
        Wenn du versuchst ein ungültiges Datum zu erzeugen, bekommst Du einen ORA-01847. Den fängst Du ab und reagierst entsprechend darauf. Bekommst Du keinen Fehler ist es ein gültiges Datum.

        Du kannst mal nur das SQL so in Toad o.ä. ausführen, dann siehst die Fehlermeldung.

        Dim
        Zitat Tom Kyte:
        I have a simple philosophy when it comes to the Oracle Database: you can treat it as a black box and just stick data into it, or you can understand how it works and exploit it as a powerful computing environment.

        Comment

        Working...
        X