declare t_sal tmp_emp.sal%type; t_i number(4); t_di tmp_emp.di%type; begin t_di:=&x; select sal into t_sal from tmp_emp where di=t_di; case when t_sal<1200 then t_i:=200; when t_sal<2000 then t_i:=150; when t_sal<4000 then t_i:=100; else t_i:=50; end case; update tmp_emp set sal=sal+t_i where di=t_i; end;是这段代码里的,可不管x输入什么值,这段代码运行后,查询表tmp_emp 的时候,里面的内容没有发生变化。
update tmp_emp set sal=sal+t_i where di=t_i; 说明没有找到匹配的行,没有修改过,所以没变化
t_sal tmp_emp.sal%type;
t_i number(4);
t_di tmp_emp.di%type;
begin
t_di:=&x;
select sal into t_sal from tmp_emp where di=t_di;
case
when t_sal<1200 then t_i:=200;
when t_sal<2000 then t_i:=150;
when t_sal<4000 then t_i:=100;
else t_i:=50;
end case;
update tmp_emp set sal=sal+t_i where di=t_i;
end;是这段代码里的,可不管x输入什么值,这段代码运行后,查询表tmp_emp 的时候,里面的内容没有发生变化。
update tmp_emp set sal=sal+t_i where di=t_i; 说明没有找到匹配的行,没有修改过,所以没变化