I was looking for is_numeric() and is_date() function in monetdb but couldn't find it. So I have written it ( there will be many ways to do it , I am sharing the way I implemented ) . This will help other users in the group.
create function is_numeric (value varchar(100))
returns int
begin
declare isnumeric int;
set isnumeric = length(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(value,'','0'),',',''),'1',''),'2',''),'3',''),'4',''),'5',''),'6',''),'7',''),'8',''),'9',''),'0','') );
if (isnumeric>0) then
return 0;
else
return 1;
end if;
end;
####################################################################
IS DATE function
####################################################################
create function is_date (value varchar(100))
returns int
begin
declare is_date int;
set is_date = case when SUBSTRING(value,7,4) BETWEEN '1900' AND '2100' then case when SUBSTRING(value,1,2) BETWEEN '01' AND '12' then case when SUBSTRING(value,4,2) BETWEEN '01' AND (CASE WHEN SUBSTRING(value,1,2) in('01','03','05','07','08','10','12') AND SUBSTRING(value,4,6) BETWEEN '01' AND '31' THEN '31' ELSE CASE WHEN SUBSTRING(value,1,2) in ('04','06','09','11') AND SUBSTRING(value,4,6) BETWEEN '01' AND '30' THEN '30'
ELSE CASE WHEN (SUBSTRING (value,1,2) in ('02') ) AND MOD(SUBSTRING(value,7,4),400)=0 OR MOD(SUBSTRING(value,7,4),4)=0 THEN '29' ELSE '28' END END END) then 1 ELSE 0 END else 0 END else 0 END ;
if (is_date=0) then
return 0;
else
return 1;
end if;
end;