Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

ストレージ・サブルーチン (2)

このセクションでは、インデックスによって名前を姓と名に分割します。次の 3 文は、他言語の文とはまったく異なります。文のうち 2 つのデータは添え字に格納されるため、イコール記号の右側には “何も” 指定しません。理由はツリー構造にあります。

例えば、姓、名、ID は添え字に格納されます。名前はアルファベット順に並べ替えられるため、データベースには姓、名の順でインデックスが作成されます。電話番号と誕生日のインデックスも同様に作成されます。グローバルの ^PersonI は 3 つの大きな枝に分かれ、各枝にインデックスがあるツリーになります。電話番号インデックスを構築する行は異なるため、電話番号の固有データを利用できます (ID は添え字に格納されません)。

複数のデータが入力されたと想定して配列のツリーを描画すると、配列のデータ構造が理解できます。これを実行するかどうかは別にして、管理ポータル ([システム・エクスプローラ] セクション) を使用して、システム, グローバル に移動し、2 つのグローバル (^PersonD^PersonI) を確認します。


public sub store()
    ' ...store subroutine continued from previous page...

    ' break name for storage in index
    ln = piece(name, ",", 1) : fn = piece(name, ",", 2)
 
    ' the next three statements store data in subscripts
    ' because of the automatic sorting of subscripts,
    ' this has the effect of building 3 indices: name, phone, and DOB
    ^PersonI( "Name", ln, fn, id) = "" ' store the name
    ^PersonI( "Phone", phone) = id     ' store the UNIQUE phone
    ^PersonI( "DOB", intdob, id) = ""  ' store the DOB
    println "...stored"                ' done
end sub
FeedbackOpens in a new tab