oracle 包、方法、存储过程
    --定义包create or replace package pkg_test 
  as   
     type myrctype is ref cursor;
     procedure get(p_id number);
  end pkg_test;
/
--定义包体create or replace package body pkg_test
  as
     procedure get(p_id number)
     is
        sqlstr varchar2(500);
     begin
        if p_id = 1 then
           dbms_output.put_line(p_id);
        else
           dbms_output.put_line('not 1');
        end if;
     end get;
  end pkg_test;
/ 
--调用包中的存储过程call pkg_test.get(3);
--创建方法create or replace function get_product_name return varchar2 is   
   product_name varchar2(50);    
      begin   
         select product_name into product_name from ent_product_info where product_code = '1000000012';
      return product_name;    
end get_product_name;
/
--调用方法
--方法一:select get_product_name from dual;
--方法二:打开command window执行如下语句var v_name varchar2(50)    
exec :v_name:=get_product_name;  
--方法三exec dbms_output.put_line('1000000012的产品名称为:'||get_product_name);
--创建方法create or replace function put_product_name(product_id in varchar2) return varchar2 is   
   product_name varchar2(50);    
      begin   
         select product_name into product_name from ent_product_info where product_code = product_id;
      return product_name;    
end put_product_name;
/
--方法一select put_product_name('1000000012') from dual;
--方法二:打开command window执行如下语句var v_name varchar2(50)    
exec :v_name:=put_product_name('1000000012');
--方法三exec dbms_output.put_line('1000000012的产品名称为:'||put_product_name('1000000012'));
我的异常网推荐解决方案:oracle存储过程,http://www.aiyiweb.com/oracle-develop/177537.html