Absolutely! However, the command changes a little bit - you have to provide a variable to select INTO:
CREATE OR REPLACE PROCEDURE xyz AS
v_ename emp.ename%TYPE;
v_salary emp.salary%TYPE;
BEGIN
SELECT ename, salary
INTO v_ename, v_salary
FROM emp
WHERE emp_id = 75;
.
.
.
END;
Also, be advised that the query must return one and only one row. If no rows are returned, Oracle will raise a NO_DATA_FOUND exception. If more than one row is returned, you will get a TOO_MANY_ROWS error.
If you need to select more than one row at a time, you will want to use an explicit cursor.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.