1-1. Creating a Block of Code

Problem

You are interested in creating an executable block of PL/SQL code.

Solution

Write the keywords BEGIN and END. Place your lines of code between those two keywords. Here's an example:

BEGIN    Executable statements go here… END;

If you want to introduce variables for your PL/SQL block, you must precede your block with a DECLARE section. Here's an example:

DECLARE     One or more variable declarations BEGIN     One or more PL/SQL statements END;

How It Works

A block of code is an executable program that performs a unit of work. The minimum executable block of code starts with the keyword BEGIN and ends with the keyword END. In between those two keywords there should be one or more PL/SQL statements that ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.