Wednesday, October 10, 2007

ORA-06550 problem in script

Tried to execute the script below got error The query:

DECLARE
CURSOR sol_cursor IS select * from membership;
months NUMBER(5,0) :=0;
BEGIN
FOR r_sol IN sol_cursor LOOP
months := (select min_months from membership_plan where id = r_sol.membership_plan_id);
UPDATE membership
SET end_date = add_months(r_sol.end_date,months)
WHERE id = r_sol.id
END LOOP;
END;

ERROR:
ORA-06550: line 6, column 12: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following: ( - + case mod new not null others avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date pipe


SOLUTION:
changing:
months := (select min_months from membership_plan where id = r_sol.membership_plan_id);

to:
select min_months INTO months from membership_plan where id = r_sol.membership_plan_id;

No comments: