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?

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

myBASdatent のストレージ・プロシージャについて学習します。これまで、プロンプトに応答しデータを確認しました。ここでは、データを保存するオプションが必要です。次のスライドで示しているように、グローバル ^PersonD にデータを格納します。

一人一人に新しい一意の ID 番号を生成して、^PersonD の添え字として使用します。myBASdatent の初回実行時は ^PersonD が存在しないため、Increment() を使用して最初の ID を必ず 1 にする必要があります。これにより、“通常” の配列と同様の概念構造を持つ配列、つまり人のリストに ^PersonD が配置されます (ただし、実際はまだツリー構造です)。個人のレコードは、3 つの文字列データから成り立ちます。store サブルーチンは以下のとおりです。


public sub store()
' store the data
    dim yn, id, rec, ln, fn

    input "Store? (y/n): ", yn  ' see if user wants to store
    ' only go on if user says yes
    if ( yn <> "y" ) then
        println "...not stored."
        exit sub
    end if
 
    id = increment(^PersonD) ' generate a new id
    rec = name & "^" & phone & "^" & intdob ' concatenate data into a record
    ^PersonD( id ) = rec ' store the record

    ' ...remainder of store subroutine continued on next page...
end sub
FeedbackOpens in a new tab