存储过程(Procedure)的定义:
A named PL/SQL block that performs one or more actions and is called as an executable PL/SQL statement. You can pass information into and out of a procedure through its parameter list.
存储过程的结构如下:
PROCEDURE name [ ( parameter [, parameter ... ] ) ]
IS
[declaration statements]
BEGIN
executable-statements
[ EXCEPTION
exception handler statements]
END [ name ];
无参存储过程示例:
有参存储过程示例:
无参存储过程的运行:
1、首先打开PL/SQL Developer,连接到一个测试数据库;
2、选择file –>new –> program window –> blank,新建一个编程窗口;
3、把代码黏贴进去或者敲进去;
4、点击工具栏上的齿轮按钮或者用快捷键F8,编译该存储过程;
5、在左侧的对象浏览器窗口中展开 Procudures,找到刚才编译的存储过程,没有的话刷新一下再找找看;
6、选中存储过程,点击右键,选择test;
7、点击工具栏上的齿轮按钮或者用快捷键F8,运行该存储过程;
8、在DBMS Outputs 标签页中可以看到输出:hell world!。
有参存储过程的运行:
在步骤7运行存储过程的时候,可以在Test script窗口下部的表格的第三列中输入测试参数,输入测试参数之后,再点击运行;
其他步骤相同。