Oracle cursor for updating in oracle Camvoice naked
If you are fetching very large numbers of rows (10s of 1000s and more), it is possible that switching to FETCH-BULK COLLECT and a high LIMIT value will make your code somewhat faster. Next, if you’re writing a “one-off” script, or a program that is run only occasionally and is not in the critical path of operations, you may want to choose the simplicity and readability of the cursor FOR loop over the incremental improvement in performance (and additional complexity of code) that BULK COLLECT offers.
Use an implicit SELECT INTO for single-row fetches.
I further recommend that you encapsulate your SELECT INTO statements into their own functions whose sole purpose is to retrieve this one row of information, as shown in Listing 1.
Code Listing 1: Encapsulating SELECT INTO in a function PACKAGE employees_qp IS FUNCTION last_name (id_in IN employees.employee_id%TYPE) RETURN employees.last_name%TYPE; END employees_qp; PROCEDURE process_employee (id_in IN employees.employee_id%TYPE) IS l_last_name employees.last_name%TYPE; BEGIN l_last_name := employees_qp.last_name (id_in); END process_employee; With this approach, you are much more likely to reuse that SELECT INTO rather than write it repeatedly in your code.
In addition, the use of SELECT INTO states very clearly that you expect at most one row, and the statement will raise exceptions (NO_DATA_FOUND or TOO_MANY_ROWS) if your expectations are not met.
This reuse is important, because it will make optimizing the SQL statements in your application much easier.
In particular, you will be able to take advantage of Oracle Database 11’s function result cache feature more quickly and smoothly.
There cannot be more than 12 rows in this table, but there may certainly be fewer.
I need to retrieve these months into a collection and then display each month.