Sql dbms#u output.put#u行即使在';将serveroutput设置为启用';

Sql dbms#u output.put#u行即使在';将serveroutput设置为启用';,sql,stored-procedures,plsql,oracle10g,plsqldeveloper,Sql,Stored Procedures,Plsql,Oracle10g,Plsqldeveloper,下面的过程执行得很好,但其中的“dbms”不会打印任何输出。(该过程旨在草草记下尚未在表中输入工资的EMP的名称) 该表有两列,即1)名称\u of_emp 2)薪水(默认为0) serveroutput设置为“on”,我在执行时收到消息“procedure completed successfully”,但它不会打印未输入工资的EMP的名称(表中有一些)。 这里有什么问题吗?c%found在获取一行之前是不正确的,因此您永远不会进入循环。这是一个代码结构问题,而不是dbms\u输出问题 顺便说

下面的过程执行得很好,但其中的“dbms”不会打印任何输出。(该过程旨在草草记下尚未在表中输入工资的EMP的名称) 该表有两列,即1)名称\u of_emp 2)薪水(默认为0)

serveroutput设置为“on”,我在执行时收到消息“procedure completed successfully”,但它不会打印未输入工资的EMP的名称(表中有一些)。
这里有什么问题吗?

c%found
在获取一行之前是不正确的,因此您永远不会进入循环。这是一个代码结构问题,而不是
dbms\u输出问题

顺便说一下,这可以简化为:

create or replace procedure add_sal_info
as
    cursor c is select * from emp_earnings;
begin
    for r in c loop
        if r.csal = 0 then
            dbms_output.put_line('enter salary for : ' ||' '|| r.cname);
        end if;
    end loop;
end;
甚至

create or replace procedure add_sal_info
as
begin
    for r in (
        select * from emp_earnings
    )
    loop
        if r.csal = 0 then
            dbms_output.put_line('enter salary for : ' ||' '|| r.cname);
        end if;
    end loop;
end;

PL/SQL在
if
while
条件(它有
then
关键字)周围没有括号。您可以将它们放在那里,但它们会被忽略。

c%found
在获取行之前不为true,因此您永远不会进入循环。这是一个代码结构问题,而不是
dbms\u输出问题

顺便说一下,这可以简化为:

create or replace procedure add_sal_info
as
    cursor c is select * from emp_earnings;
begin
    for r in c loop
        if r.csal = 0 then
            dbms_output.put_line('enter salary for : ' ||' '|| r.cname);
        end if;
    end loop;
end;
甚至

create or replace procedure add_sal_info
as
begin
    for r in (
        select * from emp_earnings
    )
    loop
        if r.csal = 0 then
            dbms_output.put_line('enter salary for : ' ||' '|| r.cname);
        end if;
    end loop;
end;
PL/SQL在
if
while
条件(它有
then
关键字)周围没有括号。你可以把它们放在那里,但是它们被忽略了。

很高兴这有帮助。(刚刚编辑添加了一个简化版本。)很高兴这有帮助。(刚刚编辑以添加简化版本。)