| От | Bricklen Anderson |
|---|---|
| Тема | Re: IsDate function in plpgsql |
| Дата | |
| Msg-id | 4450D7D8.6050200@presinet.com обсуждение исходный текст |
| Ответ на | IsDate function in plpgsql ("Sistemas C.M.P." <sistemascmp@redynet4.com.ar>) |
| Список | pgsql-admin |
Sistemas C.M.P. wrote:
> A few days ago, someone in this list gives me a function (plpgsql) that
> evaluates if a string is a valid date or not.
> It returns 1 or 0 (valid/Not Valid)
> The problem is that if the argument is a NULL field the function returns 1.
> I don't have experience with plpgsql language.
> This is the function
>
> begin
> perform $1::date;
> return 1;
> exception when others then
> return 0;
> end
create or replace function datetest (text) returns integer as $$
begin
if ($1 is null) then
return 0;
end if;
perform $1::date;
return 1;
exception when others then
return 0;
end;
$$ language plpgsql;
В списке pgsql-admin по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера