启用oracle的控制台输出。将put_line的内容输出到服务器端的控制台。

解决方案 »

  1.   


    TThe ENABLE procedure enables calls to the other DBMS_OUTPUT modules. If you do not first call ENABLE, then any other calls to the package modules are ignored. The specification for the procedure is,PROCEDURE DBMS_OUTPUT.ENABLE  
       (buffer_size IN INTEGER DEFAULT 20000);buffer_size The size of the buffer that will contain the information stored by calls to PUT and PUT_LINE. The buffer size can be as large as 1,000,000 bytes. You can pass larger values to this procedure without raising an error, but doing so will have no effect besides setting the buffer size to its maximum. You can call ENABLE more than once in a session. The buffer size will be set to the largest size passed in any call to ENABLE. In other words, the buffer size is not necessarily set to the size specified in the last call.If you want to make sure that the DBMS_OUTPUT package is enabled in a program you are testing, add a statement like this one to the start of the program:DECLARE
       ... declarations ...
    BEGIN
       DBMS_OUTPUT.ENABLE (1000000);
       ...
    END;ResThis procedure call is not necessary when testing in a SQL*Plus environment. However, To enable output from calls to PUT_LINE in SQL*Plus, you will use the SET SERVEROUTPUT command,SQL> SET SERVEROUTPUT ONto see your results. This procedure is only required when you are using DBMS_OUTPUT to capture data in a client/server mode or a precompiler language program. Any PUT/GET calls prior to ENABLE are a no-op. In a precompiler program - for testing only -  the main program will most likely call ENABLE as part of program initialization. At various points within the application there may be triggers and stored procedures that call PUT_LINE. The main C (or other language) program or its subroutines will make calls to GET_LINE to capture the data written to DBMS_OUTPUT - these calls are made following the actions (SQL statements or stored procedure calls) that activated the calls to PUT_LINE. Having called GET_LINE, the main program can print the data captured.Debugging a difficult problem may require going back to a unit test mode and testing a stored procedure from SQL*Plus.When the buffer overflows an exception (-20000) is raised. When this occurs there are several options: w Increase the size of the DBMS_OUTPUT buffer to 1,000,000
    w Try filtering the data written to the buffer - possibly there is a loop that writes to DBMS_OUTPUT and you do not need this data.
    w Call ENABLE at various checkpoints within your code. Each call will clear the buffer.
    w Use an alternate debug interface to DBMS_OUTPUT. 光说不练之龙飞虎