Oracle PL/SQL Tutorial/Function Procedure Packages/Print Output — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 13:45, 26 мая 2010
Output to the SQL plus
SQL> SET ECHO ON
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
2 a_name VARCHAR2(30) := "AAAA";
3
4 PROCEDURE name_print IS
5 BEGIN
6 DBMS_OUTPUT.PUT_LINE(a_name);
7 END;
8
9 BEGIN
10 DBMS_OUTPUT.PUT_LINE(a_name);
11
12 DECLARE
13 b_name VARCHAR2(30) := "BBBB";
14 BEGIN
15 DBMS_OUTPUT.PUT_LINE("Inside nested block");
16 DBMS_OUTPUT.PUT_LINE(a_name);
17 DBMS_OUTPUT.PUT_LINE(b_name);
18 name_print;
19 END;
20
21 DBMS_OUTPUT.PUT_LINE("Back in the main block");
22
23 --But we cannot compile the following line because b_name
24 --is not defined in this block.
25 --DBMS_OUTPUT.PUT_LINE(b_name);
26
27 --Our procedure, however, can access the value of a_name.
28 name_print;
29 END;
30 /
AAAA
Inside nested block
AAAA
BBBB
AAAA
Back in the main block
AAAA
PL/SQL procedure successfully completed.
SQL>