This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
kurs:table_index_by_varchar2 [2010/05/18 11:15] 127.0.0.1 external edit |
kurs:table_index_by_varchar2 [2015/04/16 09:28] (current) mh |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | <code> | ||
| + | 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 | ||
| + | </code> | ||
| + | |||
| + | |||
| + | |||
| <code> | <code> | ||
| PROCEDURE SALARY_DIFF_VC | PROCEDURE SALARY_DIFF_VC | ||
| Line 37: | Line 68: | ||
| END; -- Procedure | END; -- Procedure | ||
| + | </code> | ||
| + | |||
| + | <code> | ||
| + | CREATE OR REPLACE PROCEDURE DEMO_HASH AS | ||
| + | |||
| + | type person_record is record ( | ||
| + | r_name varchar2(100), | ||
| + | r_height integer); | ||
| + | |||
| + | type simple_person_table_type is table of person_record | ||
| + | index by binary_integer; | ||
| + | |||
| + | type person_table_type is table of persons%rowtype | ||
| + | index by varchar2(20); | ||
| + | |||
| + | type person_table_i_type is table of persons%rowtype | ||
| + | index by binary_integer; | ||
| + | |||
| + | cursor c_persons is (select * from persons); | ||
| + | |||
| + | tn simple_person_table_type; | ||
| + | |||
| + | v_per person_table_type; | ||
| + | v_i_per person_table_i_type; | ||
| + | |||
| + | v_i binary_integer; | ||
| + | v_vc varchar2(100); | ||
| + | BEGIN | ||
| + | |||
| + | tn(10).r_name := 'Mark'; | ||
| + | tn(10).r_height := 175; | ||
| + | |||
| + | tn(2000).r_name := 'Michael'; | ||
| + | tn(2000).r_height := 183; | ||
| + | |||
| + | v_i := tn.first; | ||
| + | while v_i is not null loop | ||
| + | dbms_output.put_line(v_i || ' ' ||tn(v_i).r_name); | ||
| + | v_i := tn.next(v_i); | ||
| + | end loop; | ||
| + | |||
| + | v_per('Michael').per_name := 'Michael'; | ||
| + | v_per('Michael').per_birthday := to_date('1981-04-25', 'yyyy-mm-dd'); | ||
| + | |||
| + | for r in (select * from persons) loop | ||
| + | v_per(r.per_name) := r; | ||
| + | end loop; | ||
| + | |||
| + | open c_persons; | ||
| + | fetch c_persons bulk collect into v_i_per; | ||
| + | close c_persons; | ||
| + | |||
| + | dbms_output.put_line('bulk collect result'); | ||
| + | for i in 1 .. v_i_per.last loop | ||
| + | dbms_output.put_line(v_i_per(i).per_name||' '|| | ||
| + | v_i_per(i).per_birthday | ||
| + | ); | ||
| + | end loop; | ||
| + | dbms_output.put_line('***'); | ||
| + | |||
| + | |||
| + | |||
| + | v_vc := v_per.first; | ||
| + | while v_vc is not null loop | ||
| + | dbms_output.put_line(v_vc || ' ' ||v_per(v_vc).per_name||' '|| | ||
| + | v_per(v_vc).per_birthday | ||
| + | ); | ||
| + | |||
| + | if v_per(v_vc).per_education is not null then | ||
| + | dbms_output.put_line( | ||
| + | v_per(v_vc).per_education(v_per(v_vc).per_education.last) | ||
| + | ); | ||
| + | end if; | ||
| + | v_vc := v_per.next(v_vc); | ||
| + | end loop; | ||
| + | |||
| + | |||
| + | END DEMO_HASH; | ||
| </code> | </code> | ||