create or replace function MMfGetPropValChar(propvalue varbinary(518))
RETURNS varchar(255)
as
$$
select
(CASE
WHEN substr(${PROPVALUE}, 1, 3) = '0x00E700' Then CAST(substr(${PROPVALUE}, 9, 510) As Varchar(255))
WHEN substr(${PROPVALUE}, 1, 3) = '0x01E700') Then CAST(substr(${PROPVALUE}, 9, CAST(substr(${PROPVALUE}, 6, 1) as integer)) As Varchar(64))
)
ELSE (select current_timestamp)
End as test
return test;
$$
Below is the error I am getting:
Compilation of SQL UDF failed: SQL compilation error: syntax error line 2 at position 0 unexpected 'select'. syntax error line 3 at position 1 unexpected 'CASE'. syntax error line 4 at position 45 unexpected 'Then'.