数据库 存储过程
一、定义存储过程
- 定义
create [or replace] procedure 过程名 [(参数[IN/OUT/IN OUT] 参数类型 ) {is/as} [说明部分] begin [语句序列] [exception 例外处理] end [过程名];
- 举例:
【例1】:create or replace procedure my_first_proc is greetings varchar2(20); begin greetings:='Hello World'; dbms_output.put_line(greetings); end my_first_proc;
二、执行存储过程
-
直接命令方式
Execute 存储过程名(参数列表);
-
程序(匿名块) 方式
Declare ··· 需要的变量说明等; Begin 存储过程名(参数列表); end
-
举例
【例1】:set serveroutput on execute my_first_proc;
【例2】: