Question : Oracle Portal - Error WWV-17050 - Failed to parse..

First let me say that I am not very experienced with PL-SQL and that is probably where my error is.  I am getting this error inside of Oracle portal.  I do have a schema called famis7i.world where I have successfully established a database link.  With other simples SQL statements I am able to run reports and get the data I want.  In this particular PL-SQL code I don’t know where the problem is.  The portlet I wan to add is a “report from SQL”  The code for the report is as fallowed:  PS: Please refer to the rest of my posting after the SQL code!

select 'Q'||(to_char(add_months(sysdate,6),'Q') - 1) "QUATER",
bsc_training_hours(decode( (to_char(add_months(sysdate,6),'Q') - 1), '1','07/01/'||to_char(sysdate,'RR'), '2','10/01/'||to_char(sysdate,'RR'),'3','01/01/'||(to_char(sysdate,'RR')+1),'4','04/01/'||(to_char(sysdate,'RR')+1)),
decode( (to_char(add_months(sysdate,6),'Q') - 1), '1','10/01/'||to_char(sysdate,'RR'), '2','01/01/'||to_char(sysdate,'RR'),'3','04/01/'||(to_char(sysdate,'RR')+1),'4','07/01/'||(to_char(sysdate,'RR')+1))) "TRAINING_HOURS_FOR_QUARTER",
        bsc_training_hours_year(decode( (to_char(add_months(sysdate,6),'Q') - 1), '1','07/01/'||to_char(sysdate,'RR'), '2','10/01/'||to_char(sysdate,'RR'),'3','01/01/'||(to_char(sysdate,'RR')+1),'4','04/01/'||(to_char(sysdate,'RR')+1)),
decode( (to_char(add_months(sysdate,6),'Q') - 1), '1','10/01/'||to_char(sysdate,'RR'), '2','01/01/'||to_char(sysdate,'RR'),'3','04/01/'||(to_char(sysdate,'RR')+1),'4','07/01/'||(to_char(sysdate,'RR')+1))) "TRAINING_HOURS_PER_YEAR",
        fm_emps('1') "FM_EMPS",
        round((bsc_training_hours_year(decode( (to_char(add_months(sysdate,6),'Q') - 1), '1','07/01/'||to_char(sysdate,'RR'), '2','10/01/'||to_char(sysdate,'RR'),'3','01/01/'||(to_char(sysdate,'RR')+1),'4','04/01/'||(to_char(sysdate,'RR')+1)),
decode( (to_char(add_months(sysdate,6),'Q') - 1), '1','10/01/'||to_char(sysdate,'RR'), '2','01/01/'||to_char(sysdate,'RR'),'3','04/01/'||(to_char(sysdate,'RR')+1),'4','07/01/'||(to_char(sysdate,'RR')+1))) / fm_emps('1')),2) "AVG_PER_EMP"
from dual
     

I can tell this is calling:  (bsc_training_hours_year) and (bsc_training_hours) which are functions inside of a system schema.  So, I know this function must exist.  When I try to create (BSC_TRAINING_HOURS_YEAR) I get the fallowing error.  I am posting the code first then the error!

(p_start IN VARCHAR2, p_end IN VARCHAR2) RETURN NUMBER IS

begin
  declare
  vtrain number;
begin

  select  sum(hours)
    into vtrain
  from [email protected]
  where wo_number = 'SWO001252'
  and trunc(work_date) >= to_date(p_end, 'MM/DD/RR') -365
  and trunc(work_date) <= to_date(p_end, 'MM/DD/RR')
    and employee in (select employee from [email protected] where crew in ('ENGR','ENERGY','REFR','PAINT','CARP','LOCK','PLUM','SIGNAGE','AUTO','ELEC','METAL','GDSFM','GDSPARK','GDSHSE','EQUIP OPER','IRR SPEC','LEAD GRDS','RECYCLE','MOVE', 'CUST')
                   )
  order by 1;
return vtrain;
exception when others then
 vtrain := '0';
 return vtrain;
end;



end;

ERROR:

Line No. 3 : PLS-00103: Encountered the symbol "(" when expecting one of the following:

. @ % ; is authid as cluster order using external character
deterministic parallel_enable pipelined aggregate
(WWV-17050)
Line No. 5 : PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following:

language
(WWV-17050)
Line No. 27 : PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:

begin function package pragma procedure form
(WWV-17050)
ORA-24344: success with compilation error (WWV-11230)
Failed to parse as PORTAL - create or replace Function SYSTEM.BSC_TRAINING_HOURS_YEAR
return VARCHAR2
(p_start IN VARCHAR2, p_end IN VARCHAR2) RETURN NUMBER IS

begin
declare
vtrain number;
begin

select sum(hours)
into vtrain
from [email protected]
where wo_number = 'SWO001252'
and trunc(work_date) >= to_date(p_end, 'MM/DD/RR') -365
and trunc(work_date) <= to_date(p_end, 'MM/DD/RR')
and employee in (select employee from [email protected] where crew in ('ENGR','ENERGY','REFR','PAINT','CARP','LOCK','PLUM','SIGNAGE','AUTO','ELEC','METAL','GDSFM','GDSPARK','GDSHSE','EQUIP OPER','IRR SPEC','LEAD GRDS','RECYCLE','MOVE', 'CUST')
)
order by 1;
return vtrain;
exception when others then
vtrain := '0';
return vtrain;
end;



end; (WWV-08300)


Please help!!!

Thank you.

Answer : Oracle Portal - Error WWV-17050 - Failed to parse..

Your syntax is wrong>>

begin
declare
vtrain number;
begin

You have a declare within the first begin that is not valid, the sequence is...

declare
begin
end;

One other thing that spring to mind is your database link - has that been created within the PORTAL schema?

bg
Random Solutions  
 
programming4us programming4us