create table t1(id int,name varchar(100));
insert into t1 values(1,'abcdefg');
create function substr1 (c varchar(100))
returns varchar(100) WITH (NOT VARIANT);
define v_c varchar(100);
let v_c=substr(c,1,5);
return v_c;
end function;
create index substr_index on t1(substr1(name));