Home  >  Article  >  Database  >  Oracle连接字符串报错误ORA-01722:无效数字的解决方法

Oracle连接字符串报错误ORA-01722:无效数字的解决方法

WBOY
WBOYOriginal
2016-06-07 17:06:103110browse

Oracle连接字符串报错误ORA-01722:无效数字的解决方法,如下函数,用来查出名字相似于某字符串

Oracle连接字符串报错误ORA-01722:无效数字的解决方法,如下函数,用来查出名字相似于某字符串create or replace function f_GetUsers(key in varchar2,

p_cursor out pkg_test.myrctype)

return number is

Result number;

begin

open p_cursor for

SELECT * FROM Accounts_Users where TrueName like '%'+key+'%' order by UserID;

Result := 0;

return(Result);

end;

编译成功,,测试的时候也没有发现错误,但是到了真正的生产环境的时候,

报错误 ORA-01722: 无效数字 很莫名

后来查阅网络

发现ORACLE 的字符串连接必须用||符号的,然后修改测试 如下

create or replace function f_GetUsers(varkey in varchar2,

p_cursor out pkg_test.myrctype)

return number is

Result number;

begin

open p_cursor for

SELECT * FROM Accounts_Users where TrueName like '%'||varkey||'%' order by UserID;

Result := 0;

return(Result);

end;编译通过

测试数据,也没有问题。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn