User Tools

Site Tools


kurs:table_index_by_varchar2

This is an old revision of the document!


PROCEDURE teilnehmer_index_by_varchar is
type teilnehmer_type IS RECORD
     (name        varchar2(25),
      geschlecht  varchar2(25));

TYPE teilnehmer_table_type IS TABLE OF varchar2(25)
      INDEX BY varchar2(25);

tn teilnehmer_table_type;

v_i varchar2(25);

BEGIN
tn('Mark') := 'M';
tn('Karin') := 'W';
tn('Albert') := 'M';
tn('Gökhan') := 'M';
tn('Natalya') := 'W';

v_i := tn.first;
while v_i is not null loop
  dbms_output.put_line(v_i||' '||tn(v_i));
  v_i := tn.next(v_i);
end loop;

END; -- Procedure
PROCEDURE SALARY_DIFF_VC
   IS
cursor bonus_salary is
  SELECT * FROM bonus
    order by salary desc;

TYPE bonus_table_type IS TABLE OF bonus%rowtype
      INDEX BY varchar2(100);

bonus_table bonus_table_type;

bonus_salary_rec bonus%rowtype; 
  
v_index      varchar2(100);

BEGIN

open bonus_salary;
   loop
     fetch bonus_salary into bonus_salary_rec;
     exit when bonus_salary%notfound;
     bonus_table(bonus_salary_rec.first_name||' '||bonus_salary_rec.last_name) 
        := bonus_salary_rec;
 
   end loop;
close bonus_salary;

v_index := bonus_table.first;   
for j in 1..bonus_table.count loop
  dbms_output.put_line(j||' '||
                       bonus_table(v_index).first_name ||' '||
                       bonus_table(v_index).last_name  ||' '||
                       bonus_table(v_index).salary);
  v_index := bonus_table.next(v_index);
end loop;   

END; -- Procedure
kurs/table_index_by_varchar2.1410376975.txt.gz · Last modified: 2015/04/16 09:28 (external edit)