Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2015

    Unanswered: output error mensaje

    I would like do to the same ( this is Sybase ) but in DB2

    set procesado = 1
    where subscr_no = @old_subscr_no
    and subscr_no_resets = @old_subscr_no_resets
    and promocion = "${PROMOCION}"

    if (@@error = 0)
    commit tran

    raiserror 20001 "Error al marcar el cliente %1! - %2! como procesado.",
    @old_subscr_no, @old_subscr_no_resets
    rollback tran
    return 20001

    1) what is the equivalent to : raiserror
    2) what is the equivalent to : if (@@error = 0)

    Thank you

  2. #2
    Join Date
    Apr 2012
    Provided Answers: 17
    Quote Originally Posted by Gius View Post
    1) what is the equivalent to : raiserror
    2) what is the equivalent to : if (@@error = 0)

    Depending on your version of DB2, operating-system, and your db2-registry settings (which you should mention when your posts when asking for help):

    (if using oracle compatibiliy)

    also (for plain DB2)

    For testing result of SQL actions best to use Exception Handlers with or without Conditions. IBM provides examples of these for stored procedures both in the SAMPLES tree on your DB2 server (for Linux/Unix/Windows) and also in the on-line Knowledge centre.

    If your sproc defines a variable called SQLSTATE, then you can test this variable directly with an IF statement (often inside an exception handler) or in your main sproc code if you have a continue-handler for sqlerrors.

    Also useful is GET DIAGNOSTICS

Posting Permissions

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