I want to set the cntpm local var in my PL/SQL block. This value is originally returned from a SQL that uses the present cursor variable. But I get an error in my code.
DBMS_OUTPUT.ENABLE;
DECLARE CNTPM INTEGER;
CURSOR c1 IS
SELECT distinct proj_code from all_projects_plan ;
BEGIN
FOR item IN c1
LOOP
SET CNTPM =: select count(distinct pm) from MYTABLE where pmloc= 'NA' and p_code = item.proj_code
DBMS_OUTPUT.PUT_LINE('Project = ' || item.proj_code || ' with number of project managers = ' || CNTPM );
IF CNTPM > 1 THEN DBMS_OUTPUT.PUT_LINE ('Several Project managers')
ELSE DBMS_OUTPUT.PUT_LINE ('just one project manager');
END LOOP;
END;
Error starting at line : 1 in command -
DBMS_OUTPUT.ENABLE
Error report -
Unknown Command
I revised accordingly to but seem to get an error at the line 1 declaration. This confuses me - why would the DECLARE not accept a variable?The funny thing is only left in the DECLARE line for the cntpm and still got an error at line 1 which disappears when I change it to:
VAR cntpm INTEGER;
--------------------------
DECLARE cntpm INTEGER;