FUNCTION A(O_error_message IN OUT VARCHAR2
) RETURN NUMBER IS

// all declarations -- no error here

cursor c1;

cursor c2;

cursor c3;

BEGIN

P_SKU :=NULL;
P_STORE :=NULL;
P_CLEARANCE :=NULL;
P_ZONE_GROUP_ID :=NULL;
P_PRICE :=NULL;
--COUNTER :=0;

for c_eff in c1 loop
exit when c1%notfound;
begin
flag_clear_susp_head :=0;
open c_rec(c_eff.effective_date);
loop
fetch c_rec into P_SKU,P_STORE,P_EVENT_NO,P_DEPT,P_ORIGINAL_EFFECTIVE_DATE,P_EFFECTIVE_DATE,P_PRICE,P_TRAN_TYPE,
P_STATUS,P_MANUAL_CHANGE_IND,P_MERCH_IND,P_TICKET_TYPE,P_REASON_MSI,P_SEASONAL_CLEAR_MSI;

exit when c_rec%notfound;
begin

P_Print_worksheet_at_loc_msi := 'Y';


--if O_return_code='TRUE' then

if flag_clear_susp_head=0 then
insert into clear_susp_head (CLEARANCE,
CLEARANCE_DESC,
REASON,
STATUS,
ZONE_GROUP_ID,
ORIG_ZONE_GROUP_ID,
CREATE_DATE,
CREATE_ID,
APPROVAL_DATE,
APPROVAL_ID,
PRINT_WORKSHEET_AT_LOC_MSI,
SEASONAL_CLEAR_MSI)
values
(P_CLEARANCE,
'CODI SKU' ,
3,
'S',
P_ZONE_GROUP_ID,
P_ZONE_GROUP_ID,
sysdate,
user,
sysdate,
user,
P_Print_worksheet_at_loc_msi,
'Y');
flag_clear_susp_head:=1;

--end if;

end if;

for c_szp in c3(P_SKU) loop
exit when c3%notfound;

begin
INSERT INTO CLEAR_SUSP_DETAIL (CLEARANCE,
SKU,
ZONE_GROUP_ID,
ZONE_ID,
MARKDOWN_NBR,
ACTIVE_DATE,
UNIT_RETAIL,
DOWNLOADED_DATE,
STATUS)
VALUES
(P_CLEARANCE,
P_SKU,
P_ZONE_GROUP_ID,
c_szp.zone_id,
1,
P_EFFECTIVE_DATE,
0, -- hard coded unit retail
NULL,
'S');
end loop;



commit;
end loop ;
CLOSE C_REC;
end loop ;


RETURN 0;


EXCEPTION

WHEN OTHERS THEN

O_error_message := SQL_LIB.CREATE_MSG('PACKAGE_ERROR',
SQLERRM,
'A',
to_char(SQLCODE));
O_error_message := O_error_message ||' SKU ' || P_SKU || ' STORE ' || P_STORE ;

ROLLBACK;
RETURN -1;

END A;



I m getting the following error
Error(865,1): PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following: begin case declare end exit for goto if loop mod null pragma raise return select update while with << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe


Cant understand why..
Any suggestions would be of great help.