2

是否可以在执行包中的过程时向用户显示注释。我的包裹有 3 个程序。我一个接一个地打电话。我想在控制台上显示注释,例如程序 xyz 正在执行,程序成功执行。我在程序中添加了评论,例如DBMS_OUTPUT.PUT_LINE('PROCEDURE EXECUTED SUCCESSFULLY')但对我没有用。仅供参考,我在 Windows 7 系统中使用 oracle 11g。

4

1 回答 1

10

You can't use DBMS_OUTPUT to display information on a procedure while it is running. This is because DBMS_OUTPUT.put_line doesn't display data on screen, rather, the data is put in a queue that is later read by the calling client (This queue is also invisible outside of its transaction). If you use SQL*Plus the queue is read and displayed automatically at the end of the procedure if you have SET SERVEROUTPUT ON.

Other means exist to follow the progress of a procedure while it is running:

As you can see you would need another process to read the information while it is written. In some applications, this would be achieved by running the main batch job in a new separate process, for example by calling DBMS_JOB or DBMS_SCHEDULER while the calling transaction loops on the progress table or file until the job is complete.

SQL*Plus is not an interactive client, you will need some more sophisticated environment to achieve this functionality.

于 2012-09-04T08:54:34.103 回答