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)

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

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

store()  [name, phone, intdob]
   ; store the data
   {
   read !, "Store? (y/n): ", yn                 ; see if user wants to store
   if ( yn '= "y" ) {                           ; only go on if user says yes
       write "...not stored."
       quit
      }

   set id = $increment( ^PersonD )              ; use $increment to generate a new ID
   set rec = name _ "^" _ phone _ "^" _ intdob  ; concatenate data into a record
   set ^PersonD( id ) = rec                     ; store the record
   
   ; ...remainder of store subroutine continued on next page...
   }
FeedbackOpens in a new tab