2016-10-18 3 views
0

私はどのような種類のプログラミングがこれであるのか、どのような方法が役立つのか分かりません。DBを変更するコードはありますか?

一部のDBテーブルを変更するコードがありますか?

ClassMethod CreateNewConfiguration(pintInsTypeConf As %Integer) As %Integer 
{ 
    Set objRecord = ##class(Table.tInsTypeConfigurations).%OpenId(pintInsTypeConf) 
    Set objNewRecord = ##class(Table.tInsTypeConfigurations).%New() 

    Set objClassDef = ##class(%Dictionary.ClassDefinition).%OpenId("Table.tInsTypeConfigurations") 

    Set intTotal = objClassDef.Properties.Count() 
    For intCount = 1:1:intTotal 
    { 
     If (((objClassDef.Properties.GetAt(intCount).Relationship = 0) && 
      (objClassDef.Properties.GetAt(intCount).Calculated = 0)) || 
      ((objClassDef.Properties.GetAt(intCount).Relationship = 1) && 
      (objClassDef.Properties.GetAt(intCount).Cardinality = "one"))) 
     { 
      Set strName = objClassDef.Properties.GetAt(intCount).Name 

      Set $zobjproperty(objNewRecord,strName) = $zobjproperty(objRecord,strName) 
     } 
    } 

    Set objNewRecord.Name = objNewRecord.rInstrumentTypes.%Id() _ " Config B “ 
    Set intResult = objNewRecord.%Save() 
    If ((intResult '= 1) || ($ZERROR '= "")) 
    { 
     Quit 0 
    } 

    Quit objNewRecord.%Id() 
} 

答えて

3

はい、@duskwuffは正しく、CachéObjectScriptコードです。
そして、このコードでは、あるオブジェクトのコピープロパティを、Table.tInsTypeConfigurationsのIDがpintInsTypeConfの新しいオブジェクトにコピーするだけです。それは最適化されたコードではありませんが、とにかく、この作業を行う必要があります。

関連する問題