User Tools

Site Tools


kurs:nested_table_als_column_type

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
kurs:nested_table_als_column_type [2011/11/17 11:10]
mh
kurs:nested_table_als_column_type [2014/11/11 14:52] (current)
mh
Line 1: Line 1:
 +<​code>​
 +CREATE OR REPLACE PROCEDURE TEILNEHMER_EDUCATION ​
 +/*
 +  + zusaetzlich zum teilnehmernamen eine zusätzliche
 +    ausbildung (p_add_education) angeben und die an die schon vorhandenen
 +    anhaengen und den Teilnehmer damit updaten
 +
 +*/
 +(p_tln_name teilnehmer.tln_name%type,​
 + ​p_add_education varchar2
 +)
 +AS
 +  t_education education; ​
 +BEGIN
 +  select coalesce(tln_education,​ education() ) into t_education ​
 +    from teilnehmer
 +  where tln_name = p_tln_name; ​       ​
 +  ​
 +  -- dbms_output.put_line(t_education.count);​
 +  ​
 +  t_education.extend;​
 +  t_education(t_education.last) := p_add_education;​
 +  ​
 +  update teilnehmer set tln_education = t_education
 +    where tln_name = p_tln_name;
 +  ​
 +  if t_education.count <> 0 then
 +  for i in 1..t_education.last loop
 +    -- dbms_output.put_line(t_education(1)||'​ '|| t_education.count);​
 +    dbms_output.put_line(t_education(i));​
 +  end loop;
 +  end if;
 +  ​
 +  ​
 +END TEILNEHMER_EDUCATION;​
 +</​code>​
 +
 +
 <​code>​ <​code>​
 CREATE OR REPLACE ​ CREATE OR REPLACE ​
Line 16: Line 54:
 CREATE SEQUENCE ​ "​HR"​."​S";​ CREATE SEQUENCE ​ "​HR"​."​S";​
 </​code> ​   </​code> ​  
 +
 +<​code>​
 +PROCEDURE teilnehmer_ausbildung (
 +  p_name VARCHAR2,
 +  p_add_ausbildung VARCHAR2)
 +IS
 +    t_ausbildung ​  ​ausbildung := ausbildung();​
 +    c              INTEGER;
 +    f              BOOLEAN := FALSE;
 +    al             ​number;​
 +BEGIN
 +    SELECT ​  COUNT (id)
 +      INTO   c
 +      FROM   ​kursteilnehmer
 +     ​WHERE ​  name = p_name;
 +
 +    IF c = 0
 +    THEN
 +        INSERT INTO kursteilnehmer (id, name, ausbildung)
 +          VALUES ​  ​(s.NEXTVAL,​ p_name, ausbildung (p_add_ausbildung));​
 +    ELSE
 +        SELECT ​  ​ausbildung
 +          INTO   ​t_ausbildung
 +          FROM   ​kursteilnehmer
 +         ​WHERE ​  name = p_name;
 +
 +        FOR i IN 1 .. t_ausbildung.last
 +        LOOP
 +            IF t_ausbildung (i) = p_add_ausbildung
 +            THEN
 +                f := TRUE;
 +            END IF;
 +        END LOOP;
 +
 +        IF f = FALSE
 +        THEN
 +
 +            t_ausbildung.EXTEND;​
 +            t_ausbildung (t_ausbildung.last) := p_add_ausbildung;​
 +
 +            UPDATE ​  ​kursteilnehmer
 +               ​SET ​  ​ausbildung = t_ausbildung
 +             ​WHERE ​  name = p_name;
 +        END IF;
 +    END IF;
 +
 +   /* FOR i IN 1 .. t_ausbildung.LAST
 +    LOOP
 +        DBMS_OUTPUT.put_line (t_ausbildung (i));
 +    END LOOP;*/
 +END;                                                              -- Procedure
 +</​code>​
kurs/nested_table_als_column_type.1321524625.txt.gz · Last modified: 2014/09/10 21:22 (external edit)