急救:请问该存储过程错在哪里?

zxjcool 2005-12-16 03:03:32
(username varchar2,passwords varchar2,V_RESULT out number) as

usernames varchar2(20):=username;
passwordss varchar2(20):=passwords;

begin

select count(*) into V_RESULT from A
where admin_id=(select userid from B
where passwords=passwordss and username=usernames
);

EXCEPTION
WHEN NO_DATA_FOUND THEN
V_RESULT:=0;
WHEN OTHERS THEN
V_RESULT:=0;

commit;
end bbs_admincheck;


我对照了A和B两张表,存在相同的记录,可是V_RESULT的返回值总是 0 ,为什么得不到真实值呢?
...全文
277 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zxjcool 2005-12-19
  • 打赏
  • 举报
回复
再顶
zxjcool 2005-12-17
  • 打赏
  • 举报
回复
问题没解决,顶一下
zxjcool 2005-12-16
  • 打赏
  • 举报
回复
ab5669(王长林),还是不行啊,返回值总是0

还有,usernames varchar2(20):=username;与 passwordss varchar2(20):=passwords;
怎么会为null呢?

但是我单独:select userid into V_RESULT from B
where passwords=passwordss and username=usernames

V_RESULT 就有正确的返回值啊
ab5669 2005-12-16
  • 打赏
  • 举报
回复
--改为
(v_username varchar2,v_passwords varchar2,V_RESULT out number) as
begin

select count(*) into V_RESULT from A
where admin_id in (select userid from B
where passwords=v_passwords and username=v_username
);
EXCEPTION
WHEN NO_DATA_FOUND THEN
V_RESULT:=0;
WHEN OTHERS THEN
V_RESULT:=0;
end bbs_admincheck;

--以下赋值实际上为NULL
-- usernames varchar2(20):=username;
-- passwordss varchar2(20):=passwords;
zxjcool 2005-12-16
  • 打赏
  • 举报
回复
行号= 13 列号= 3 错误文本= PLS-00372: 在一个过程中,RETURN 语句无法包含表达式
行号= 13 列号= 3 错误文本= PL/SQL: Statement ignored
行号= 17 列号= 3 错误文本= PLS-00372: 在一个过程中,RETURN 语句无法包含表达式
行号= 17 列号= 3 错误文本= PL/SQL: Statement ignored

yufeiyxl(与飞) 加了return不行啊,不加return,返回的值与上面的情况一样,总是 0

yufeiyxl 2005-12-16
  • 打赏
  • 举报
回复
(username varchar2,passwords varchar2,V_RESULT out number) as

usernames varchar2(20):=username;
passwordss varchar2(20):=passwords;

begin

select count(*) into V_RESULT from A
where admin_id in (select userid from B
where passwords=passwordss and username=usernames
);

return v_result;
EXCEPTION
WHEN OTHERS THEN
V_RESULT:=0;
return v_result;
end bbs_admincheck;
nicolas1999king 2005-12-16
  • 打赏
  • 举报
回复
username in varchar2,passwords in varchar2,V_RESULT out number

in 加了吗
zxjcool 2005-12-16
  • 打赏
  • 举报
回复
按楼上的要求做了,Oracle没有的错误信息提示
boydgmx 2005-12-16
  • 打赏
  • 举报
回复
1、不要commit
2、先把EXCEPTION部分注释掉,看看Oracle提示的错误信息

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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