Ratiess
Ratiess

Reputation: 59

Code for modify DB?

I have no idea what kind of language of programming is this, or what the method does, any help?

It could be some code for modify some DB tables?

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

Upvotes: 0

Views: 115

Answers (1)

DAiMor
DAiMor

Reputation: 3205

yes, @duskwuff is right, it is Caché ObjectScript code.
And in this code, just make a copy properties for some object, from class Table.tInsTypeConfigurations with id pintInsTypeConf, to new object. It is not optimized code, but anyway, it should does this task.

Upvotes: 3

Related Questions