Oracle 自定义函数问题
createorreplacefunctionGetAttentionRate(pIWorkItemIdinvarchar2,pIdnoinvarchar2)return...
create or replace function GetAttentionRate
(
pIWorkItemId in varchar2,
pIdno in varchar2
)
return number
is
pAttentionRate number;
begin
select AttentionRate into pAttentionRate from IworkItemAttentionRates where IWorkItemId = pIWorkItemId and Idno =pIdno;
if pAttentionRate is null
then
return 2;
end if;
return (pAttentionRate);
end;
为什么会一直return null 啊? 不是应该return 2的么。
但是如果直接 pAttentionRate := null 的话又是能正常返回 2的 展开
(
pIWorkItemId in varchar2,
pIdno in varchar2
)
return number
is
pAttentionRate number;
begin
select AttentionRate into pAttentionRate from IworkItemAttentionRates where IWorkItemId = pIWorkItemId and Idno =pIdno;
if pAttentionRate is null
then
return 2;
end if;
return (pAttentionRate);
end;
为什么会一直return null 啊? 不是应该return 2的么。
但是如果直接 pAttentionRate := null 的话又是能正常返回 2的 展开
1个回答
展开全部
create or replace function GetAttentionRate
(
pIWorkItemId in varchar2,
pIdno in varchar2
)
return number
is
cursor cor(pIWorkItemId IworkItemAttentionRates.IWorkItemId%TYPE, pIdno IworkItemAttentionRates.Idno%TYPE) is
select AttentionRate from IworkItemAttentionRates where IWorkItemId = pIWorkItemId and Idno =pIdno;
pAttentionRate IworkItemAttentionRates.AttentionRate%TYPE;
begin
open cor(pIWorkItemId, pIdno);
fetch cor into pAttentionRate;
close cor;
if pAttentionRate is nullthen
return 2;
end if;
return (pAttentionRate);
end;
(
pIWorkItemId in varchar2,
pIdno in varchar2
)
return number
is
cursor cor(pIWorkItemId IworkItemAttentionRates.IWorkItemId%TYPE, pIdno IworkItemAttentionRates.Idno%TYPE) is
select AttentionRate from IworkItemAttentionRates where IWorkItemId = pIWorkItemId and Idno =pIdno;
pAttentionRate IworkItemAttentionRates.AttentionRate%TYPE;
begin
open cor(pIWorkItemId, pIdno);
fetch cor into pAttentionRate;
close cor;
if pAttentionRate is nullthen
return 2;
end if;
return (pAttentionRate);
end;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询