declare
v_sal emp.sal%type;
begin
select sal into v_sal from emp
where empno = 7369;
if(v_sal<1200) then
dbms_output.put_line('low');
elsif(v_sal=1200) then
dbms_output.put_line('middle');
else
dbms_output.put_line('hige');
end if;
end;
注意elsif中没有else的e
declare
v_sal emp.sal%type;
begin
select sal into v_sal from emp
where empno = 7839;
if(v_sal<2500) then
v_sal := v_sal*2;
update emp set sal = v_sal where empno=7839;
commit;
elsif(v_sal=2500) then
dbms_output.put_line(v_sal);
else
v_sal := v_sal/2;
update emp set sal=v_sal where empno=7839;
commit;
end if;
end;
以上是PL_SQL执行select和update语句
v_sal emp.sal%type;
begin
select sal into v_sal from emp
where empno = 7369;
if(v_sal<1200) then
dbms_output.put_line('low');
elsif(v_sal=1200) then
dbms_output.put_line('middle');
else
dbms_output.put_line('hige');
end if;
end;
注意elsif中没有else的e
declare
v_sal emp.sal%type;
begin
select sal into v_sal from emp
where empno = 7839;
if(v_sal<2500) then
v_sal := v_sal*2;
update emp set sal = v_sal where empno=7839;
commit;
elsif(v_sal=2500) then
dbms_output.put_line(v_sal);
else
v_sal := v_sal/2;
update emp set sal=v_sal where empno=7839;
commit;
end if;
end;
以上是PL_SQL执行select和update语句