我有一些代码无法运行,因为它需要在select语句中使用INTO子句:
<color name="top_blue">#B3284575</color>
但是我不确定如何添加它以及它如何与此脚本一起使用。
我可以帮忙吗?
答案 0 :(得分:2)
错误消息足够清楚:在PL / SQL中,如果不将结果提取到某个变量中,则无法进行SELECT
查询。
例如:
SQL> begin
2 select 1, 2 from dual;
3 end;
4 /
select 1, 2 from dual;
*
ERROR at line 2:
ORA-06550: riga 2, colonna 5:
PLS-00428: an INTO clause is expected in this SELECT statement
SQL> declare
2 v1 number;
3 v2 number;
4 begin
5 select 1, 2
6 into v1, v2
7 from dual;
8 end;
9 /
PL/SQL procedure successfully completed.
SQL>
因此,您需要定义变量来处理查询的结果。
请注意,在示例中我使用了两个标量变量,但如果您的查询可以返回多行,则需要使用一些集合来获取数据;例如:
declare
type tyListNum is table of number;
vList1 tyListNum;
vList2 tyListNum;
begin
select 1, 2
bulk collect into vList1, vList2
from dual
connect by level <= 2;
--
-- whatever you need to do with the fetched values
end;