Thursday, 6 March 2014

Overview of PLSQL

#=======================================================================
# Author            : Lokanadham Thandlam
#=======================================================================



--Example 1–1 PL/SQL Block Structure
<< label >> (optional)
DECLARE                                         -- Declarative part (optional)
-- Declarations of local types, variables, & subprograms
BEGIN                                            -- Executable part (required)
   -- Statements (which can use items declared in declarative part)
EXCEPTION -- Exception-handling part (optional)
-- Exception handlers for exceptions (errors) raised in executable part]
END;




--Example 1–2 Processing Query Result Rows One at a Time
BEGIN
   FOR someone IN (  SELECT *
                       FROM emp
                      WHERE empno < 10000
                   ORDER BY empno)
   LOOP
      DBMS_OUTPUT.PUT_LINE (
            'First name = '
         || someone.ename
         || ', Job = '
         || someone.job);
   END LOOP;

END;