fetch first from @sndCur into @tmpCompNo,@tmpCompName

解决方案 »

  1.   

    FETCH
    从 Transact-SQL 服务器游标中检索特定的一行。语法
    FETCH
            [ [ NEXT | PRIOR | FIRST | LAST
                    | ABSOLUTE { n | @nvar }
                    | RELATIVE { n | @nvar }
                ] 
                FROM
            ] 
    { { [ GLOBAL ] cursor_name } | @cursor_variable_name } 
    [ INTO @variable_name [ ,...n ] ]参数
    NEXT返回紧跟当前行之后的结果行,并且当前行递增为结果行。如果 FETCH NEXT 为对游标的第一次提取操作,则返回结果集中的第一行。NEXT 为默认的游标提取选项。PRIOR返回紧临当前行前面的结果行,并且当前行递减为结果行。如果 FETCH PRIOR 为对游标的第一次提取操作,则没有行返回并且游标置于第一行之前。FIRST返回游标中的第一行并将其作为当前行。LAST返回游标中的最后一行并将其作为当前行。...
      

  2.   

    set @firCur=Cursor Local Static For
    select sortNo,sortName from pluSort
    set @sndCur=Cursor Local Scroll For
    select comNo,comName from comInfo where parent=@compNo
    open @sndCuropen @firCur
    fetch Next From @firCur into @sortNo,@sortNamewhile(@@fetch_status=0)
    begin
    fetch Next From @sndCur into @tmpCompNo,@tmpCompName
    while(@@fetch_Status=0)
    begin
                        .....
               fetch Next From @sndCur into @tmpCompNo,@tmpCompName
             end
             fetch next from @firCur into @sortNo,@sortName
    endclose @sndCur
    deallocate @sndCur
    Clsoe @firCur
    deallocate @firCur
      

  3.   


    set @firCur=Cursor Local Static For
    select sortNo,sortName from pluSort
    set @sndCur=Cursor Local Scroll For
    select comNo,comName from comInfo where parent=@compNo
    open @sndCuropen @firCur
    fetch Next From @firCur into @sortNo,@sortNamewhile(@@fetch_status=0)
    begin
             fetch First From @sndCur into @tmpCompNo,@tmpCompName
    while(@@fetch_Status=0)
    begin
                        .....
               fetch Next From @sndCur into @tmpCompNo,@tmpCompName
             end
             fetch next from @firCur into @sortNo,@sortName
    endclose @sndCur
    deallocate @sndCur
    Clsoe @firCur
    deallocate @firCur