Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My cursor suddenly stops ?. @@sqls

Status
Not open for further replies.

mjuell

Programmer
Jun 26, 2003
17
0
0
NO
My cursor suddenly stops ?.
@@sqlstatus = 2 when it stops
even though there are more rows to be fetched...

Anybody have an idea why ?..



Code:
set nocount on
go

    
    declare tell cursor for
    select driver_id, avtale_nr
    from GRUNNLAG_DRIVERFILER_AVTALE
    where info_is_deleted = 'N'
    and antall_Gsm > 0
    and comment is null
go


 declare
    @teller int,
    @avtale_nr       decimal(7,0) ,
    @driver_id numeric(12,0)

    open tell

    select @teller = 0

    fetch tell into @driver_id, @avtale_nr



    while @@sqlstatus <> 2
    begin
    
        if exists ( select 1
                    from s212replica..idms_bedakk b, s212replica..idms_kons k, s212replica..idms_konto o, 
                    s212replica..idms_tjlinje t, s212replica..idms_tjtilb i
                     where b.bedakk_avtale_nr = @avtale_nr
                    and b.bedakk_kontraktsnr = k.kontraktsnr
                    and k.neotjty_id  = 'GSM'
                    and k.konsesjon_til_dato = '4712-12-31'
                    and k.kontonr = o.kontonr
                    and o.konto_type in ( 'NO', 'RE', 'VA')
                    and o.konto_status = 'ÅP'
                    and o.statuskode <> 'N'
                    and t.fk_kons_tjlinje = k.p_k
                    and t.tjtilbt = '4712-12-31'
                    and t.tjkd  = i.tjkd
                    and i.tjkdbs like '%vip%'
                   )
        begin

            update grunnlag_Driverfiler_avtale
            set comment = &quot;vipnett&quot;
            where current of tell

        end

  


        select @teller = @teller +1
        
        if @teller%100 = 0
        begin
            select @teller
        end


        fetch tell into @driver_id, @avtale_nr
    end
go

close tell
deallocate cursor tell





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top