我如何编写这样的函数。我在Clouse的地方连接有问题。
create or replace function is_valid_value(valuetoCheck in varchar2)
return varchar2 is
v_value valid_values.resourceName%type;
begin
begin
SELECT RESOURCENAME into v_value
FROM VALID_VALUES
WHERE VALIDVALUE IN (valuetoCheck)
where upper(resourceName) = upper (valuetoCheck);
exception
when no_data_found then
return 0;
end;
return 1;
end is_valid_value ;
答案 0 :(得分:1)
检查此代码。找到内联的评论:
create or replace function is_valid_value(
valuetoCheck in varchar2
) return varchar2
is
v_value valid_values.resourceName%type;
begin
--begin --> there is no need for two 'begin' in this case
SELECT RESOURCENAME into v_value
FROM VALID_VALUES
WHERE VALIDVALUE IN (valuetoCheck)
AND /* was WHERE, should be change to AND */ upper(resourceName) = upper (valuetoCheck)
AND other_value = another_value
OR this_value = other_value;
return 1; --> this should be returned before exception
exception
when no_data_found then
return 0;
--end; --> there is no need for end since we removed 'begin'
end is_valid_value;