This I put to you evaluate the strange things that occur sometimes: a select with having before the WHERE !!!
In the example below, I am simulating the error in an Oracle 8.0.6 (100% bugged). The worst is that in version 8.1.7.4 This is also working
SQL> SELECT * FROM V$VERSION;
BANNER
----------------------------------------------------------------
Oracle8 Release 8.0.6.0.0 - Production
PL/SQL Release 8.0.6.0.0 - Production
CORE Version 4.0.6.0.0 - Production
TNS for HPUX: Version 8.0.6.0.0 - Production
NLSRTL Version 3.3.3.0.0 - Production
SQL>
SQL>
SQL> create or replace procedure thomas_loucura
2 is
3 cursor vcur is
4 select me.codmerc
5 from mercean Me,
6 mercfil mf
7 having max(flgbase) = 'N' --- **** ABSURDO ****
8 where me.codmerc = mf.codmerc
9 and mf.codsit <> 'E'
10 group by me.codmerc;
11
12 vtemp number;
13 begin
14
15
16 open vcur;
17 fetch vcur into vtemp;
18 close vcur;
19
20 end;
21 /
Procedure created
SQL>
SQL> EXEC THOMAS_LOUCURA;
PL/SQL procedure successfully completed
SQL>