我建立的一个存储过程,里边有一部分
 for I2 in curArea loop  --执行计算
        INSERT INTO base_userlevel
            (serialnum,sysuserid,svctype,sysareacode,areacode,period,
            netmonth,cenmonth,
            levelvalue,areaflag,billmonth)
    SELECT ROWnum, a.sysuserid, a.svctype, a.sysareacode, a.areacode, a.period,
          a.netmonth, a.cenmonth,
          NVL (b.levelvalue, 0) + a.fee + a.fee * I2.scale as levelvalue1,
          a.areaflag,a.billmonth
     FROM base_userexpbill a, base_userlevel b
        WHERE a.areaflag = '01' AND b.areaflag = '01'
            AND a.billmonth = '01' AND b.billmonth = '01'
            AND a.sysuserid = b.sysuserid(+)
            AND a.netmonth >= 1 AND a.netmonth <=12
            order by levelvalue1;
     
      commit;
    end loop;但是编译的时候总是报这个错误
PLS-00103: Encountered the symbol "ORDER" when expecting one of the following:
. ( * @ % & - + ; / at mod rem return returning
<an exponent (**)> and or group having intersect minus start
union where connect ||
The symbol "group was inserted before "ORDER" to continue.这是因为什么呀?大侠们帮帮我呀!急死了!!

解决方案 »

  1.   

    是的,我如果把order by 去掉 就没有错误了。
      

  2.   

    我做了试验,加order by没有问题。难道跟loop有关?
      

  3.   

    估计是你的curArea游标语句有问题。贴出来看看
    http://www.experts-exchange.com/Databases/Q_20916260.html
      

  4.   

    你用的Oracle是那个版本的.
    8i的在procedure中使用
      insert into table1
       select * from table2 
        order by ; --使用order by会发生错误.
    但在9i中不会.