本文介绍了使用PLSQL时,此SELECT语句中应有一个INTO子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到以下错误.在SELECT CASE
语句中获取错误.
I am getting the following error. Getting the error at SELECT CASE
statement.
FOR REMS IN cur_names LOOP
SELECT CASE
WHEN EXISTS (SELECT 1
FROM SupplyTable
WHERE FirstName = REMS.Names)
THEN 'Y'
ELSE 'N'
END AS rec_exists
FROM dual;
IF rec_exists = 'Y' THEN
FName := REMS.Names;
ELSE
FName := 'Gen';
END IF;
END LOOP;
推荐答案
您不能在pl sql代码中进行随机选择.它必须在带有into子句的循环中,游标中.只需在此处包括一个into子句即可.
you can´t have a random select inside your pl sql code. It must be in a loop, cursor, with an into clause. Just include an into clause here.
declare
v_value varchar2(1);
begin
...
FOR REMS IN cur_names LOOP
SELECT CASE
WHEN EXISTS (SELECT 1
FROM SupplyTable
WHERE FirstName = REMS.Names)
THEN 'Y'
ELSE 'N'
END AS rec_exists
INTO v_value
FROM dual;
IF v_value = 'Y' THEN
FName := REMS.Names;
ELSE
FName := 'Gen';
END IF;
END LOOP;
...
或循环
FOR REMS IN cur_names LOOP
for i in
(
SELECT CASE
WHEN EXISTS (SELECT 1
FROM SupplyTable
WHERE FirstName = REMS.Names)
THEN 'Y'
ELSE 'N'
END AS rec_exists
FROM dual
)
loop
IF i.rec_exists = 'Y' THEN
FName := REMS.Names;
ELSE
FName := 'Gen';
END IF;
end loop;
END LOOP;
这篇关于使用PLSQL时,此SELECT语句中应有一个INTO子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!