Friday, 23 October 2015

My notes on PL/SQL


I found these 3 articles very informative and all that you need to know before using pl/sql in your project. ( If you already know sql )

These links are by Steven Feuerstein ( They are all you need if for PL/SQL if you know sql well )

A Good link on use of Cursor


A Good link on When not to use For loop


A Good link on Bulk collect and For all


Good Way to write PL/SQL

DECLARE
   c_limit PLS_INTEGER := 100;
CURSOR employees_cur
   IS
      SELECT employee_id
        FROM employees
       WHERE department_id = department_id_in;

TYPE employee_ids_t IS TABLE OF 
      employees.employee_id%TYPE;

l_employee_ids   employee_ids_t;

BEGIN
   OPEN employees_cur;
LOOP
      FETCH employees_cur
      BULK COLLECT INTO l_employee_ids
      LIMIT c_limit;
EXIT WHEN l_employee_ids.COUNT = 0;
   END LOOP;
END;

No comments:

Post a Comment