oracle学习笔记之四(存储过程)

存储过程:

不带参数:

 

create or replace  procedure out_line

is 

begin 

  dbms_output.put_line(systimestamp);

  dbms_output.put_line('helloWorld');

 end;

/

set Serveroutput on ;

exec out_line ;

  

带输入参数:

 

create or replace procedure  demo2(dno number ,dname varchar2 ,loc varchar2)

is 



begin

   insert into dept values(dno ,dname ,loc);

end;

/

exec demo2(70,'gouchao','gouchao');

commit;

select * from dept;

 

 

 

带输出参数1

 

 

create or replace procedure demo3(eno number , name out varchar2 ,salary out number)

is 

begin 

  select ename ,sal into name,salary from emp where empno = eno;

exception

 when no_data_found then 

   dbms_output.put_line('该记录不存在');

end;

/

set serveroutput on ;

var name varchar2(10);

var salary number;

exec demo3(7788,:name ,:salary);

print name salary ;

 

  

带输出参数2

 

 

create or  replace procedure demo4(i number , j number , sum out number)

is 

begin

 

   sum:=  i+j;

end;

/

var result number;

exec demo4(1,2,:result);

print result;

 

 

 

 

删除存储过程:

<!--EndFragment-->

你可能感兴趣的:(oracle学习)