oracle 存储过程 存储函数
一: 定义:指存储在数据库中供所有用户程序调用的子程序,叫存储过程、存储函数。 相同点:完成特定功能的程序 不同点:是否用return语句返回值,存储过程无return返回值,存储函数有return返回值。 二:创建和调用存储过程 创建:create or replace procedure 命令 语法:create or replace procedure 过程名(参数列表) as PLSQL子程序体 调用:两种方式 1.exec 过程名(参数列表); 2.begin 过程名(参数列表); 过程名(参数列表); end; / 例子:1 无参存储过程,打印hellow world create or replace procedure sayhellowworld as begain dbms_output.put_line("hellowworld"); end; / commit; 调用: 1.exec sayhellowworld(); 2.begin sayhellowworld(); sayhellowworld(); end; / 2 有参in存储过程:给某个员工加100工资,应打印出涨前涨后薪水。 create or replace procedure raisesalary(eno in number) as --定义一个变量psal保存涨前薪水