如何设置%Dictionary.StorageSQLMapDataDefinition.RetrievalCode?

时间:2015-03-05 14:36:33

标签: intersystems objectscript

我该怎么做:

<Data name="hyperlink">
<RetrievalCode>
<![CDATA[set res=""
    set colId=""
    for
    {
        set colId = $order( ^ohtest("mltab","main","Dta",{L4},colId) )
        quit:(colId = "")

        set indexTab = $g(^ohtest("mltab","main","Dta",{L4},colId,"Index"))
        if indexTab'="" {
            set res = res_"<hyperlinkIndexTab><colId>"_colId_"</colId><iTab>"_indexTab_"</iTab></hyperlinkIndexTab>"
        }
    }
    s {hyperlink}=res]]></RetrievalCode>
</Data>

编程?

我有:

            set global = "^ohtest"
            set iTab="main"

            //hyperlink
            set storData = ##class(%Dictionary.StorageSQLMapDataDefinition).%New()
            set storData.Name = "hyperlink"
            set storData.RetrievalCode = "<![CDATA[set res="""" set colId="""" for{set colId = $order( "_global_"(""mltab"","_iTab_",""Dta"",{L4},colId) ) quit:(colId = """") set indexTab = $g("_global_"(""mltab"","_iTab_",""Dta"",{L4},colId,""Index"")) if indexTab'="""" {set res = res_""<hyperlinkIndexTab><colId>""_colId_""</colId><iTab>""_indexTab_""</iTab></hyperlinkIndexTab>""}} s {hyperlink}=res]]>"
            do storMap.Data.Insert(storData)

但它不起作用。如何让生成上面提供的代码?

1 个答案:

答案 0 :(得分:2)

你的第一个问题是,将CDATA声明放在代码中。 Caché会在没有你的情况下添加它,然后你把iTab放在没有引号的地方。

    set global = "^ohtest"
    set iTab="main"

    set data=##class(%Dictionary.StorageSQLMapDataDefinition).%New()
    set data.Name="hyperlink"
    set code=""
    set code=code_"set res="""""_$c(13,10)
    set code=code_"set colId="""""_$c(13,10)
    set code=code_"for"_$c(13,10)
    set code=code_"{"_$c(13,10)
    set code=code_"  set colId = $order( "_global_"(""mltab"","""_iTab_""",""Dta"",{L4},colId) )"_$c(13,10)
    set code=code_"  quit:(colId = """")"_$c(13,10)
    set code=code_"  set indexTab = $g("_global_"(""mltab"","""_iTab_""",""Dta"",{L4},colId,""Index""))"_$c(13,10)
    set code=code_"  if indexTab'="""" {"_$c(13,10)
    set code=code_"    set res = res_""<hyperlinkIndexTab><colId>""_colId_""</colId><iTab>""_indexTab_""</iTab></hyperlinkIndexTab>"""_$c(13,10)
    set code=code_"  }"_$c(13,10)
    set code=code_"}"_$c(13,10)
    set code=code_"s {hyperlink}=res"_$c(13,10)
    set data.RetrievalCode=code
    do storMap.Data.Insert(data)