-1

我正在尝试使用示例书的教程来学习一些 PL-SQL,但是其中一个建议的代码在运行时会返回以下错误:

ORA-06550:第 10 行,第 48 列:PL/SQL:ORA-00947:没有足够的值 ORA-06550:第 9 行,第 1 列:PL/SQL:忽略 SQL 语句

你能帮我理解我做错了什么吗?

提前谢谢了!西蒙娜。

SQL小提琴

Oracle 11g R2 模式设置

create table product (code integer primary key, name varchar2 (20), type varchar2(8),price number(4,2),update_dt date);
insert into product values(1,'Mela','Frutta',1,to_date('1-MAY-2015','DD-MON-YYYY'));
insert into product values(2,'Pera','Frutta',2,to_date('2-MAY-2015','DD-MON-YYYY'));
insert into product values(3,'Carota','Ortaggio',3,to_date('3-MAY-2015','DD-MON-YYYY'));
insert into product values(4,'Zucchina','Ortaggio',4,to_date('4-MAY-2015','DD-MON-YYYY'));
insert into product values(5,'Arancia','Frutta',5,to_date('5-MAY-2015','DD-MON-YYYY'));

查询 1

declare 
code_var integer;
type_var varchar2(8);
name_var varchar2(20);
price_var number(4,2);
update_dt_var date;
price_too_high exception;
begin
select code, type,name, price, update_dt
into code_var,type_var,price_var,update_dt_var
from product
where name='Arancia';
if price_var > 4.5 then
raise price_too_high;
end if;
exception
when price_too_high then
dbms_output.put_line('price is too damn high!');
end;

结果

4

2 回答 2

2

您正在尝试将 5 个值从您的选择中插入到四个变量中。

于 2015-03-27T17:16:12.740 回答
0

这是对的:

select code,     type,     name,     price,     update_dt
into   code_var, type_var, name_var, price_var, update_dt_var
from   product
where  name='Arancia';
于 2015-03-27T17:19:05.263 回答