Sobes.tech
Middle

What is a procedure in PL/SQL?

sobes.tech AI

Answer from AI

A procedure in PL/SQL is a named block of code that performs a specific task and can accept parameters. Unlike a function, a procedure does not necessarily return a value.

Procedures are used to organize reusable code, improve readability, and manage database logic.

Example of a procedure in PL/SQL:

CREATE OR REPLACE PROCEDURE update_salary(emp_id IN NUMBER, new_salary IN NUMBER) IS
BEGIN
  UPDATE employees SET salary = new_salary WHERE employee_id = emp_id;
  COMMIT;
END;
/

This procedure updates the salary of an employee with the specified ID.