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;
/*/

转载于:https://www.cnblogs.com/ln-qiqi/p/10675378.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值