请问为何使用function 返回的结果作为查询条件查不出结果?

yoshubom 2007-12-06 09:26:17
创建了一个function,代码如下:

create function find_idno(sn char) return number is
idno number(14);
begin
select id_no into idno from dcustmsg@bossdb where phone_no = sn;
return idno;
end;

我想用function 的返回结果作为查询的条件,但不知为何出不来结果?不是没有结果,而是执行了半天sql 也没有执行完.

select * from dsrvmsg@bossdb where id_no = find_idno('13994469795');
...全文
99 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yoshubom 2007-12-07
  • 打赏
  • 举报
回复
我发现人家也是用一个方法来获得id 号并作为查询条件,但不知道是方法还是存储过程。
淡定的峰哥 2007-12-06
  • 打赏
  • 举报
回复
可以直接用两个表的连接查询
select a.* from dsrvmsg@bossdb a, dcustmsg@bossdb b where a.id_no=b.id_no and b.phone_no='13994469795''
zhpsam109 2007-12-06
  • 打赏
  • 举报
回复
看看执行计划!
id_no上是否有索引,使用函数会禁用索引!

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧