Date Validation?

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Date Validation?
Дата
Msg-id web-85340@davinci.ethosmedia.com
обсуждение исходный текст
Ответы Re: Date Validation?  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список pgsql-sql
Folks,

Pardon me for asking this again, but I received *no* responses last
week.

Question:  Is there any function or method which will allow me, in SQL
or PL/pgSQL, to validate dates without raising an error for invalid
dates?

Expansion:  I have a number of PL/pgSQL functions which must accept
dates as parameters from the PHP4 interface.  There is, however, the
possibility that an invalid date will be passed, such as "2001-02-31"
due to the nature of HTML forms date selector.
    What I would like to do is accept the date as a VARCHAR parameter, and
then validate it and convert it to a date inside the function if it
passes validation.
    However, all validation methods I've tried, such as ISFINTTE and
TO_DATE produce SQL errors if the date is not valid; this causes the
function to error out and the user gets an unfriendly error message
which I have not control over.  This is unacceptable.  Obviously, one
answer is error-handling inside functions, but we won't get that until
7.2 as far as I know.
    I could write a complicated string-parsing function to test the
validity of each part of the date, but that would a) lock the interface
into passing the dates in only one format, and b) be really complicated
for leap years and the millenium.
    I am hoping that someone has already dealt with this issue in a way
that date validation can be trappable.

Thanks for your advice.

-Josh Berkus



______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco

Вложения

В списке pgsql-sql по дате отправления:

Предыдущее
От: "Grigoriy G. Vovk"
Дата:
Сообщение: Re: Referencing a view?
Следующее
От: "Josh Berkus"
Дата:
Сообщение: Re: Referencing a view?