===========
螳豌伎 
===========

朱 螳豌伎  螳 る  蟆給...
襷 螳豌伎  螳 殊る るジ 豪語  谿瑚蠍 覦..

る狩伎 螳豌-蟯螻 一危覯伎 蟯襴 ろ..
讀, 螳豌伎 蟯螻 覈語 覈 讌伎 る 詞..
覓朱 蠍一 蟯螻 覈語...
螳豌企ゼ 蟯螻 覈語  蟆豌 ...
讀, 螳豌伎レ 譴螳 貂′, , ろ煙 螻牛る 蟆..
螳豌危朱 誤覃 蠏 螳豌企 覃, 煙 螳讌  給..
る 觀磯朱 蟆 ...願 る狩 蟯襴 覿覿 る9..蠏語曙 谿瑚蟲..
螳襷 伎手鍵 覃 企 觀磯ゼ 襷り 企ゼ 螳豌危朱 襷る 蟆..
朱 螳豌企ゼ  蟆覿 危エ覲願給..
れ覯 襷襴讌襷  覿覿 螳豌伎  螳 殊る 曙企 覓伎 襴語 覈襯手..
 襷蟆 豌 螳豌伎 螳 牛螻  覓語襯 覲伎覃 譬蟆給..
C++企 るジ 螳豌伎ロ 語企 伎 るる 伎蟾讌 一危覯伎るゼ 覃伎 殊 覈詩 讀蟇一 
殊 蟆..覓朱 螳豌危 一危覯伎るゼ 覿 觜手規...~

覦襦 れ旧 れ願讌..瑚磯 PL/SQL  (譯)企豢 PL/SQL...
覓碁 覃伎殊 谿瑚蟲...
讒...襷 覃伎 谿瑚朱..覃伎殊 伎 企 覲伎...手規 語 覿  襭れ 谿場覲伎語..
螳 譯朱 谿瑚 覓語手 給..

..蠏碁覃 螳豌-蟯螻 DBMS る狩伎  螳豌-蟯螻企手 讌 れ襦 企慨覃伎 危エ覺..
豈 豌 蠍一 覓 蠍瑚 企れ れ 襷企...~
願 譴 蟲...螳 襷れ伎 企慨蟆企..
螳豌伎  螳 る 螳 覦 蟆 企慨蟆 る 蠍覦 危願  蟆企 ..
轟 螳豌伎  螳 殊 覿  襯 企慨る 螳豌願 襾殊襯 讌 覈襯願企.. 

SQL> create type test_object as object(
  2  id varchar(4),
  3  name varchar(10));
  4  /

 焔給.

SQL> create table test_object_table of test_object;       -------------> 螳豌企ゼ 企 企...

企 焔給.

SQL> insert into test_object_table
  2  values (test_object('1111', 'scott'));               ---------------> 蟯螻 豌 レ  蟆 覲伎..

1 螳  襷れ伎給.

SQL> insert into test_object_table
  2  values (test_object('2222', 'yasi'));

1 螳  襷れ伎給.

SQL> select * from test_object_table;                 --------------> 螳豌危 伎 襷 企 蟯螻 螳 譟壱..
                                                                      願 覦襦 る狩伎 螳豌-蟯螻 DBMS 手 覿襯企 伎..
ID   NAME
---- ----------
1111 scott
2222 yasi

SQL> create table test_object_table2
  2  ( id_name test_object,                        --------------> test_object  燕 螳豌危...煙 覲伎譯手 給..
  3    group_id varchar2(10));                                     

企 焔給.

SQL> select * from test_object_table2;

 貊螳 給.

SQL> insert into test_object_table2
  2  values (test_object('1111', 'system'), 'sysoper');

1 螳  襷れ伎給.

SQL> insert into test_object_table2
  2  values (test_object('2222', 'yasi'), 'users');

1 螳  襷れ伎給.

SQL> select * from test_object_table2;

ID_NAME(ID, NAME)                        GROUP_ID
---------------------------------------- ----------
TEST_OBJECT('1111', 'system')            sysoper
TEST_OBJECT('2222', 'yasi')              users

SQL> select t.id_name.id as id,                   -----------> 螳豌伎 語伎  (.) 覯朱 譟壱螻 ...
  2         t.id_name.name as name,                            覦企...^^
  3         t.group_id as group_id
  4  from test_object_table2 t;

ID   NAME       GROUP_ID
---- ---------- ----------
1111 system     sysoper
2222 yasi       users

SQL> create or replace type test_object2 as object(
  2  id_name test_object,                             ---------->  燕 螳豌伎 轟煙 蠏碁襦 伎  るジ 螳豌企ゼ 燕....
  3  address varchar2(40));                                       
  4  /

 焔給.


~ 麹 覦... 願 牛覃伎 覓企 覩碁ゼ 蠎企...
願 覲伎 覿 蠏碁襴 螳...~
伎 螳 ′殊り 螳螻 覲旧″ 襯 覲願企..

SQL> CREATE OR REPLACE TYPE address AS OBJECT (
  2    street_1      VARCHAR2(40),
  3    street_2      VARCHAR2(40),
  4    city          VARCHAR2(40),
  5    state_abbr    VARCHAR2(2),
  6    zip_code      VARCHAR2(5),
  7    phone_number  VARCHAR2(10),
  8    MEMBER PROCEDURE ChangeAddress (                      -------------------> 覃蟾 
  9      st_1 IN VARCHAR2, st_2 IN VARCHAR2, cty IN VARCHAR2,
 10      state IN VARCHAR2, zip IN VARCHAR2),
 11    MEMBER FUNCTION getStreet (line_no IN number) RETURN VARCHAR2,
 12    MEMBER FUNCTION getCity RETURN VARCHAR2,
 13    MEMBER FUNCTION getStateAbbr RETURN VARCHAR2,
 14    MEMBER FUNCTION getPostalCode RETURN VARCHAR2,
 15    MEMBER FUNCTION getPhone RETURN VARCHAR2,
 16    MEMBER PROCEDURE setPhone (newPhone IN VARCHAR2)
 17  );
 18  /

 焔給.


address朱 螳豌危 燕給...
襦 襯 誤讌...襦 襴願  蟆 手係螻,  襴願  蟆 襷...
企 覃襯 燕 伎 燕 螳豌危  譟一 蠍  蟆伎...
れ 燕 蟆豌 覈語牡 燕 譯殊伎 ...
貉 觜る企Μ蟆 誤 蟆 煙...る狩伎 螳豌危 煙 1000螳蟾 螳讌 企..
蠏碁 覈語牡襯 燕 覲願企..

SQL> CREATE OR REPLACE TYPE address AS OBJECT (
  2    street_1      VARCHAR2(40),
  3    street_2      VARCHAR2(40),
  4    city          VARCHAR2(40),
  5    state_abbr    VARCHAR2(2),
  6    zip_code      VARCHAR2(5),
  7    phone_number  VARCHAR2(10),
  8    MEMBER PROCEDURE ChangeAddress (
  9      st_1 IN VARCHAR2, st_2 IN VARCHAR2, cty IN VARCHAR2,
 10      state IN VARCHAR2, zip IN VARCHAR2),
 11    MEMBER FUNCTION getStreet (line_no IN number) RETURN VARCHAR2,
 12    MEMBER FUNCTION getCity RETURN VARCHAR2,
 13    MEMBER FUNCTION getStateAbbr RETURN VARCHAR2,
 14    MEMBER FUNCTION getPostalCode RETURN VARCHAR2,
 15    MEMBER FUNCTION getPhone RETURN VARCHAR2,
 16    MEMBER PROCEDURE setPhone (newPhone IN VARCHAR2)
 17  );
 18  /

 焔給.

SQL> CREATE OR REPLACE TYPE BODY address AS
  2    MEMBER PROCEDURE ChangeAddress (
  3      st_1 IN VARCHAR2, st_2 IN VARCHAR2, cty IN VARCHAR2,
  4      state IN VARCHAR2, zip IN VARCHAR2) IS
  5    BEGIN
  6      IF (st_1 IS NULL) OR (cty IS NULL) OR
  7         (state IS NULL) OR (zip IS NULL)
  8         OR (upper(state) NOT IN ('AK','AL','AR','AZ','CA','CO',
  9                                  'CT','DC','DE','FL','GA','HI',
 10                                  'IA','ID','IL','IN','KS','KY',
 11                                  'LA','MA','MD','ME','MI','MN',
 12                                  'MO','MS','MT','NC','ND','NE',
 13                                  'NH','NJ','NM','NV','NY','OH',
 14                                  'OK','OR','PA','RI','SC','SD',
 15                                  'TN','TX','UT','VA','VT','WA',
 16                                  'WI','WV','WY'))
 17  OR (zip <> ltrim(to_char(to_number(zip),'09999'))) THEN
 18       RAISE_application_error(-20001,'The new Address is invalid.');
 19      ELSE
 20        street_1 := st_1;
 21        street_2 := st_2;
 22        city := cty;
 23        state_abbr := upper(state);
 24        zip_code := zip;
 25      END IF;
 26    END;
 27  
 28    MEMBER FUNCTION getStreet (line_no IN number)
 29      RETURN VARCHAR2 IS
 30    BEGIN
 31      IF line_no = 1 THEN
 32        RETURN street_1;
 33      ELSIF line_no = 2 THEN
 34        RETURN street_2;
 35      ELSE
 36        RETURN ' ';    --send back a blank.
 37      END IF;
 38    END;
 39  
 40    MEMBER FUNCTION getCity RETURN VARCHAR2 IS
 41    BEGIN
 42      RETURN city;
 43    END;
 44  
 45    MEMBER FUNCTION getStateAbbr RETURN VARCHAR2 IS
 46    BEGIN
 47      RETURN state_abbr;
 48    END;
 49  
 50    MEMBER FUNCTION getPostalCode RETURN VARCHAR2 IS
 51    BEGIN
 52      RETURN zip_code;
 53    END;
 54  
 55    MEMBER FUNCTION getPhone RETURN VARCHAR2 IS
 56    BEGIN
 57      RETURN phone_number;
 58    END;
 59  
 60    MEMBER PROCEDURE setPhone (newPhone IN VARCHAR2) IS
 61    BEGIN
 62      phone_number := newPhone;
 63    END;
 64  END;
 65  /

 覲碁語 焔給.


~ 麹 蠍語襷....伎 觜訣...
MEMBER PROCEDURE ChangeAddress  煙  覲蟆曙 り 襷 襦...
 螳螳 ル蟇磯 螳煙 一危 覓願屋煙 讌蠍  企語 れ願企..
螳螳 覃る  螳 襴危蠍 伎 焔 蟆れ...

る狩伎 螳豌危 煙 覃朱 蟆 伎ル 給...
願 蠏 螳豌危 語ろ伎るゼ 燕 ..
蠏 煙 覃 れ螻 螳 伎..

FUNCTION address(street_1 in varchar2, street_2 in varchar2, city in varchar2, state_abbr,.............) returns address

企 煙 覃  螳  螳豌企ゼ 覦...
煙   れ螻 螳 讌..

address_variable := address('101 Oak', '', 'Detroit', 'MI', '48223', '3135358886');


 覈語牡 れ 危エ覺..

MEMBER FUNCTION getPhone RETURN VARCHAR2 IS
    BEGIN
      RETURN phone_number;
    END;

煙 覦  覃... 覃襯 Accessor Method ...
朱朱 get企 企ゼ ..

蠏 覦  setPhone mutator Method朱 蟆...貊 覲企 蟆螻 螳 煙 讌 谿語^讌 給..
讀, 煙 讌 蟇企襴讌 螻 螳朱 蟇企襴 蟆...   

MEMBER PROCEDURE setPhone (newPhone IN VARCHAR2) IS
    BEGIN
      phone_number := newPhone;
    END;    
    
...蠏碁 企 覃襯 伎 螳豌危 語ろ伎るゼ 燕螻, 譟壱 覲願企..

SQL> set serveroutput on
SQL> 
SQL> --A PL/SQL block demonstrating the
SQL> --use of the address object.
SQL> DECLARE
  2    address_1   address;
  3    address_2   address;
  4    address_3   address;
  5  BEGIN
  6    --Instantiate a new address object named address_1,
  7    --and assign a copy of it to address_2.
  8    address_1 := address ('2700 Peerless Road','Apt 1',              -------------> address 煙 讌? address_1 襦 語ろ伎り ..
  9                          'Cleveland','TN','37312','4235551212');
 10    address_2 := address_1;
 11  
 12    --Change address #1
 13    address_1.ChangeAddress ('2800 Peermore Road','Apt 99',
 14                             'Detroit','MI','48823');                 --------------> ChangeAddress 襦襯 伎 語ろ伎るゼ 螳煙..
 15  
 16    --Instantiate a second object.
 17    address_3 := address ('2700 Eaton Rapids Road','Lot 98',
 18                          'Lansing','MI','48911','5173943551');
 19  
 20    --Now print out the attributes from each object.
 21    dbms_output.put_line('Attributes for address_1:');           -------------> 蠍磯磯 燕 語ろ伎るゼ 伎蟆 覲伎譯手鍵  讌..
 22    dbms_output.put_line(address_1.getStreet(1));                -------------> 螳豌危朱 燕伎  覃襯 ..螳豌伎 豌 覯朱...
 23    dbms_output.put_line(address_1.getStreet(2));
 24    dbms_output.put_line(address_1.getCity
 25                         || ' ' || address_1.getStateAbbr
 26                         || ' ' || address_1.getPostalCode);
 27    dbms_output.put_line(address_1.getPhone);
 28  
 29    dbms_output.put_line('-------------------------');
 30    dbms_output.put_line('Attributes for address_2:');
 31    dbms_output.put_line(address_2.getStreet(1));
 32    dbms_output.put_line(address_2.getStreet(2));
 33    dbms_output.put_line(address_2.getCity
 34                         || ' ' || address_2.getStateAbbr
 35                         || ' ' || address_2.getPostalCode);
 36    dbms_output.put_line(address_2.getPhone);
 37  
 38    dbms_output.put_line('-------------------------');
 39    dbms_output.put_line('Attributes for address_3:');
 40    dbms_output.put_line(address_3.street_1);
 41    dbms_output.put_line(address_3.street_2);
 42    dbms_output.put_line(address_3.city
 43                         || ' ' || address_3.state_abbr
 44                         || ' ' || address_3.zip_code);
 45    dbms_output.put_line(address_3.phone_number);
 46  END;
 47  /
Attributes for address_1:
2800 Peermore Road
Apt 99
Detroit MI 48823
4235551212
-------------------------
Attributes for address_2:
2700 Peerless Road
Apt 1
Cleveland TN 37312
4235551212
-------------------------
Attributes for address_3:
2700 Eaton Rapids Road
Lot 98
Lansing MI 48911
5173943551

PL/SQL 豌襴螳 朱 襭給.

瑚れ...~ 伎る所 企  觜企手 螳...
讌 蠏碁  れ..~
...
蠍郁讌 朱 螳 ″讌??

るジ 蟆 危エ覲願規 螳煙 讌 企...

SQL> CREATE TABLE employee
  2         (emp_id           INTEGER,
  3           emp_name      VARCHAR2(32),
  4           supervised_by      INTEGER,
  5           pay_rate               NUMBER(9,2),
  6           pay_type              CHAR);

企 焔給.

SQL> alter table employee
  2  add (home_address address);      ------------------> 螳豌危朱  貉殊 豢螳.

企 覲蟆暑給.

SQL> INSERT INTO employee
  2    (emp_id, emp_name,pay_rate,pay_type,home_address)
  3    VALUES (597,'Matthew Higgenbottom',120000,'S',
  4            address('101 Maple','','Mio','MI','48640','5173943551'));       --------> 一危 曙

1 螳  襷れ伎給.

SQL> 
SQL> COMMIT;

貉る 襭給.

SQL> 
SQL> DECLARE
  2    emp_home_address    address;           ---------------------> 螳豌危朱 覲 
  3  BEGIN
  4    emp_home_address := address('911 Pearl','Apt 2','Lewiston',
  5                                'MI','48645','5173363366');
  6    INSERT INTO employee
  7      (emp_id, emp_name,pay_rate,pay_type,home_address)
  8      VALUES (598, 'Raymond Gennick',55,'H',emp_home_address);
  9    COMMIT;
 10  END;
 11  /

PL/SQL 豌襴螳 朱 襭給.

SQL> SELECT emp_id, emp_name, home_address
  2    FROM employee
  3   WHERE home_address IS NOT null;

    EMP_ID EMP_NAME                         HOME_ADDRESS(STREET_1, STREET_2, CITY, STATE_ABBR, ZIP_CODE, PHONE_NUMBER)
---------- -------------------------------- --------------------------------------------------------------------------------
       597 Matthew Higgenbottom             ADDRESS('101 Maple', NULL, 'Mio', 'MI', '48640', '5173943551')
       598 Raymond Gennick                  ADDRESS('911 Pearl', 'Apt 2', 'Lewiston', 'MI', '48645', '5173363366')
       

る 企 蟶 螳給...
伎 螳煙 蟆 企慨蟆給...蠍磯蓋朱 PL/SQL 伎螳讌 る 曙給...

SQL> DECLARE
  2    emp_addr    address;
  3  BEGIN
  4    --Retrieve the object from the table
  5    SELECT home_address INTO emp_addr
  6      FROM employee
  7     WHERE emp_id = 597;
  8  
  9    --Use a mutator method to change the phone number.
 10    emp_addr.setPhone('3139830301');               --------------> 覡ろ危 覃襯 伎 螳煙..
 11  
 12    UPDATE employee
 13       SET home_address = emp_addr
 14     WHERE emp_id = 597;
 15  
 16    COMMIT;
 17  END;
 18  /

PL/SQL 豌襴螳 朱 襭給.

SQL> SELECT emp_id, emp_name, e.home_address.phone_number home_phone
  2    FROM employee e
  3   WHERE emp_id = 597;

    EMP_ID EMP_NAME                         HOME_PHONE
---------- -------------------------------- ----------
       597 Matthew Higgenbottom             3139830301
     
SQL> UPDATE employee e
  2     SET e.home_address  = address(e.home_address.street_1,
  3                         e.home_address.street_2, e.home_address.city,
  4                         e.home_address.state_abbr, e.home_address.zip_code,
  5                         '5173433333')
  6   WHERE emp_id = 598;

1  螳煙給.

SQL> COMMIT;

貉る 襭給.


襷讌襷 危エ覲 螳煙覓碁....豌 企蓋蟆り骸 觜訣...覯 伎  蟲覿伎手...
螳螳 譟壱, 螳煙, ,   給...
蠏碁覃 る狩伎 企至 螳豌企ゼ  螳螳 蟲覿 覦覯 螳企...
蟲覿 覦覯 螳 企 貉殊朱  螳豌伎 螳 煙 殊... 磯殊 企 螳 
螳豌伎  語ろ伎るゼ ロ ...
企蟆 蟲覿 覦覯襷蟲...る狩伎 Object idenfifier る狩伎 燕 螳朱 蟲覿 ..
 螳 螳螳 燕 螳豌企ゼ 一危覯伎 豌伎 螻蟆 蟲覲 蟆 ...

れ 螳豌危 企 襷 襯 危エ覲願企..

SQL> CREATE OR REPLACE TYPE building AS OBJECT (
  2    BldgName          VARCHAR2(40),
  3    BldgAddress       address,
  4    BldgMgr           INTEGER,
  5    MEMBER PROCEDURE  ChangeMgr (NewMgr IN INTEGER),
  6    ORDER MEMBER FUNCTION Compare (OtherBuilding IN building)      ---------> ORDER  覃る 襯 
  7        RETURN INTEGER
  8    );
  9  /

 焔給.


蠍一 覺 蟆  ORDER ...
伎蟾讌  るジ 蟆ろ螻 襾手螳 襴暑...
ORDER   螳豌企ゼ 觜蟲 貊襯 燕  蟆 伎..
 螳豌願 螳讌 覃 企 蟆  一  讌 螳襴る 螳 覦..
譴  危エ覲願規...朱 企郁企朱 蟆襷 螻 螻覃 襴 螳..

SQL> CREATE OR REPLACE TYPE BODY building AS
  2    MEMBER PROCEDURE  ChangeMgr(NewMgr IN INTEGER) IS
  3      BEGIN
  4        BldgMgr := NewMgr;
  5      END;
  6  
  7    ORDER MEMBER FUNCTION Compare (OtherBuilding IN building)
  8    RETURN INTEGER IS
  9        BldgName1     VARCHAR2(40);
 10        BldgName2     building.BldgName%TYPE;            ------------> '覲企 企企.貉殊企%TYPE'   螳給..
 11      BEGIN
 12        --Grab the two building names for comparison.
 13        --Make sure that we don't get messed up by leading/trailing
 14        --spaces or by case.
 15        BldgName1 := upper(ltrim(rtrim(BldgName)));         --------------->  螻給葦 覈 螻 覓語襦 豺伎 BldgName1 j規 企..
 16        BldgName2 := upper(ltrim(rtrim(OtherBuilding.BldgName)));
 17  
 18        --Return the appropriate value to indicate the order of
 19        --this object vs OtherBuilding.
 20        IF BldgName1 = BldgName2 THEN                ----------------->  螳 觜蟲襯  企語..
 21          RETURN 0;
 22        ELSIF BldgName1 < BldgName2 THEN
 23          RETURN -1;
 24        ELSE
 25          RETURN 1;
 26        END IF;
 27      END;
 28  END;
 29  /

 覲碁語 焔給.

SQL> CREATE TABLE buildings OF building;         ---------> 螳豌危 企 

企 焔給.

SQL> INSERT INTO buildings
  2    values (building('Victor Building',
  3            address('203 Washington Square',' ','Lansing',
  4                    'MI','48823',' '),
  5            597));

1 螳  襷れ伎給.

SQL> 
SQL> INSERT INTO buildings
  2    values (building('East Storage Shed',
  3            address('1400 Abbott Rd','','Lansing','MI','48823',''),
  4            598));

1 螳  襷れ伎給.

SQL> INSERT INTO buildings
  2    values (building('Headquarters Building',
  3            address('150 West Jefferson','','Detroit','MI','48226',''),
  4            599));

1 螳  襷れ伎給.

SQL> 
SQL> SELECT * from buildings;

BLDGNAME                                 BLDGADDRESS(STREET_1, STREET_2, CITY, STATE_ABBR, ZIP_CODE, PHONE_NUMBER) BLDGMGR
---------------------------------------- ------------------------------------------------------------------------- ----------
Victor Building                          ADDRESS('203 Washington Square', ' ', 'Lansing', 'MI', '48823', ' ')       597
East Storage Shed                        ADDRESS('1400 Abbott Rd', NULL, 'Lansing', 'MI', '48823', NULL)            598
Headquarters Building                    ADDRESS('150 West Jefferson', NULL, 'Detroit', 'MI', '48226', NULL)        599

SQL> COMMIT;

貉る 襭給. 


れ 螳豌危 企  蟆  るジ 襯 覲願給...
螳豌危 企 蟆 るジ 覦覯 VALUE朱 一一襯  蟆..
SQL> select value(e) from buildings e;

VALUE(E)(BLDGNAME, BLDGADDRESS(STREET_1, STREET_2, CITY, STATE_ABBR, ZIP_CODE, PHONE_NUMBER), BLDGMG
----------------------------------------------------------------------------------------------------
BUILDING('Victor Building', ADDRESS('203 Washington Square', ' ', 'Lansing', 'MI', '48823', ' '), 59
BUILDING('East Storage Shed', ADDRESS('1400 Abbott Rd', NULL, 'Lansing', 'MI', '48823', NULL), 598)
BUILDING('Headquarters Building', ADDRESS('150 West Jefferson', NULL, 'Detroit', 'MI', '48226', NULL

SQL> desc building
 企                                                                                                              ?      
 ---------------------------------------------------------------------------------------------------
 BLDGNAME                                                                                                                   VARCHAR2(40)
 BLDGADDRESS                                                                                                                ADDRESS
 BLDGMGR                                                                                                                    NUMBER(38)

METHOD
------
 MEMBER PROCEDURE CHANGEMGR
 語覈                                             蠍磯蓋 企/碁?
 ------------------------------ ----------------------- --------- --------
 NEWMGR                         NUMBER                  IN

METHOD
------
 ORDER MEMBER FUNCTION COMPARE RETURNS NUMBER
 語覈                                             蠍磯蓋 企/碁?
 ------------------------------ ----------------------- --------- --------
 OTHERBUILDING                  BUILDING                IN

SQL> 


れ 企 螳豌危 覓語 危エ覲願規 る狩伎  覓語 願屋 覦 危エ覲願給...
襯 る, 企 觜 1000覈  る, 螳  伎  1000螳 襴暑 building 螳豌願 蟆 ..
蟆郁記 覓 襷 覲企ゼ 螳蟆  蟆伎...
企壱 蟆 願屋蠍  る狩伎 る語  谿語^襷 ロ..谿語^ 煙 REF襯 ..
讀, 螳豌企ゼ  蟆  谿語^襷 る 詞..
る狩 蟯襴 覿覿 瑚 蟆伎..
谿語^襯 燕 覺...

SQL> ALTER TABLE employee
  2    ADD (emp_bldg    REF building);

企 覲蟆暑給.

 覲企 building 螳豌企ゼ  蟆  谿語^...讀, る狩伎 螳豌 覲襯 豌襴 REF DEREF 一一襯
る 蟆..
REF 一一 る語  る 覲襯 覦 SQL覓語 螻,
DEREF 一一 る 覲  谿語^ れ る碁ゼ 蟆 SQL覓語 .

REF一一 DEREF 一一襯  襯 一朱 覲願..

SQL> CREATE OR REPLACE PROCEDURE AssignEmpToBldg (
  2    EmpNumIn IN employee.emp_id%TYPE,
  3    BldgNameIn IN buildings.BldgName%TYPE
  4    ) AS
  5  BEGIN
  6    UPDATE employee
  7       SET emp_bldg = (SELECT REF(b)             -------------> REF一一 , buildings 企  螳豌伎  谿語^襷 .
  8                        FROM buildings B
  9                       WHERE BldgName = BldgNameIn)
 10     WHERE emp_id = EmpNumIn;
 11  
 12    --Raise an error if either the employee number or
 13    --building name is invalid.
 14    IF SQL%NOTFOUND THEN
 15      RAISE_application_error(-20000,'Employee ' || EmpNumIn
 16                             || ' could not be assigned to building '
 17                             || BldgNameIn);
 18    END IF;
 19  END;
 20  /

襦螳 焔給.

SQL> 
SQL> BEGIN
  2    AssignEmpToBldg (598,'Victor Building');
  3    AssignEmpToBldg (597,'East Storage Shed');
  4  END;
  5  /

PL/SQL 豌襴螳 朱 襭給.

SQL> CREATE OR REPLACE FUNCTION GetEmpBldgName (
  2    EmpNumIn IN employee.emp_id%TYPE
  3    ) RETURN VARCHAR2 AS
  4  TheBldg     building;
  5  BEGIN
  6    --Select the building object reference from this employee's record.
  7    SELECT DEREF(emp_bldg) INTO TheBldg                   -------------------> れ 螳豌伎  蟆 .讀, 谿語^襯 伎.
  8      FROM employee
  9     WHERE emp_id = EmpNumIn;
 10  
 11    IF TheBldg IS NULL THEN
 12      RETURN 'No Building Assigned';
 13    ELSE
 14      RETURN TheBldg.BldgName;
 15    END IF;
 16  END;
 17  /

螳 焔給.

SQL> 
SQL> BEGIN
  2    dbms_output.put_line(GetEmpBldgName(598));
  3    dbms_output.put_line(GetEmpBldgName(597));
  4  END;
  5  /
Victor Building
East Storage Shed

PL/SQL 豌襴螳 朱 襭給.

譯殊蟾蟆 覲手 企 蟆 谿語^襯 讌  谿語^伎襯  蟆企? ..
DEREF 一一 伎  る 谿語^ る狩伎 螳豌企ゼ 谿城  覈 覲願 
れ 給..蠏碁 蟯螻 企  譟一碁語 螳 語ろ 企 讌讌 
  蟆..

谿瑚襦 覃伎殊 覓碁 覲企 SELF 朱誤郁 ...願 覃襯 煙 蠍磯蓋螳.
語 螳豌伎 煙 谿語^ .

伎 螳豌危  蠍磯蠍 レ 襷讌襷 螳豌 觜蟲 蟆 企慨蟲....曙  覲願給..
螳豌 觜蟲 螳讌 覃襯 讌...
蠏 螳讌   危エ覲 ORDER MAP 覃..
襾殊 ORDER 伎 危エ覲願給..

 危エ覲  れ螻 螳 蟲覓語 給..

ORDER MEMBER FUNCTION Compare (OtherBuilding IN building) 
        RETURN INTEGER         

ORDER 曙企 Compare 螳  building 螳豌企ゼ るジ building 螳豌伎 觜蟲  語襦 豪 焔 
朱 蟆 襷伎朱 蟆..
螳 豬 語 る語 螳 伎伎 ..
ORDER SELF 朱誤一 覲 蟆豌 觜蟲 れ螻 螳 螳 覦..

覦螳           覩
------------     ------------------
     -1          SELF螳 語覲企 .
     0           SELF螳 語 螳.
     1           SELF螳 語覲企 .

れ ..

SQL> set serveroutput on
SQL> 
SQL> --A demonstration of the ORDER function.
SQL> DECLARE
  2    bldg_a      building;   --will be less than bldg_b
  3    bldg_b      building;
  4    bldg_b2     building;
  5    bldg_c      building;
  6  BEGIN
  7    --First, create four building objects.
  8    bldg_a := building('A Building',null,null);
  9    bldg_b := building('Another Building',null,null);
 10    bldg_b2 := building('Another Building',null,null);
 11    bldg_c := building('Cosmotology Research Lab',null,null);
 12  
 13    --Now compare the building objects and display the results;
 14    IF bldg_a < bldg_b THEN
 15      dbms_output.put_line('bldg_a < bldg_b');
 16    END IF;
 17  
 18    --These two have the same name, so should be equal.
 19    IF bldg_b = bldg_b2 THEN
 20      dbms_output.put_line('bldg_b = bldg_b2');
 21    END IF;
 22  
 23    IF bldg_c > bldg_b2 THEN
 24      dbms_output.put_line('bldg_c > bldg_b2');
 25    END IF;
 26  END;
 27  /
bldg_a < bldg_b
bldg_b = bldg_b2
bldg_c > bldg_b2

PL/SQL 豌襴螳 朱 襭給.

MAP 覃 ORDER     るジ 覦覯..
MAP  螳豌伎   蠏 伎 煙 磯  螳 螻壱..蠏碁Μ螻
蠏 螳  螳豌伎 るジ 螳豌(螳 螳豌危)襯 觜蟲 ...
MAP 蟆郁骸 れ 一危譴 伎伎 ..

- NUMBER
- DATE
- VARCHAR2

襷讌襷朱 る狩伎 螳豌危  曙 覲願規 襷豺蟆..

- 煙 讌讌 .    --------------> 豈  伎碁...伎..螳 蠍磯 煙 讌 襷伎..覓企 覯渚讌 ..
- PRIVATE 煙 讌讌 .
-   煙襯 讌讌 .
- 螳豌危 一危覯伎 譴 伎 覃, PL/SQL  襦 伎   .
- 朱 一危 煙朱   .
- 螳豌伎 煙 螳襯 豕 1000螳 伎  .