一个用ORACLE做的学生管理系统.
只有添加和更新没做对.请大神帮助.异常我想了个就是插入学号和数据库里有的学号一样时,引发异常.  请帮助. 异常还没做.create or replace package body stuManagement
  is
  procedure addstu(
   v_stu student%rowtype)
  as
   s student%rowtype;
  begin
      s.sno:=v_stu.sno;
      s.sname:=v_stu.sname;
      s.sex:=v_stu.sex;
      s.age:=v_stu.age;
      s.dept:=v_stu.dept;
      insert into student values(s.sno,s.sname,s.sex,s.age,s.dept);
      dbms_output.put_line('信息已插入');
  end;
       exec stuManagement.addstu('05880109','金','男',19,'计算机系');
第 1 行出现错误:
ORA-06550: 第 1 行, 第 7 列:
PLS-00306: 调用 'ADDSTU' 时参数个数或类型错误
ORA-06550: 第 1 行, 第 7 列:
PL/SQL: Statement ignored 参数个数或类型都没有错误.. 这个是为什么呢.
只有age是NUMBER类型 其他的都是字符串类型. 

解决方案 »

  1.   

    . 我就是想在in变量是ROWTYPE类型的情况下.. 有什么简单点的办法去实现这个功能
      

  2.   


    --不是给你说了吗?
    DECLARE
    s student11%rowtype;
    BEGIN  
      s.sno:='05880109';
      s.sname:='金';
      s.sex:='男';
      s.age:=19;
      s.dept:='计算机系';
      stuManagement.addstu(s);
    END;
      

  3.   


    --上面定义S的时候错了,嘿。。咋那多11呢
    --这样用块去包装下,传个rowtype参数进去:DECLARE
    s student%rowtype;
    BEGIN  
      s.sno:='05880109';
      s.sname:='金';
      s.sex:='男';
      s.age:=19;
      s.dept:='计算机系';
      stuManagement.addstu(s);
    END;
      

  4.   


      1  create or replace package stuManagement
      2  as
      3  procedure addstu(stu student%rowtype);
      4* end;
    SQL> /程序包已创建。SQL> edi
    已写入 file afiedt.buf  1  create or replace package body stuManagement
      2  as
      3  procedure addstu(stu student%rowtype)
      4  as
      5  num number;
      6  begin
      7  select count(*) into num from student where sno=stu.sno;
      8  if num=0 then
      9  insert into student values(stu.sno,stu.sname,stu.sex,stu.age,stu.dept);
     10  commit;
     11  else
     12  raise_application_error(-20002,'学号不能重复');
     13  end if;
     14  end;
     15* end;
    SQL> /程序包体已创建。
    SQL> declare
      2  stu student%rowtype;
      3  begin
      4  stu.sno:='060201';
      5  stu.sname:='scott';
      6  stu.sex:='男';
      7  stu.age:=20;
      8  stu.dept:='计算机';
      9  stuManagement.addstu(stu);
     10  end;
     11  /PL/SQL 过程已成功完成。