PL/SQL 11g R2 —— PL/SQL概述 !

PL/SQL 块结构:

<< label >> (optional)
DECLARE -- Declarative part (optional)
-- Declarations of local types, variables, & subprograms

BEGIN -- Executable part (required)
-- Statements (which can use items declared in declarative part)

[EXCEPTION -- Exception-handling part (optional)
-- Exception handlers for exceptions (errors) raised in executable part]
END;

PL/SQL 块分类:

PL/SQL 11g R2 —— PL/SQL概述 !_第1张图片


匿名块:

SQL> conn hr/hr
已连接。
SQL> set serveroutput on
SQL> declare
  2    v_fname varchar2(20);
  3  begin
  4    select first_name into v_fname from employees where employee_id = 100;
  5    dbms_output.put_line(v_fname);
  6  end;
  7  /
Steven

PL/SQL 过程已成功完成。

你可能感兴趣的:(PL/SQL 11g R2 —— PL/SQL概述 !)