1.字符串小代码转化为字符串值
如 (10,20)==》 (现金(电汇),银行承兑汇票,现金(电汇))
java
CREATE OR REPLACE FUNCTION FROM_ARRAYSTR_TO_STR(P1 in varchar2,P2 in varchar2)
return varchar2
is
VLA varchar2(2048):='';--最后函数返回的值
TEMP varchar2(20); --截取字符串第一个的值'a,b,c'-->'a'
TEMP_AGE varchar2(20):=P1; --截取字符串第一个的值'a,b,c'-->'a'
TEMP_CHANGE varchar2(20); --小代码转化结果
begin
IF P1='' OR P1 IS NULL THEN
VLA:='';
ELSE
IF INSTR(P1,',')>0 THEN
LOOP
IF INSTR(TEMP_AGE,',')>0 THEN
SELECT SUBSTR(TEMP_AGE, 1, INSTR(TEMP_AGE, ',')-1) INTO TEMP FROM dual;
SELECT SUBSTR(TEMP_AGE, INSTR(TEMP_AGE, ',')+1) into TEMP_AGE FROM dual;
SELECT VAL_DESC_CN INTO TEMP_CHANGE FROM XS_MD_VALSET_DETAIL dt4 WHERE dt4.VAL=TEMP AND dt4.value_Set_Code=P2;
IF VLA='' or VLA IS NULL THEN
VLA:=TEMP_CHANGE;
ELSE
VLA:=VLA||','||TEMP_CHANGE;
END IF;
ELSE
SELECT VAL_DESC_CN INTO TEMP_CHANGE FROM XS_MD_VALSET_DETAIL dt4 WHERE dt4.VAL=TEMP_AGE AND dt4.value_Set_Code=P2;
VLA:=VLA||','||TEMP_CHANGE;
exit when 1=1;
END IF;
END LOOP;
ELSE
SELECT VAL_DESC_CN INTO VLA FROM XS_MD_VALSET_DETAIL dt4 WHERE dt4.VAL=P1 AND dt4.value_Set_Code=P2;
END IF;
END IF;
return VLA;
end;
数据执行方法
java
SELECT FROM_ARRAYSTR_TO_STR('10,20,10','H010') FROM DUAL;