2017-07-18(流程控制语句)

DECLARE
Enam varchar2(20) :=’KING’;
BEGIN
DELETE FROM emp WHERE Enam=ename;
END;


select * from emp;
declare
V_empno emp.empno%type :=7499;
rec emp%rowtype;
begin
select * into rec from emp where empno=V_empno;
dbms_output.put_line('姓名:'||rec.ename||'工资'||rec.sal||'工作时间'||rec.hiredate);
end;

 


select * from dept;
declare
V_deptno number;
V_dname varchar2(100);
begin
insert into dept
values(50,'dsfg','fh')
returning deptno,dname into V_deptno,V_dname;
dbms_output.put_line(V_deptno);
dbms_output.put_line(V_dname);
end;


declare
V_empno emp.empno%type :=7566;
V_salary emp.sal%type;
V_comment varchar2(100);
begin
select sal into V_salary from emp where empno=V_empno;
if V_salary <1500 then
V_comment:='工资太低';
elsif V_salary <3000 then
V_comment:='一般般';
else
V_comment:='太牛逼';
end if;
dbms_output.put_line(V_comment);
end;

 

declare
V_empno emp.empno%type :=7566;
V_salary emp.sal%type;
V_comment varchar2(100);
begin
select sal into V_salary from emp where empno=V_empno;
V_comment:=
case V_salary
when 2975 then '你的工资太低,没钱来找我'
when 3000 then '咱俩工资差不多,哪天出来喝个酒'
else '你太牛逼了'
end;
dbms_output.put_line('sal:'||V_salary||'comment:'||V_comment);
end;

 

 

declare
int number(5) :=0;
begin
loop
int :=int + 1;
dbms_output.put_line('int的当前值是:'||int);
exit when int=10;
end loop;
end;

posted on 2017-07-18 18:14  Java256  阅读(123)  评论(0)    收藏  举报

导航