PLSQL

 [DECLARE 
    Declarations 声明部分]
    BEGIN
    Plsql语句;
    [EXCEPTION 
    handlers]
END;

--输出语句  ||拼接
dbms_output.put_line(内容);
-- 
DECLARE
a date;
v_s int;
abc varchar2(10);
v_g varchar2(100);
BEGIN
  a:=sysdate;
  dbms_output.put_line(a);
  v_s:=&请你个老狗比输入点整数;
  v_g:='&你可以来点汉字';
  

dbms_output.put_line(v_s);
dbms_output.put_line ('abc');
dbms_output.put_line(v_g);
--exception
end;
------------
declare
a varchar(50);
begin
  a:='&输入他是什么颜色';
  if a = 'red' or a = 'green'
    then dbms_output.put_line('红色');
    end if;
     /* if a = 'green'
        then dbms_output.put_line('绿色');
        end if;*/
          if a !='red' and a != 'green'
            then dbms_output.put_line('其他颜色');
            end if ;
--exception
end;

declare
v_color varchar(20);
begin
  v_color :='&给个颜色';
case when v_color ='black'
  then dbms_output.put_line('黑色');
  when
   v_color='red'
    then dbms_output.put_line('红色');
    when v_color !='black' and v_color !='red'
      then dbms_output.put_line('别的颜色');
    
end CASE;
end;

------------------

 1>记录类型的定义:
  type xs is record(
      sno number(5),
      ssex varchar(20),
      cno number(5)
  );
  type_name:记录类型名称
  type emp_type is record(
      ename varchar2(10),
      job emp.job%type,
      sal emp.sal%type
  );
------------------
declare
a int :=50;
b int :=1;
begin
  while b<=1000 loop
    a:=a+b; 
    b:=b+1; 
     end loop; 
    dbms_output.put_line(a);
end;

--循环打印1 到9
begin
  --for循环语句 
  for i in 1..9 loop
    --循环体语句
    dbms_output.put_line(' '||i);
  end loop;
end;
select sal from emp

begin
  for a in (select * from emp  where sal=&sal)loop
dbms_output.put_line(a.empno);
end loop;
end;

begin 
  for c in (select * from sc where sno='&sno') loop
    -----除了数字全部都要加两个单引号
  dbms_output.put_line(','||c.score);
  end loop;
end;

select * from sc1
select * from sc

 declare
i number:=1;
begin 
<<a>>
dbms_output.put_line(i);
i:=i+1;
if i<10 then
  goto a;
  end if;

end;
去掉_line不是不输出了,而是输出到内存,在下一次输出时一起出来

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值