Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts

    stored proc error handling

    Code:
    DECLARE EXIT HANDLER FOR SQLEXCEPTION SET i_result = -2;
    This does it, but anyway , since there is a bunch of sqls there, I can't see which failed. Could write a zilion of DECLARE EXIT HANDLER ..., but that would only tell me which error, not which sql.

    I imagined that the failed sql should be written to mysql-error-log.err file
    but there is nothing.

    Any tip appreciated.
    Last edited by BubikolRamios; 06-27-2011 at 10:38 AM.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,889
    Thanks
    79
    Thanked 4,421 Times in 4,386 Posts
    ?? Why can't you get both pieces of information??

    DECLARE EXIT HANDLER FOR SQLEXCEPTION SET problem = CONCAT( '2: ', someOtherVariable);

    That is, have the number tell you WHERE the error came from and a reason code of some code (maybe obtained from MySQL itself) tell you what the error is.

  • #3
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    so what you are saying:

    Code:
    DECLARE EXIT HANDLER FOR SQLEXCEPTION SET problem = CONCAT( '2: ', someOtherVariable);
    
    Select from ...;
    SET someOtherVariable= 'sql1';
    
    
    Select from ...;
    SET someOtherVariable= 'sql2';
    That gets confusing as soon you add/insert other sql-s into procedure.

    Figured that error sqls probably does not get into file, coz I have output of slow_sql_log set to table, and that somehow prevent logging error sqls to file. Or something .... Will try to figure out that first.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search


  •  

    Posting Permissions

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