Oracle中的存储过程简单例子

时间:2014-05-03 23:56:27   收藏:0   阅读:470

---创建表
create table TESTTABLE
(
  id1  VARCHAR2(12),
  name VARCHAR2(32)
)
select t.id1,t.name from TESTTABLE t
insert into TESTTABLE (ID1, NAME)
values (‘1‘, ‘zhangsan‘);


insert into TESTTABLE (ID1, NAME)
values (‘2‘, ‘lisi‘);


insert into TESTTABLE (ID1, NAME)
values (‘3‘, ‘wangwu‘);


insert into TESTTABLE (ID1, NAME)
values (‘4‘, ‘xiaoliu‘);


insert into TESTTABLE (ID1, NAME)
values (‘5‘, ‘laowu‘);
---创建存储过程
create or replace procedure test_count
as
v_total number(1);
begin
  select count(*) into v_total from TESTTABLE;
  DBMS_OUTPUT.put_line(‘总人数:‘||v_total);
end;
--准备
--线对scott解锁:alter user scott account unlock; 
--应为存储过程是在scott用户下。还要给scott赋予密码
---alter user scott identified by tiger;
---去命令下执行
EXECUTE test_count;
----在ql/spl中的sql中执行
begin
  -- Call the procedure
  test_count;
end;

bubuko.com,布布扣



Oracle中的存储过程简单例子,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!