Oracle 存储过程

创建存储过程

create or replace procedure Demo AS
V_TOTAL NUMBER(10);
begin
    select count(*) into V_TOTAL from base_building; 
    DBMS_OUTPUT.put_line('建筑数:'||V_TOTAL);
end demo;

调用存储过程

begin 
    demo;
end;

在PL/SQL的结果集中显示

以上语句都在sql查询窗口,F8执行

声明变量

declare 
  a number(3) := 100;
  b number(4) := 1000;
  c number(5) := 100; 
  d number(4) := 100;
begin
     --在PL/SQL中可以<span style="color:#ff0000;"><strong>在语句块中</strong></span>直接引用,但在Sqlplus(或者commend中)需要call或者execute命令
  dbms_output.put_line('a + b = ' || c);
  dbms_output.put_line('a - b = ' || d);
  dbms_output.put_line('但a的值为:' || a || ', b的值为:' || b);
end;

输出结果

posted @ 2018-05-04 14:10  取什么昵称呢  阅读(190)  评论(0编辑  收藏  举报