简体   繁体   English

PLS-00382:表达式类型错误,无法显示 DBMS_OUTPUT.PUT_LINE

[英]PLS-00382: expression is of wrong type, can't show DBMS_OUTPUT.PUT_LINE

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多次遇到这个问题,SQL Developer can't show DBMS_OUTPUT.PUT_LINE 尽管已经打开了服务器输出并且 DBMS Output 从查看工具栏打开

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控制台成功请求输入,但无法在任何地方显示所需的 output

ORA-06550: line 8, column 12:
PLS-00382: expression is of wrong type
ORA-06550: line 8, column 9: error

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. DB<>fiddle b 的常数值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM