Stored Procedures in Oracle
A stored procedure is a collection of SQL statements that are stored in the database and can be called by applications. Stored procedures are used to encapsulate complex logic and provide a standardized way to access data. Here is an example:
CREATE OR REPLACE PROCEDURE get_employee(
p_employee_id IN NUMBER,
p_employee OUT SYS_REFCURSOR
)
AS
BEGIN
OPEN p_employee FOR
SELECT * FROM employees WHERE employee_id = p_employee_id;
END;
This creates a stored procedure named "get_employee" that takes an employee ID as input and returns a cursor with the corresponding employee data.
No comments:
Post a Comment