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?

演習 4 : ストレージ・プロシージャの追加

  1. スタジオを開始し、mydatent ルーチンを開きます。終了したルーチンも、datent.mac として SAMPLES ネームスペースで記述できます。

  2. main ルーチンを編集します。display プロシージャの後、store プロシージャを呼び出します。

    
        do display()
        do store()
    
  3. 電話番号がインデックスに既存するかどうかをチェックするため、既定のエリア・コードを追加する行の後、$$validPhone 関数に If 文を追加します。

    
        set:(phone?3n1"-"4n) phone = "617-" _ phone ; add default area code
        if $data( ^PersonI( "Phone", phone)) {
            write !, "Phone number in use"
            quit 0
        }
        else {
            quit phone 
        }
    
  4. 新規の 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
    
      set ln = $piece(name, ",", 1),
          fn = $piece(name, ",", 2)                ; break name for storage in index
    
      /* 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 */
      set ^PersonI( "Name", ln, fn, id) = ""       ; store the name
      set ^PersonI( "Phone", phone) = id           ; store the UNIQUE phone
      set ^PersonI( "DOB", intdob, id) = ""        ; store the DOB
      write "...stored"                            ; done
     }
    
  5. 何人かを格納し、管理ポータルでグローバルを表示します。

FeedbackOpens in a new tab