这是我正在编写的PL / SQL程序,用于将字符串转换为ascii值,但是出现以下错误:
ORA-06550: line 12, column 5:
PLS-00113: END identifier 'FUNCTION' must match 'ENCODE12' at line 3, column 10
ORA-06550: line 12, column 13:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: begin function package pragma procedure form
我是新的PL / SQL编程。预先感谢。
declare
buff number(3):=0;
function Encode12(string varchar2)
return varchar2 is
encodedString varchar2(50):='';
Begin
for i in 1 .. length(string) loop
buff:=ascii(substr(string,i,1));
concat(encodedString,buff);
end loop;
return encodedString;
end function;
答案 0 :(得分:1)
尝试:
create or replace function Encode12(string varchar2 )
return varchar2 is
encodedString varchar2(50):='';
buff number(3):=0;
Begin
for i in 1 .. length(string) loop
buff:=ascii(substr(string,i,1));
-- concat(encodedString,buff);
encodedString := encodedString || buff;
end loop;
return encodedString;
end;
/
Oracle中没有concat
过程,必须使用赋值和连接运算符:
encodedString := encodedString || buff;
请看一下这个演示:http://sqlfiddle.com/#!4/21309/1