PL/SQL - Block

> Procedural Languages > PL/SQL - (Procedure Language|PL) SQL

1 - About

3 - Syntax

<< 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;

4 - Tools / Trick

4.1 - Generating PL/SQL block in SQL

SELECT
    CASE
      WHEN MIN(rownum) OVER () = rownum
      THEN 'BEGIN '
        || statement 
      WHEN MAX(rownum) OVER () = rownum
      THEN statement
        || 'END;'
        || '/'
      ELSE statement
    END AS BEGIN
FROM 
whateverTable;

5 - Documentation

See block

Advertising
lang/plsql/block.txt · Last modified: 2017/09/17 17:36 by gerardnico