How to set %Dictionary.StorageSQLMapDataDefinition.RetrievalCode?

不打扰是莪最后的温柔 提交于 2019-12-12 01:52:27

问题


How can I do this:

<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>

programatically?

I have:

            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)

But it doesn't work. How to let generate code provided above?


回答1:


your first problem is, putting CDATA declaration in code. Caché will add it without you, and then you put iTab without quotes.

    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)


来源:https://stackoverflow.com/questions/28880384/how-to-set-dictionary-storagesqlmapdatadefinition-retrievalcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!