tailieunhanh - Oracle SQL Plus The Definitive Guide- P7

Oracle SQL Plus The Definitive Guide- P7:Every day, computer professionals the world over wake up, travel to the office, sit down in front of a computer, and begin another day working with that database called Oracle. Programmers write queries and stored procedures. Database administrators monitor performance, make database changes, and perform other maintenance tasks. Operations people may need to back up or recover a database. | previous page page_37 next page Page 37 7 DBMS_OUTPUT_PUT_LINE An error occurred. 8 END 9 PL SQL procedure successfully completed. Where s the output Now you may be wondering why there was no output from the code block in the previous section. After all the code does contain a call to the PUT_LINE procedure that sure looks as if it ought to display something. In fact the code did generate some output. You just didn t see it. Remember from Chapter 1 that SQL Plus itself does not execute PL SQL code. It just sends that code to the database server which executes the code for you. The Oracle database server doesn t have any way to directly display the output for you to see. Instead any output from PL SQL code is buffered by the server for later retrieval by the application that executed it in this case SQL Plus. By default SQL Plus does not retrieve PL SQL output from the server. You have to tell it to retrieve the output if you want to see it. The command for that is SET SERVEROUTPUT ON If you enter the above command followed by the same PL SQL block that you entered earlier your output will look like this SQL SET SERVEROUTPUT ON SQL DECLARE 2 X VARCHAR2 12 Hello World 3 BEGIN 4 X 5 EXCEPTION 6 WHEN OTHERS THEN 7 An error occurred. 8 END 9 Hello World PL SQL procedure successfully completed. This time around you do see the output from the block. The SERVEROUTPUT setting sticks for the duration of your SQL Plus session so you don t have to keep turning it on each time you execute another block. There are some other parameters to the SET SERVEROUTPUT command that affect formatting and the output buffer size. The SIZE parameter lets you increase the buffer size from the default of 2000 bytes something you should do if you expect to display a lot of information from PL SQL. The FORMAT parameter lets you control whether and how long lines of output are wrapped when they are displayed. The following exam- previous page page_37 next

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.