我的代码出现了问题,它向我抛出了这个错误,我不确定为什么,因为它没有任何意义如果你们中的任何人可以帮助我,你将成为我的救星。
我还没有真正尝试过任何东西,因为我什至不知道至少从哪里开始并尝试解决这个问题,我在我的代码或任何东西中都找不到任何不一致之处,我不确定为什么它指出没有声明部分中的数据实际上存在。
声明 * 第 1 行错误: ORA-01403: 未找到数据 ORA-06512: 在第 7 行
` 设置服务器输出打开
DECLARE
v_newgoal donor.yrgoal%TYPE;
v_idno donor.idno%TYPE;
v_name donor.name%TYPE;
v_yrgoal donor.yrgoal%TYPE;
BEGIN
SELECT idno, name, yrgoal
INTO v_idno, v_name, v_yrgoal
FROM donor
WHERE v_idno = 11111;
IF v_yrgoal > 500 THEN
v_newgoal := v_yrgoal * 2;
ELSIF v_yrgoal < 500 THEN
v_newgoal := v_yrgoal + 250;
ELSE
dbms_output.put_line('Error: Not Proceeding.');
END IF;
UPDATE donor
SET yrgoal = v_newgoal
WHERE idno = 11111;
dbms_output.put_line(v_idno||' '||v_name||' '||v_yrgoal);
END;
/
SET SERVEROUTPUT OFF
`
DECLARE
v_newgoal donor.yrgoal%TYPE; -- is Null
v_idno donor.idno%TYPE; -- is Null
v_name donor.name%TYPE; -- is Null
v_yrgoal donor.yrgoal%TYPE; -- is Null
BEGIN
SELECT idno, name, yrgoal -- >> NO_DATA_FOUND exception raised here
INTO v_idno, v_name, v_yrgoal -- Select ... INTO ... must return something
FROM donor -- (when there is no row returned) >>> NO_DATA_FOUND >>> could be handled in the EXCEPTION section below
--WHERE v_idno = 11111; -- this means "WHERE Null = 11111" - change the line to "WHERE idno = 11111"
WHERE IDNO = 11111;
IF v_yrgoal > 500 THEN
v_newgoal := v_yrgoal * 2;
ELSIF v_yrgoal < 500 THEN
v_newgoal := v_yrgoal + 250;
ELSE -- if v_yrgoal is equal to 500 then v_newgoal will stay Null - don't think you want that
dbms_output.put_line('Error: Not Proceeding.'); -- just message with no stopping --> UPDATE will be executed
END IF;
UPDATE donor
SET yrgoal = v_newgoal -- possible Null value
WHERE idno = 11111;
dbms_output.put_line(v_idno||' '||v_name||' '||v_yrgoal);
EXCEPTION -- EXCEPTION section - a place to handle different kinds of errors
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('some info about the ERR');
WHEN OTHERS THEN
... do something else ...
END;
是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是数据是 数据是