程序出错的代码:

        ...... EXEC SQL DECLARE goulian CURSOR FOR select a.addrreceiver,a.count,count(b.addrreceiver) from 
(select addrreceiver, count(addrreceiver) as count from t20050601 
where  addrsender='[email protected]' group by addrreceiver) a
left join t20050601 b 
on b.addrsender=a.addrreceiver 
where b.addrreceiver='[email protected]'
group by a.addrreceiver,a.count; EXEC SQL OPEN goulian;
for(cnt=0;cnt<totalnum;cnt++)
        ......如果将中间的sql语句注释掉就编译通过(问题是单独在sql下面完全可以运行的)
否则就会报错,以下是我的操作出错信息[program@Redhat gq]$ proc PARSE=NONE t1.pcPro*C/C++: Release 10.1.0.2.0 - Production on Fri Aug 19 12:05:54 2005Copyright (c) 1982, 2004, Oracle.  All rights reserved.System default option values taken from: /u01/app/oracle/product/10.1.0/db_1export/precomp/admin/pcscfg.cfgCopyright (c) 1982, 2004, Oracle.  All rights reserved.System default option values taken from: /u01/app/oracle/product/10.1.0/db_1export/precomp/admin/pcscfg.cfgSyntax error at line 86, column 2, file t1.pc:
Error at line 86, column 2 in file t1.pc
        left join t20050601 b
.1
PCC-S-02201, Encountered the symbol "left" when expecting one of the following:   ; , for, union, connect, group, having, intersect, minus,
   order, start, where, with,Syntax error at line 87, column 17, file t1.pc:
Error at line 87, column 17 in file t1.pc
        on b.addrsender=a.addrreceiver
................1
PCC-S-02201, Encountered the symbol "=" when expecting one of the following:   : ) [ ] / . an identifier, a numeric constant,Syntax error at line 89, column 2, file t1.pc:
Error at line 89, column 2 in file t1.pc
        group by a.addrreceiver,a.count
.1
PCC-S-02201, Encountered the symbol "group" when expecting one of the following:   * + - / | at, and, or, day, hour, minute, month, returning,
   second, year,Syntax error at line 91, column 3, file t1.pc:
Error at line 91, column 3 in file t1.pc
        //select addrreceiver, count(addrreceiver) as count from t20050601
..1
PCC-S-02201, Encountered the symbol "/" when expecting one of the following:   : ( + - case, an identifier, a quoted string,
   a numeric constant, cursor, date, null, count, prior, cast,
   coalesce, deref, extract, interval, nullif, ref, time,
   timestamp, translate, treat, trim, avg, max, min, sum,
   stddev, variance,Error at line 0, column 0 in file t1.pc
PCC-F-02102, Fatal error while doing C preprocessing
[program@Redhat gq]$

解决方案 »

  1.   


    换成 WHERE A.COL=B.COL(+) 试试
      

  2.   

    bzszp(SongZip) 你好
    你说的意思是不是不用join而换成where做,如果不用join的确没问题,
    但是这和我要查询要求不符合了
      

  3.   

    select a.addrreceiver,a.count,count(b.addrreceiver) from 
    (select addrreceiver, count(addrreceiver) as count from t20050601 
    where  addrsender='[email protected]' group by addrreceiver) a
    , t20050601 b  
    where b.addrsender=a.addrreceiver(+) and b.addrreceiver='[email protected]'
    group by a.addrreceiver,a.count;
      

  4.   

    没用过这样的写法,是不是(+)指定a表字段,就表示对a表做left join呢
    我马上试试看
      

  5.   

    谢谢老大,完全正确。proc对语法的要求还真多啊!