How to Execute PL SQL Block in Oracle

  • PLSQL
  • 1 min read

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