如题

解决方案 »

  1.   

    是不是在你定义的sql代码中,没有定义列名,或者使用了oracle保留字。
    多看看提问的智慧!
    oracle 版本未知?
    问题描述不清楚?
      

  2.   

    抱歉,我不知道原来这个错误跟那么多东西相关。那我详细说一下我的问题吧,我用的是oracle 10g Ex版本-------包头,其中过程maxsal为的是求出各部门的工资最高的员工工资然后打印--------------
    create or replace package salpkg as
      type deptsal_rec is record(deptno emp.deptno%type, sal emp.sal%type);
      type deptsalset is table of deptsal_rec;
      type dept_maxsalset is table of emp.sal%type index by pls_integer;
      procedure maxsal(deptsal in deptsalset);
    end salpkg;
    /
    -----包体,是过程maxsal的实现,三个for循环,第一个是初始化,第二个找出最高工资,第三个打印----create or replace package body salpkg as
      procedure maxsal(deptsal in deptsalset) is
        deptmaxsal dept_maxsalset;
        cursor dept_cur is select distinct deptno from emp;
      begin 
        for i in deptsal.first..deptsal.last
        loop
          deptmaxsal(i.deptno) :=0;
        end loop;
        for i in deptsal.first..deptsal.last
        loop
          if i.sal > deptmaxsal(i.deptno)then
            deptmaxsal(i.deptno) :=i.sal;
          end if;
        end loop; 
        for i in dept_cur
        loop
          dbms_output.put_line(deptmaxsal(i.deptno));
        end loop;
      end;
    end;
    /
    另:emp表中的deptno是number类型,能不能做关联数组的小标,number类型和pls_integer类型可不可以互相转换???