Реферат: Как сделать двунаправленный запрос
s ascSelect="select ID, Name from NameList order by ID ASC"
s descSelect="select ID, Name from NameList order by ID DESC"
S ok=##class(%DynamicQuery).SQLPrepare(.descHandle,descSelect)
S ok=##class(%DynamicQuery).SQLExecute(.descHandle)
s descClose=descHandle
S ok=##class(%DynamicQuery).SQLPrepare(.ascHandle,ascSelect)
S ok=##class(%DynamicQuery).SQLExecute(.ascHandle)
s State=$li(ascHandle,1)
s ascClose=ascHandle
; идемна 4 шагавперед
s $li(ascHandle,1)=State
w "4 steps forward",!
f i=1:1:4 d
. d ##class(%DynamicQuery).SQLFetch(.ascHandle,.Row,.AtEnd)
. q:(AtEnd=1)!(Row="")
. s ID=$li(Row,1)
. s Name=$li(Row,2)
. w "ID="_ID_", Name="_Name,!
s State=$li(ascHandle)
; возвращаемся на 2 шага назад
s $li(descHandle,1)=State
w "2 steps backward",!
f i=1:1:2 d
. d ##class(%DynamicQuery).SQLFetch(.descHandle,.Row,.AtEnd)
. q:(AtEnd=1)!(Row="")
. s ID=$li(Row,1)
. s Name=$li(Row,2)
. w "ID="_ID_", Name="_Name,!
s State=$li(descHandle)