0
我试图与他人代替一个字符创建一个新的功能:功能替换字符
CREATE OR REPLACE FUNCTION TEST (sifra in varchar2)
RETURN VARCHAR2 AS
sifra1 varchar2(16);
BEGIN
select case when instr(sifra,'A') >0 then replace(sifra, 'A', '0')
when instr(sifra,'B') >0 then replace(sifra, 'B', '1')
when instr(sifra,'C') >0 then replace(sifra, 'C', '2')
when instr(sifra,'D') >0 then replace(sifra, 'D', '3')
when instr(sifra,'E') >0 then replace(sifra, 'E', '4')
when instr(sifra,'F') >0 then replace(sifra, 'F', '5')
when instr(sifra,'G') >0 then replace(sifra, 'G', '6')
when instr(sifra,'H') >0 then replace(sifra, 'H', '7')
when instr(sifra,'I') >0 then replace(sifra, 'I', '8')
when instr(sifra,'J') >0 then replace(sifra, 'J', '9')
end
into sifra1 from dual;
return sifra1;
END TEST;
但是当我尝试使用该功能在查询我得到的所有null
值作为输出。
select test(sifra) from iis.artikli
这里有什么问题?
你需要为你只检查大写字符传递大写。做'从iis.artikli'选择测试('SIFRA')。还要注意传递varchar的单引号。 – Ofisora
@Ofisora我不知道它是否正确,在有结果的情况下进行修改 – Savke
如果解决了这个问题,那就很好。我假定sifra是你作为参数传递的词。 – Ofisora