How to Execute PL SQL Block in Oracle

Below are the few quick examples to execute PL SQL block in Oracle.

1. Execute PL SQL Block in SQL Plus

In SQL Plus, just put the forward slash (/) at the end of PL SQL block and press enter to execute. As shown below:

set serveroutput on;

DECLARE
v_empno emp.empno%TYPE := 7369;
v_ename emp.ename%TYPE;
BEGIN
SELECT ename
INTO v_ename
FROM emp
WHERE empno = v_empno;

DBMS_OUTPUT.put_line (v_ename);
END;
/

Output

SMITH
PL/SQL procedure successfully completed.

2. Execute PL SQL Block in Toad

In Toad, put the cursor anywhere in the PL SQL block and press F5 to execute as a script or press F9 to execute in the background.

3. Execute PL SQL Block in SQL Developer

In SQL Developer, press ctrl+enter or press F5 to execute the PL SQL block.

See also:

  1. Import CSV in Oracle table using Toad
  2. Stored Procedure Example in Oracle
  3. Table Type Example in Oracle
Vinish Kapoor
Vinish Kapoor

Vinish Kapoor is a seasoned software development professional and a fervent enthusiast of artificial intelligence (AI). His impressive career spans over 20 years, marked by a relentless pursuit of innovation and excellence in the field of information technology. As an Oracle ACE, Vinish has distinguished himself as a leading expert in Oracle technologies, a title awarded to individuals who have demonstrated their deep commitment, leadership, and expertise in the Oracle community.