oracle存储过程

基本结构

create or replace procedure testinfo
  is
     begin
        insert into info values(210000,'小米','6000',‘中国’);
        commit;
        dbms_output.put_line('插入新记录成功');
end testinfo;

查错

show errors;

查已建成的存储过程

select * from user_source where name='TESTINFO' order by line;    --存储过程名要大写

调用

exec testinfo;

--程序块中调用testinfo --set serverout on begin testinfo end;
/**存储过程参数过程包括:in 输入参数、out 输出参数、in out可被修改的输入参数,并作为输出参数**/

in
create or replace procedure testinfo(v_id in int,v_name in varchar2)
  is
     begin
        insert into info values(v_id,v_name,'6000',‘中国’);
        commit;
        dbms_output.put_line('插入新记录成功');
end;

 

--不按顺序传入参数,指定参数值
begin
  testinfo(v_name=>'小米',v_lid=>'210000');
end;

--按顺序传入参数
begin
  testinfo(210000‘’,'小米‘);
end;

--混合传入参数
begin
 pro_insertDept(210000,v_name=>'小米');
end;

 

out

create or replace procedure testinfo(v_id in int,v_name out info.name%type)
  as
     begin
        select name into v_name from info where id=v_id;
end;

 

declare
testname info.name%type;          
begin
  testinfo('210000',testname)
  dbms_output.put_line(testname);
end;

 

in out

create or replace procedure square(num in out int)
as 
 begin
   num:=powre(num,2)
 end;
declare
  n_num int;
  n_number int;
begin
     n_num:=5;
     n_number:=n_num;
     square(n_number);
     dbms_output.put_line(n_num||'平方是'||n_number);
end;

 

转载于:https://www.cnblogs.com/Soper/p/10340206.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值