Oracle 学习---- 练习语法 循环( loop end loop; for ;while; if elsif end if )

/*--set serveroutput on;
declare
mynum number(3) :=0;
tip varchar2(10):='结果是 ';
begin
mynum:=10+100;
dbms_output.put_line(tip || mynum);
end;
/*/

/*declare
pername temp.name%type;
psal temp.sal%type;
begin
select name,sal into pername,psal from temp where keycode=3;
dbms_output.put_line('3号员工的姓名是:'|| pername || ',工资是:'|| psal);
end;
/*/

/*declare
emp_name temp%rowtype;
begin
select * into emp_name from temp where keycode=2;
dbms_output.put_line('3号员工姓名:' || emp_name.name || ',年龄:' || emp_name.sal);
end;
/*/

/*declare
pday varchar2(20);
begin
select to_char(sysdate,'day')into pday from dual;
dbms_output.put_line('今天是' || pday);

if pday in ('星期六','星期日') then
dbms_output.put_line('休息日');
else dbms_output.put_line('工作日');
end if;

end;
/
*/
/*
declare
age number(3) := &age;
begin
if age < 16 then
dbms_output.put_line('你是未成年人!');
elsif age < 30 then
dbms_output.put_line('你是青年人!');
elsif age < 60 then
dbms_output.put_line('你是奋斗人');
elsif age < 80 then
dbms_output.put_line('你是享受人');
else
dbms_output.put_line('未完再继');
end if;
end;
/*/
/*
declare
i number(2) :=1;
begin
loop
exit when i >10;
dbms_output.put_line(i);
i :=i+1;
end loop;
end;
/
*/
/*
declare
i number(2) :=1;
begin
while i<11
loop
dbms_output.put_line(i);
i:=i+1;
end loop;
end;
/ */

/*declare
i number(2) := 20;
begin
for i in 20 .. 30
loop
dbms_output.put_line(i);
end loop;
end;
/*/

posted @ 2019-04-09 10:29  阿Q啊  阅读(1732)  评论(0编辑  收藏  举报