pl/sql 中变量定义范围的小例子:
开始
set serveroutput on; <<outer>> DECLARE birthdate DATE; BEGIN birthdate:=TO_DATE('2012-05-18','YYYY-MM-DD'); DECLARE birthdate DATE; BEGIN birthdate:=TO_DATE('2012-01-15','YYYY-MM-DD'); dbms_output.put_line('inner date is:' || birthdate); dbms_output.put_line('outer date is:' || outer.birthdate); END; dbms_output.put_line('outer date is:' || birthdate); END;
运行结果:
anonymous block completed inner date is:15-JAN-12 outer date is:18-MAY-12 outer date is:18-MAY-12
结束