Friday, 22 July 2011

USE OF bulk collect in oracle apps

 Step 1
=======
 create table Employee_test(
      ID                 VARCHAR2(4 BYTE)         NOT NULL,
      First_Name         VARCHAR2(10 BYTE),
      Last_Name          VARCHAR2(10 BYTE),
      Start_Date         DATE,
      End_Date           DATE,
      Salary             Number(8,2),
      City               VARCHAR2(10 BYTE),
      Description        VARCHAR2(15 BYTE)
   )


Step 2;-
======

insert into Employee_test(ID,  First_Name, Last_Name, Start_Date,End_Date,Salary,City,Description)
  values('02','Alison',   'Mathews', to_date('19760321','YYYYMMDD'), to_date('19860221','YYYYMMDD'), 6661.78, 'Vancouver','Tester')
 



 insert into Employee_test(ID,  First_Name, Last_Name, Start_Date,End_Date,Salary,City,Description)
   values('03','James',    'Smith',   to_date('19781212','YYYYMMDD'), to_date('19900315','YYYYMMDD'), 6544.78, 'Vancouver','Tester')
 



 insert into Employee_test(ID,  First_Name, Last_Name, Start_Date,End_Date,Salary,City,Description)
    values('04','Celia',    'Rice',    to_date('19821024','YYYYMMDD'), to_date('19990421','YYYYMMDD'), 2344.78, 'Vancouver','Manager')


Step3:-
======

declare
        type text_nt is table of VARCHAR2(256);
        v_ename_nt text_nt;
        cursor c_emp is select first_name from Employee_test where id='02';
        procedure p_print_row is
        begin
            if v_eName_nt.count=2 then
               DBMS_OUTPUT.put_line(v_eName_nt(1)||' '||v_eName_nt(2));
            elsif v_eName_nt.count=1 then
              DBMS_OUTPUT.put_line(v_eName_nt(1));
           end if;
       end;
   begin
       open c_emp;
       loop
           fetch c_emp bulk collect into v_eName_nt limit 2;
           p_print_row;
           exit when c_emp %NOTFOUND;
       end loop;
       close c_emp;
   end;







 

No comments:

Post a Comment