create or replace package vendition_pkg is
type mer_row is record
(
id tb_wyh_user_info.user_id%type,
user_name tb_wyh_user_info.user_name%type,
age tb_wyh_user_info.age%type,
area tb_wyh_user_info.area%type,
salary tb_wyh_user_info.salary%type
)
procedure serchcount(userid in varchar2,user_info out mer_row);
procedure updatedata(userid in varchar2,user_salary in number);
end vendition_pkg;
/create or replace package body vendition_pkg is
procedure serchcount (userid in varchar2,user_info out mer_row)is
  begin
    select a.user_id,a.user_name,a.age,a.area,a.salary into user_info from tb_wyh_user_info a
    where a.user_id=userid
    exception 
      when too_many_rows then
        dbms_output.put_line('用户编号不是唯一的');
        when no_data_found then
          dbms_output.put_line('未找到该用户的商品');
          when others then
            dbms_output.put_line('出现未知错误: '||sqlerrm);
            end serchcount;
 procedure updatedata(userid in varchar2,user_salary in number) is
   exec exception;
   begin
     if user_salary<=0 then
       raise exec;
       end if;
       update tb_wyh_user_info
       set salary=user_salary+1
       where user_id=userid;
       commit;
       exception
         when exec then
           dbms_output.put_line('输入的工资格无效');
           when others then
             dbms_output.put_line('无此用户');
             end updatedata;
             end vendition_pkg;
               出现误??? 不知为什么??请各位帮忙、、、感激不尽。。 
  
                 

解决方案 »

  1.   


    --PACKAGE这里
    salary tb_wyh_user_info.salary%type
    )--少个分号--PACKAGE BODY这里
    where a.user_id=userid --少分号
    --PROCEDURE UPDATEDATA 里面
    EXEC EXCEPTION; --不要用EXEC做变量名称,换一个。
      

  2.   

    那楼主说的很对,exec是关键字,这个关键字是用来执行存储过程的,给你一个例子,你可以参考一下:(存储过程)
    create or replace procedure gife is
    begin
    insert into mytest values('MARRY,'m123');
    Exception
    when others then
    dbms_output.put_line('格式不对,拒绝插入');
    end;
    (包)
    --创建包sp_package
    create package sp_package is
    procedure update_sal(name varchar2,newSal number);
    function sp_fun(name varchar2) return number;
    end;
      
    --实现包sp_package
    create or replace package body sp_package is
    procedure update_sal(name varchar2,newSal number)
    is
    begin
    update emp set sal=newSal where ename=name;
    end;
    function sp_fun(name varchar2) return number
    is yearSal number;
    begin
    select sal*12+nvl(comm,0)*12 into yearSal from emp where ename=name;
    return yearSal;
    end;
    end;