SHARE
TWEET

Untitled

a guest Oct 15th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. -- rozdiel medzi tabulkou objektov a tabulkou ktora ma atribut ktory je objektovym typom
  4.  
  5. CREATE TABLE osoba OF t_osoba;
  6. DROP TABLE osoba;
  7. CREATE TABLE osoba_2(osoba_atr t_osoba);
  8. DROP TABLE osoba_2;
  9.  
  10. -- fcia order vracia -1 0 1
  11.  
  12. ALTER TYPE t_osoba
  13.     add map member FUNCTION utried RETURN VARCHAR2 cascade; -- ak podciarkuje 'map' to nie je problem
  14.     /
  15.    
  16. CREATE OR REPLACE TYPE BODY t_osoba AS
  17.     member PROCEDURE vypis_adresu IS
  18.         BEGIN
  19.             DBMS_OUTPUT.put_line( meno || ' ' || priezvisko);
  20.             adresa.vypis;
  21.         END vypis_adresu;
  22.     map member FUNCTION tried RETURN VARCHAR2 IS
  23.         BEGIN
  24.             RETURN priezvisko || ' ' || meno;
  25.         END tried;
  26. END;
  27. /
  28.  
  29.  
  30. SELECT z.osoba.priezvisko pr, z.osoba.meno m FROM zamestnanci z
  31. ORDER BY pr;
  32.  
  33. SELECT z.osoba.priezvisko pr, z.osoba.meno FROM zamestnanci z
  34. ORDER BY z.osoba;
  35.  
  36.  
  37. ALTER TYPE t_osoba DROP map member FUNCTION tried RETURN VARCHAR2 cascade;
  38.  
  39. ALTER TYPE t_osoba add ORDER member FUNCTION tried(osoba t_osoba) RETURN VARCHAR2 cascade;
  40.  
  41.  
  42.  
  43.  
  44. CREATE OR REPLACE TYPE BODY t_osoba AS
  45. member PROCEDURE vypis_adresu IS
  46.     BEGIN
  47.         DBMS_OUTPUT.put_line(meno || ' ' || priezvisko);
  48.         adresa.vypis;
  49.     END vypis_adresu;
  50. END;
  51.  
  52.  
  53. ORDER member FUNCTION tired(osoba t_osoba) RETURN NUMBER IS
  54. BEGIN
  55.     IF priezvisko || ' ' || meno < osoba.priezvisko  || ' ' || osoba.meno THEN
  56.         RETURN -1;
  57.     IF priezvisko || ' ' || meno > osoba.priezvisko  || ' ' || osoba.meno THEN
  58.         RETURN 1;    
  59.     ELSE
  60.         RETURN 0;
  61. END;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top