Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2011
    Posts
    10

    Answered: SYBASE cursor for read only is infinite loop

    Correct question is below
    Last edited by digioleg; 03-25-15 at 10:32.

  2. Best Answer
    Posted by Martijnvs

    "Why don't you use while (@@sqlstatus <> 2) instead?"


  3. #2
    Join Date
    Apr 2011
    Posts
    10

    Sybase cursor make infinit loop

    I have simple cursor on sybase 15.03
    DECLARE nosponcomplete insensitive CURSOR FOR
    SELECT p.ib_proj_id_c,
    p.clnt_rgn_id_c,
    c.clnt_lgl_n,
    rtrim(e.csv_em_last_n) + ', ' + rtrim(e.csv_em_first_n) + ' (' + e.csv_em_title_c + ')'
    FROM spd_tproj_ref p,
    spd_tproj_prod_xref pp,
    csv_tcsv_em_ref e,
    spd_tclnt_ref c,
    spd_vem_unit_ref eu
    WHERE p.ib_proj_id_c = pp.ib_proj_id_c
    AND p.clnt_id_c = c.clnt_id_c
    AND e.csv_em_id_c = eu.EmployeeID
    AND pp.ib_proj_stat_c = 'A'
    AND pp.ib_proj_stag_c not in ('L','C','D')
    AND p.clnt_spnsr_id_c = e.csv_em_id_c
    AND e.phr_em_stat_c = 'T'
    AND ISNULL(e.phr_last_work_dz,e.phr_em_end_dz) < dateadd(dd, -16, getdate())
    AND p.spd_divsn_id_c & 1 = 1
    FOR READ ONLY

    This cursoir has 260 records.
    But when I get in the loop
    while (1=1)
    begin
    fetch ...into

    if @@sqlstatus = 2 break
    end

    This cursor become infinite.
    Any idea why this is happened?

  4. #3
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    Why don't you use while (@@sqlstatus <> 2) instead?
    I'm not crazy, I'm an aeroplane!

  5. #4
    Join Date
    Apr 2011
    Posts
    10
    Almost perfect solution, but I had to use if @@sqlstatus <>0 break. It works.
    SYBASE 15.03 has strange behavior, which not in 15.7

    Thanks,
    Oleg

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •