Reputation: 21
Encountered this problem several times, that SQL Developer can't show DBMS_OUTPUT.PUT_LINE despite already turning serveroutput on and Dbms Output turned on from View toolbar
set serveroutput on;
accept p_angka prompt 'Input Number : ';
declare
a integer;
b integer :=&p_angka;
begin
dbms_output.put_line('---ODD NUMBER---');
for a in 1..b loop
if (a mod 2) then
dbms_output.put_line(a);
end if;
end loop;
end;
Console succesfully asking for input but can't show the desired output anywhere with
ORA-06550: line 8, column 12:
PLS-00382: expression is of wrong type
ORA-06550: line 8, column 9: error
Upvotes: 1
Views: 198
Reputation: 35910
I think there are several mistakes in your code which is mentioned inline in the following code:
set serveroutput on;
-- accept p_angka prompt 'Input Number : '; -- not needed
declare
--a integer; -- not needed
b integer := &p_angka;
begin
dbms_output.put_line('---ODD NUMBER---');
for a in 1..b loop
if (mod(a,2) = 0) then -- mod function should be used like this
dbms_output.put_line(a);
end if;
end loop;
end;
/
DB<>Fiddle with constant value for b.
Upvotes: 2