从参数的返回情况来看:
<wbr><wbr><wbr><wbr>如果返回多个参数值最好使用存储过程,如果只有一个返回值的话可以使用函数;</wbr></wbr></wbr></wbr>
从调用情况来看:
<wbr><wbr><wbr><wbr>如果在SQL语句(DML或SELECT)中调用的话一定是存储函数或存储的封装函数不可以是存储过程,但调用存储函数的时候还有好多限制以及函数的纯度等级的问题,你可以参考《ORACLE 9I PLSQL程序设计》(机械工业出版社);</wbr></wbr></wbr></wbr>
如果是在过程化语句中调用的话,就要看你要实现什么样的功能。函数一般情况下是
用来计算并返回一个计算结果而存储过程一般是用来完成特定的数据操作(比如修改、插入数据库表或执行某些DDL语句等等),所以虽然他们的语法上很相似但用户在使用他们的时候所需要完成的功能大部分情况下是不同的。
===================================================================================
存储过程和函数:
<wbr><wbr><wbr>例子:</wbr></wbr></wbr>
<wbr><wbr><wbr>//创建过程</wbr></wbr></wbr>
<wbr><wbr><wbr>create or replace procedure add_emailinfo(namee email_info.fullname%type ,address email_info.email_address%type )</wbr></wbr></wbr>
<wbr><wbr><wbr>is</wbr></wbr></wbr>
<wbr><wbr><wbr>begin</wbr></wbr></wbr>
<wbr><wbr><wbr>insert into email_info(fullname,email_address) values (namee,address);</wbr></wbr></wbr>
<wbr><wbr><wbr>end;</wbr></wbr></wbr>
<wbr><wbr><wbr>//调用过程</wbr></wbr></wbr>
<wbr><wbr><wbr>call add_emailinfo('cherry','asdfsdf');</wbr></wbr></wbr>
<wbr><wbr><wbr>/</wbr></wbr></wbr>
<wbr><wbr><wbr>//创建函数</wbr></wbr></wbr>
<wbr><wbr><wbr>create or replace function<wbr>sel_emailinfo(namee email_info.fullname%type )</wbr></wbr></wbr></wbr>
<wbr><wbr><wbr>return varchar2 is</wbr></wbr></wbr>
<wbr><wbr><wbr>address varchar2(30);</wbr></wbr></wbr>
<wbr><wbr><wbr>begin</wbr></wbr></wbr>
<wbr><wbr><wbr>select email_address into address from email_info</wbr></wbr></wbr>
<wbr><wbr><wbr>where trim(fullname)=trim(namee);</wbr></wbr></wbr>
<wbr><wbr><wbr>return address;</wbr></wbr></wbr>
<wbr><wbr><wbr>end ;</wbr></wbr></wbr>
<wbr><wbr><wbr>//调用函数</wbr></wbr></wbr>
<wbr><wbr><wbr>select sel_emailinfo('bbb') from dual;</wbr></wbr></wbr>