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?

演習 5 : データ入力と検索のオブジェクト・バージョンの記述

  1. 以下は、myBASdatentobj の新規 store サブルーチンです。

    
    public sub store()
    ' store the data
        dim yn, per
     
        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
     
        per = New BasTutorial.Person()
        with per
            .Name = name
            .Phone = phone
            .DOB = intdob
            .%Save()
        end with
        per = Nothing
        println "...stored" ' done
    end sub
    
  2. 以下は、myBASlookupobj の新規 load サブルーチンです。

    
    private sub load(id as %Integer)
    ' load a person into local variables
        dim per
        per = OpenId BasTutorial.Person(id)
        with per
            name = .Name
            phone = .Phone
            intdob = .DOB
        end with
        per = Nothing
    end sub
    
  3. 以下は、myBASlookupobj の新規 update サブルーチンです。

    
    private sub update(id As %Integer,_
                       newname As %String,_
                       newphone As %String,_
                       newintdob As %Integer)
    ' update ^PersonD and ^PersonI
        dim per
        per = OpenId BasTutorial.Person(id)
        with per
            .Name = newname
            .Phone = newphone
            .DOB = newintdob
            .%Save() ' this updates indices too, all within a transaction!
        end with
        per = Nothing
        println "...updated."
    end sub
    
  4. この行を変更して、myBASlookupobjgetphone サブルーチンを更新します。

    
        ph = traverse(^PersonI("Phone", origph), 1, loopid)
    

    以下のとおり変更します。

    
        ph = traverse(^PersonI("Phone", origph))
        if ph <> "" then loopid = traverse(^PersonI("Phone", ph, ""))
    
  5. 次にこの行を変更します。

    
        loopid = ^PersonI("Phone", origph)
    

    以下のとおり変更します。

    
        loopid = traverse(^PersonI("Phone", origph, ""))
    
  6. 次にこの行を変更します。

    
        ph = traverse(^PersonI("Phone", ph), 1, loopid)
    

    以下のとおり変更します。

    
        ph = traverse(^PersonI("Phone", ph))
        if ph <> "" then loopid = traverse(^PersonI("Phone", ph, ""))
    
FeedbackOpens in a new tab