SAP HANA не приходит с ISNUMERIC()
функции. Однако этот вопрос был задан и несколько раз ответил на SCN: E.g. http://scn.sap.com/thread/3449615
или мой подход от спины в дни: http://scn.sap.com/thread/3638673
drop function isnumeric;
create function isNumeric(IN checkString NVARCHAR(64))
returns isNumeric integer
language SQLSCRIPT as
begin
declare tmp_string nvarchar(64) := :checkString;
declare empty_string nvarchar(1) :='';
/* replace all numbers with the empty string */
tmp_string := replace (:tmp_string, '1', :empty_string);
tmp_string := replace (:tmp_string, '2', :empty_string);
tmp_string := replace (:tmp_string, '3', :empty_string);
tmp_string := replace (:tmp_string, '4', :empty_string);
tmp_string := replace (:tmp_string, '5', :empty_string);
tmp_string := replace (:tmp_string, '6', :empty_string);
tmp_string := replace (:tmp_string, '7', :empty_string);
tmp_string := replace (:tmp_string, '8', :empty_string);
tmp_string := replace (:tmp_string, '9', :empty_string);
tmp_string := replace (:tmp_string, '0', :empty_string);
/*if the remaining string is not empty, it must contain non-number characters */
if length(:tmp_string)>0 then
isNumeric := 0;
else
isNumeric := 1;
end if;
end;
Тестирование это показывает: с данными, как (выберите «1blablupp» как VAL от фиктивной союза всех выберите «1234», как VAL от фиктивная объединение всех выберите «bla123», как вал с соской)
select val, isNumeric(val) from data
VAL ISNUMERIC(VAL)
1blablupp 0
1234 1
bla123 0
Это не является полным: насчет -100, 1.000.000 и т.д. –