Friday, 16 May 2014

Simple PLSQL Program

DECLARE

  -- single line ccmments
   --
 
   --multi line comments
   /*
   --- n number of statements
 
   */

   --<declarations section>
   --variables
   --char type
   --declare variables using %TYPE,%ROWTYPE
   --declare records as PLSQL TABLE TYPE
   -- declare global variables
   --number type
   --date type
   -- cursor
   -- exceptions
   --subprograms
 --
stud_id  number;
stud_name varchar2(15) :='SATHISH';
join_date date := sysdate;
SUBTYPE name IS char(20);
SUBTYPE message IS varchar2(100);
salutation name; greetings message;

BEGIN
--<executable command(s)>
  --we can use dml statements
     -- insert ,update,delete,select....
     -- we can use operations
     -- we can write all loop conditions
     --here we raise exceptions
     -- we can open the cursor, fetch,close
   
     /* dbms_output.put_line('OUTER BEGIN');
        dbms_output.put_line('Student ID:'||stud_id);
     */
     null;
    stud_id :=10;
--    stud_name := 'SATHISH';  
     dbms_output.put_line('OUTER BEGIN');
     dbms_output.put_line('Student ID:'||stud_id);
     dbms_output.put_line('Student Name:'||stud_name);
     dbms_output.put_line('Student Join Date:'||join_date);
     begin
      null;
      stud_id :=20;
       stud_name :='RAM';
      dbms_output.put_line('INNER BEGIN');
      dbms_output.put_line('Student ID:'||stud_id);
      dbms_output.put_line('Student ID:'||stud_name);
      dbms_output.put_line('Student ID:'||join_date);
     -- all executable statements
     exception
     when others then
     null;
     end;

No comments:

Post a Comment

Note: only a member of this blog may post a comment.