SQL Procedure Question

  • How can I handle an error in sql procedure if the data that is being fetched

    by the cursor is being inserted into a table which doesn't allowed duplicates. How can I recover from this error and fetch the next records that the cursor has.

    Thanks in advance

  • This was removed by the editor as SPAM

  • Why not check if row exists in destination table before insert. This is what I do.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • You need to check the @@ERROR variable.

    Eg:

    
    
    fetch next from cur into @Var1
    while @@fetch_status = 0
    begin
    update table1 Set Field1 = @Var1
    if @@ERROR <> 0
    'issue message like "@Var1 could not be updated"
    fetch next from cur into @Var1
    end

    Thanks

    Phill Carter

    Edited by - phillcart on 11/19/2002 8:38:12 PM

    --------------------
    Colt 45 - the original point and click interface

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply