I need to write for a cursor who dispay a list of employees selected mit paramaters from_employee and to_employee two exceptions. First need to work when there is no rows were selected and another one when just one row was selected. My code just blocks all the time sqldeveloper and it starts to nerve. I need a help!!!
Why is this even a Stored Procedure? It ought to be a VIEW. But, anyway, a number of comments (and personal preferences):
1) When declaring variable, you correctly use %TYPE. That should also be used in the declaration of parameters. Something like:
2) What exactly does this procedure do? It just outputs to the console? If so, just use a VIEW, it is faster and simpler. If it is to return to the caller, there are going to be issues when there is more than one record. Nonetheless, if you want to print out each record separately, just use a FOR with an implicit CURSOR and move the parameters into the query itself:
3) If you need to know how many records were returned, just use a counter variable. Declare it on top and set it to 0. Then increment it in the loop.
(I do not think i have Oracle installed at home. So, this is completely untested.)