Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple Select inside an Oracle Stored Procedure

how do you create a stored procedure with a simple select (SELECT * FROM TABLE) using Oracle? Also, any good tutorials on stored procedures would help tremendously.

Thanks.

like image 746
OneSneakyMofo Avatar asked Nov 23 '10 21:11

OneSneakyMofo


People also ask

Can we use SELECT in stored procedure?

We can not directly use stored procedures in a SELECT statement.

Can you write SELECT inside a trigger?

Yes, we can create trigger like functionality on select statement like, which user has select which table and most importantly what sql query�issued by using dbms_fga built in package. just check it out.

Can we use SELECT into in PL SQL?

You can make the use of the SELECT INTO statement in PL/ SQL to retrieve the row containing single or multiple column values in the resultant for storing them in variables.


2 Answers

create or replace procedure spr_select_Emp(eno in number, employee out emp%RowType)
As

Begin
   Select empno,ename,mgrno,hiredate,sal,comm,deptno into employee from emp
   where empno=eno
End;
like image 29
oralce passion Avatar answered Jan 04 '23 16:01

oralce passion


It depends on what you're trying to return from the stored procedure (resultset vs. scalar value) and what version of Oracle you're on (newer versions make this easier).

This question is probably a dupe of Get resultset from oracle stored procedure.

like image 171
BQ. Avatar answered Jan 04 '23 17:01

BQ.