Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Component Table Development 1

Status
Not open for further replies.

marjac

Programmer
Jun 19, 2001
7
US
Can a stored procedure select SQL stored in a database table?
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top