更新时间:2023-10-26 20:26:46
是关于那些花哨"的您在此处使用的单引号:
It is about those "fancy" single quotes you used here:
DBMS_OUTPUT.PUT_LINE(‘Department Names are :’ || DEPARTMENT_NAME);
应该
DBMS_OUTPUT.PUT_LINE('Department Names are :' || DEPARTMENT_NAME);
截至其他错误"你已经做了:没有循环,光标只返回一行,然后显示它.我建议您切换到游标 for 循环,因为它更易于维护:
As of other "errors" you've made: without a loop, cursor returns only one row and you then display it. I'd suggest you to switch to a cursor for loop as it is simpler to maintain:
begin
for cur_r in (select department_name from department) loop
dbms_output.put_line(cur_r.department_name);
end loop;
end;
/
这就是你需要的一切;没有声明部分,没有打开或关闭游标,不用担心退出循环...... Oracle 为你做.
This is everything you need; no declaration section, no opening nor closing a cursor, no worrying about exiting the loop ... Oracle does it for you.