修改数据库代码?

时间:2016-10-18 19:43:17

标签: intersystems-cache objectscript

我不知道这是什么类型的编程语言,或者该方法有什么帮助?

可能是一些用于修改某些数据库表的代码?

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()
}

1 个答案:

答案 0 :(得分:3)

是的,@ duskwuff是对的,它是CachéObjectScript代码 在此代码中,只需为某个对象创建一个副本属性,从标识为Table.tInsTypeConfigurations的类pintInsTypeConf到新对象。它不是优化代码,但无论如何,它应该完成这项任务。