PL/SQL - Block

About

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;

Tools / Trick

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;

Documentation

See block


Powered by ComboStrap