Compilation errors for PROCEDURE ICD.SP_RPT_OUTMANUALBYSTAFFNOError: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
       
          ( - + mod not null others <an identifier>
          <a double-quoted delimited-identifier> <a bind variable> avg
          count current exists max min prior sql stddev sum variance
          execute forall time timestamp interval date
          <a string literal with character set specification>
          <a number> <a single-quoted SQL string>
Line: 96
Text: ( select sum(num) from t_Tmp_OutManualByStaffNo where stattime=a.stattime and servicename =a.servicename) ,Error: PLS-00103: Encountered the symbol "," when expecting one of the following:
       
          ; return returning and or
Line: 96
Text: ( select sum(num) from t_Tmp_OutManualByStaffNo where stattime=a.stattime and servicename =a.servicename) ,Error: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
       
          ( - + mod not null others <an identifier>
          <a double-quoted delimited-identifier> <a bind variable> avg
          count current exists max min prior sql stddev sum variance
          execute forall time timestamp interval date
          <a string literal with character set specification>
          <a number> <a single-quoted SQL string>
Line: 100
Text: ( select sum(num) from t_Tmp_OutManualByStaffNo where stattime=a.stattime and servicename =a.servicename)Error: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
       
          ( - + mod not null others <an identifier>
          <a double-quoted delimited-identifier> <a bind variable> avg
          count current exists max min prior sql stddev sum variance
          execute forall time timestamp interval date
          <a string literal with character set specification>
          <a number> <a single-quoted SQL string>
Line: 102
Text: a.num*100.0/( select sum(num) from t_Tmp_OutManualByStaffNo where stattime=a.stattime and servicename =a.servicename)Error: PLS-00103: Encountered the symbol ")" when expecting one of the following:
       
          , * & - + / at mod rem <an identifier>
          <a double-quoted delimited-identifier> <an exponent (**)> as
          from ||
Line: 103
Text: ),2),Error: PLS-00103: Encountered the symbol "1" when expecting one of the following:
       
          ( <an identifier> <a double-quoted delimited-identifier>
          table the
Line: 106
Text: 1,Error: PLS-00103: Encountered the symbol "DELETE"
Line: 114
Text: DELETE t_Tmp_OutManualByStaffNo WHERE vdnusername=iVDNUserName and flag=0;Error: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
       
          begin function package pragma procedure form
Line: 181Error: Hint: Value assigned to 'tCityID' never used in 'SP_Rpt_OutManualByStaffNo'
Line: 31
Text: WHERE a.userid=iVDNUserName AND a.usergid=b.name;

解决方案 »

  1.   

    在Select前加一个(
    INSERT INTO t_Tmp_OutManualByStaffNo (
          stattime,
          servicename,
          status,
          totalnum, 
          num, 
          rate,  
          totaltimes,
          avgtimes ,
          flag,
          vdnusername) 
       (SELECT        /*改这里*/
          a.stattime,
          c.servicename,
          b.memo,
          ( select sum(num) from t_Tmp_OutManualByStaffNo where stattime=a.stattime and servicename =a.servicename) ,
          a.num,
          round(decode
          ( 
          ( select sum(num) from t_Tmp_OutManualByStaffNo where stattime=a.stattime and servicename =a.servicename)
          ,0,0,
          a.num*100.0/( select sum(num) from t_Tmp_OutManualByStaffNo where stattime=a.stattime and servicename =a.servicename)
          ),2),
          a.totaltimes,
          a.avgtimes,
          1,
          iVDNUserName
      FROM t_Tmp_OutManualByStaffNo a,t_tmp_status b,T_tmp_OutBoundService c
      WHERE b.status=a.status 
      AND   a.servicename=c.serviceid 
      AND   a.vdnusername=iVDNUserName 
      ORDER BY a.stattime,a.servicename;
    ...
      

  2.   

    楼主的问题好模糊。是不是字段没对上。status --〉b.memo?
      

  3.   

    你把selecty语句提出执行一下。看与insert字段是否一致
      

  4.   

    楼上,我注释掉就没有错误了.我做了下测试,得到了两个结论,大家指教.
    1.在过程中insert into table select ... from tab语句后不能加order by,但过程外肯定可以.
    2.在过程中子查询不能作为列,但可以当成表使用;过程外,子查询可以作为表,列使用.我得出这两个结论,都是基于多次测试的结果.觉得很不爽的是,过程内的语句限制太多.各位
    也可以做些简单的测试,估计平常也没注意到这两点,都动手试试吧,看看大家的结论和我是否相同
      

  5.   

    你的iVDNUserName是一个入口参数吧,把第一个iVDNUserName改成a.vdnusername试一试
      

  6.   

    兄弟们啊,不要老盯着我的代码看啊,按我下面的结论做测试;
    --------------------
    楼上,我注释掉就没有错误了.我做了下测试,得到了两个结论,大家指教.
    1.在过程中insert into table select ... from tab语句后不能加order by,但过程外肯定可以.
    2.在过程中子查询不能作为列,但可以当成表使用;过程外,子查询可以作为表,列使用.我得出这两个结论,都是基于多次测试的结果.觉得很不爽的是,过程内的语句限制太多.各位
    也可以做些简单的测试,估计平常也没注意到这两点,都动手试试吧,看看大家的结论和我是否相同
      

  7.   

    试了一下,确实如楼主所说
    测试版本 oracle 8.1.6
      

  8.   

    你在Select里不用order by试一下
    你以后用在查询表用order by一样的呀
      

  9.   

    没什么好奇怪的。sql与pl/sql的语法解释器是不同的,直到oracle9i2才统一起来(在oracle9i2的new future中有说明)。新的语法总是先被sql解释器支持,pl/sql语法解释器总要落后一些。子查询作为列(selection list)oracle称为 scalar subquery(标量子查询)
    子查询作为表(from list)     oracle称为 inline-viewscalar subquery按照oracle的说法是9i才支持,并且9i第一版的pl/sql不支持。
      

  10.   

    楼上,既然是同一个版本,过程外,过程内都要用到解释器。ORACLE为什么要区别对待?
      

  11.   

    那就要问oracle自己为什么这样搞