kamilacbe 14 Junior Poster in Training

Hi , here is my procedure where i want to return the open cursor to client using EyPupilPremiumLog parameter and then have to loop through for looging purpose which i cudnt able to do.. tried fetch /for etc but missing somewhere the nuanses .. Advise would be helpful.

PROCEDURE GetEyPupilPremiumLog(pLogId            IN ey_pupil_premium_log.log_id%TYPE,                              
                               pPreview          IN ey_pupil_premium_log.preview%TYPE,
                             --  ErrorLog          OUT NUMBER,
                               EyPupilPremiumLog OUT SYS_REFCURSOR) IS                               
 -- type test is ref cursor return EyPupilPremiumLog%rowtype;
  l_ey_pp_full def_param.param_val%TYPE;   

  l_cursor  SYS_REFCURSOR;   
  ServiceName la_service_provider_detail.service_name%TYPE;
  Surname people.surname%TYPE;
  Forename people.forename%Type;
  Action Varchar(50);
  Rate ey_pupil_premium_log.rate%Type;
  Funding_Code single_funding_formulas.funding_code%Type; 
  limit_in  PLS_INTEGER DEFAULT 100;
  --Row_total_Count Number;

 BEGIN
  SELECT param_val
  INTO   l_ey_pp_full
  FROM   def_param
  WHERE  param_cd = 'EY_PP_FULL'; 
OPEN EyPupilPremiumLog FOR   
  SELECT lspd.service_name "Service Name",
           p.surname "Surname",
           p.forename "Forename", 
           case epl.action
             when 'RI' then 'Rate Increased'
             when 'RD' then 'Rate Decreased'               
             when 'AC' then 'Adjustment Created'               
             when 'LC' then 'Line Cancelled'               
             when 'SA' then 'SFF Added'               
             when 'SD' then 'SFF Deleted'               
           end "Action",
           epl.rate "Rate",
           sff.funding_code "Funding Code"
    -- INTO  ServiceName, Surname, Forename,Action,Rate,Funding_Code 
      FROM ey_pupil_premium_log epl
           JOIN la_serv_prov_child_hours lspch
        ON epl.la_serv_prov_child_hours_id =
           lspch.la_serv_prov_child_hours_id          
           JOIN la_service_provider_detail lspd
        ON lspch.la_service_provider_detail_id =
           lspd.la_service_provider_detail_id
           JOIN people p
        ON lspch.stud_id = p.person_id 
 LEFT JOIN single_funding_formula_rates sffr 
        ON epl.funding_formula_rate_id = sffr.funding_formula_rate_id
 LEFT JOIN single_funding_formulas sff
        ON sffr.funding_formula_id = sff.funding_formula_id     
       WHERE ((pLogId IS NULL)OR (epl.log_id = pLogId)OR epl.log_id IS NULL)    
       AND epl.preview = pPreview       
       OR (l_ey_pp_full = 'T' OR epl.action in ('RI','RD'))     
       Order BY lspd.service_name,
              p.surname,
              p.forename,
              epl.ey_pupil_premium_log_id; 
              -- Have to loop the data over here 
              FETCH EyPupilPremiumLog 
    INTO  l_cursor;-- ServiceName, Surname, Forename,Action,Rate,Funding_Code;
   DBMS_OUTPUT.PUT_LINE(l_cursor.ServiceName); --pops as Not declared with the l_cursor :(
   CLOSE l_cursor;
END GetEyPupilPremiumLog;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.