SAK }‘ŠÙ
Oracle PL/SQL •Ò3 - ƒRƒŒƒNƒVƒ‡ƒ“AtableAvarrayA錾AƒRƒŒƒNƒVƒ‡ƒ“ƒƒ\ƒbƒh
¡PL/SQL ƒRƒŒƒNƒVƒ‡ƒ“ EƒRƒŒƒNƒVƒ‡ƒ“‚Æ‚µ‚ÄA table ƒlƒXƒg‚µ‚½•\ varray ‰Â•ÏƒTƒCƒY”z—ñ ‚ª‚ ‚éB varray ‚Í“YŽš‚ÌãŒÀ‚ªŒˆ‚܂邪Atable ‚É‚ÍãŒÀ‚ª‚È‚¢B ‚Ü‚½Atable ‚ÍA’†”²‚Ìó‘Ô‚É‚Å‚«‚éB Etable ‚ÍASQL ‚Å‚àˆµ‚¦‚邪Aõˆø•t‚« table ‚͈µ‚¦‚È‚¢B (index by binary_integer Žw’è‚Ì‚à‚ÌB) ¡SQL ‚ł̃RƒŒƒNƒVƒ‡ƒ“錾 y’PƒŒ^z create type ttel as table of varchar2(12) / create type tadre as object ( name varchar2(40), adre varchar2(200), tel ttel ) / y’Pƒ—á varray Œ^ + oo4o ƒtƒB[ƒ‹ƒhŽQÆz create type ttadre as varray(3) of varchar2(20) / create table test ( item1 char(10), item2 char(10), adre ttadre ) / insert into test values ('a001', 'b002', ttadre('Ž–¼1', 'Ž–¼2', 'Ž–¼3') ) / '** oo4o varray Œ^ŽQÆ(“YŽš) Dim item As OraCollection Do Until rs.EOF Print rs(0) Print rs(1) Set item = rs.Fields("adre").Value For i = 1 To item.Size Print i & " - " & item(i) Next rs.MoveNext Loop y’Pƒ—á object Œ^ + oo4o ƒtƒB[ƒ‹ƒhŽQÆz create type tadre as object ( name varchar2(40), adre varchar2(200), tel varchar2(12) ) / create table test ( item1 char(10), item2 char(10), adre tadre ) / insert into test values ('a001', 'b002', tadre('Ž–¼1', 'ZŠ1', '“d˜b1') ) / '** oo4o object Œ^ŽQÆ(–¼‘O) Dim item As OraObject Do Until rs.EOF Print rs(0) Print rs(1) Set item = rs.Fields("adre").Value Print "name - " & item.Name Print "adre - " & item.adre Print "tel - " & item.tel rs.MoveNext Loop '** oo4o object Œ^ŽQÆ(“YŽš) Do Until rs.EOF Print rs(0) Print rs(1) Set item = rs.Fields(2).Value For i = 1 To item.Count Print i & " - " & item(i) Next rs.MoveNext Loop y•¡ŽG—á object Œ^A varray Œ^ + oo4o ƒtƒB[ƒ‹ƒhŽQÆz create type tadre as object ( name varchar2(40), adre varchar2(200), tel varchar2(12) ) / create type ttadre as varray(3) of tadre / create table test ( item1 char(10), item2 char(10), adre ttadre ) / insert into test values ('a001', 'b002', ttadre( tadre('Ž–¼1', 'ZŠ1', '“d˜b1'), tadre('Ž–¼2', 'ZŠ2', '“d˜b2'), tadre('Ž–¼3', 'ZŠ3', '“d˜b3') ) ) / '** oo4o varray Œ^Aobject Œ^ŽQÆ(–¼‘O) Do Until rs.EOF Print rs(0) Print rs(1) Set item = rs.Fields("adre").Value For i = 1 To item.Size Set item2 = item(i) For j = 1 To item2.Count Print i & " - name - " & item2.Name Print i & " - adre - " & item2.adre Print i & " - tel - " & item2.tel Next Next rs.MoveNext Loop '** oo4o varray Œ^Aobject Œ^ŽQÆ(“YŽš) Do Until rs.EOF Print rs(0) Print rs(1) Set item = rs.Fields(2).Value For i = 1 To item.Size Set item2 = item(i) For j = 1 To item2.Count Print i & ", " & j & " - " & item2(j) Next Next rs.MoveNext Loop ¡ƒRƒŒƒNƒVƒ‡ƒ“錾 declare type ttel is table of varchar2(12); a ttel; begin a := ttel('123-456-7890', '123-456-7890', '123-456-7890'); a(1) := '100'; end; / declare type ttel is varray(3) of varchar2(12); a ttel; begin a := ttel('123-456-7890', '123-456-7890', '123-456-7890'); a(1) := '100'; end; / declare type tjcno is table of Žó’m.Žó’”Ô†%type; jcno tjcno; cursor cu is select * from “¾ˆÓæm; type tkrec is table of cu%rowtype; begin jcno := tjcno('123456-001', '123456-001', '123456-001'); jcno(1) := '100'; end; / declare type ttest is record ( item1 varchar2(20), item2 varchar2(20), item3 varchar2(20) ); type tttest is varray(2) of ttest; a tttest; begin a := tttest(); end; / declare type ta is varray(10) of varchar2(10); type ttest is record ( item1 varchar2(20), item2 varchar2(20), item3 ta ); a ttest; begin a.item3 := ta(); end; / ¡•s‰Â”\‚È錾 EtableA‚Ü‚½‚ÍAvarray ‚ðX‚É tableA‚Ü‚½‚ÍAvarray ‚Ɋ܂߂邱‚Æ‚Ío —ˆ‚È‚¢B(SQL ‚Ì create type ... as object ‚ÍŠÜ‚ß‚ç‚ê‚éB) declare type ttest is table of varchar2(10); type tttest is varray(2) of ttest; a tttest; begin a := tttest(); end; / declare type ta is varray(10) of varchar2(10); type ttest is record ( item1 varchar2(20), item2 varchar2(20), item3 ta ); type tttest is varray(2) of ttest; a tttest; begin a := tttest(); end; / ¡ƒRƒŒƒNƒVƒ‡ƒ“ƒƒ\ƒbƒh ƒRƒŒƒNƒVƒ‡ƒ“–¼.exists(“YŽš) “YŽš‚ª‘¶Ý‚·‚ê‚Î TRUE ƒRƒŒƒNƒVƒ‡ƒ“–¼.count —v‘f” ƒRƒŒƒNƒVƒ‡ƒ“–¼.limit Å‘å—v‘f” (table ‚ÍANULL ‚ª•Ô‚é) ƒRƒŒƒNƒVƒ‡ƒ“–¼.first Ŭ“YŽš ƒRƒŒƒNƒVƒ‡ƒ“–¼.last Å‘å“YŽš ƒRƒŒƒNƒVƒ‡ƒ“–¼.prior(n —v‘f) n —v‘f‘O‚Ì“YŽš ƒRƒŒƒNƒVƒ‡ƒ“–¼.next(n —v‘f) n —v‘fŽŸ‚Ì“YŽš ƒRƒŒƒNƒVƒ‡ƒ“–¼.extend(n —v‘f) n —v‘f’ljÁ (table ‚Ì‚Ý) ƒRƒŒƒNƒVƒ‡ƒ“–¼.extend(n —v‘f, “YŽš) “YŽš‚Ì—v‘f‚ð n —v‘fƒRƒs[ (table ‚Ì‚Ý) ƒRƒŒƒNƒVƒ‡ƒ“–¼.trim(n —v‘f) Ōォ‚ç n —v‘fíœ (table ‚Ì‚Ý) ƒRƒŒƒNƒVƒ‡ƒ“–¼.delete(“YŽš) “YŽš‚Ì—v‘f‚ðíœ (table ‚Ì‚Ý) ¡Oracle PL/SQL •ÒŽ‘—¿
¡SQL Šî‘bŽÀ’n•ÒŽ‘—¿
¡SQL Šî‘b•ÒŽ‘—¿
¡SQL ƒ`ƒ…[ƒjƒ“ƒO•ÒŽ‘—¿
¡PostgreSQL •ÒAJAVA ServletAJSP •ÒŽ‘—¿
¡MySQL •ÒŽ‘—¿