Quantcast
Channel: Toad for MySQL
Viewing all articles
Browse latest Browse all 1315

Forum Post: Error by debugging stored procedure

$
0
0
Hi Toad, Today I tried to debug a stored procedure on MariaDB. There comes up a database error whch shows me that the internal code (automatically created by toad before debugging starts) fails. I copied the code into a text editor and splitted the code in lines. The corresponding lines are marked red and bold. --> begin of my code CREATE PROCEDURE questdebug.6c476170dc7e0dcd5b6c762c6a92138ab54df03fimpl(IN p_id BIGINT, IN p_level INT(4), IN p_url VARCHAR(512), IN p_process_flag INT(2), IN p_home_id BIGINT, OUT p_return BIGINT) BEGIN DECLARE v_error TINYINT DEFAULT 0; DECLARE v_error_message VARCHAR(512); BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT; IF @errno = 1062 THEN # duplicate key -> go ahead SET v_error_message = CONCAT('WARNING ', @errno, ' (', @sqlstate, '): ', @text); CALL crawler.p_create_url_log(p_id, 'PROCEDURE', 'p_create_url_pages', v_error_message, CURRENT_TIMESTAMP(6), @out_return); SET p_return = 0; ELSE -- -------------- -- logging error -- -------------- SET v_error_message = CONCAT('ERROR ', @errno, ' (', @sqlstate, '): ', @text); CALL crawler.p_create_url_log(p_id, 'PROCEDURE', 'p_create_url_pages', v_error_message, CURRENT_TIMESTAMP(6), @out_return); SET p_return = p_id; CALL questsoftware.DEBUGSET('p_id','P',p_id); CALL questsoftware.DEBUGSET('p_level','P',p_level); CALL questsoftware.DEBUGSET('p_url','P',p_url); CALL questsoftware.DEBUGSET('p_process_flag','P',p_process_flag); CALL questsoftware.DEBUGSET('p_home_id','P',p_home_id); CALL questsoftware.DEBUGSET('p_return','P',p_return); CALL questsoftware.DEBUGSET('v_error','L',v_error); CALL questsoftware.DEBUGSET('v_error_message','L',v_error_message); CALL questsoftware.DEBUGTRACE('PROCEDURE','crawler','p_create_url_pages',30); END IF; CALL questsoftware.DEBUGSET('p_id','P',p_id); CALL questsoftware.DEBUGSET('p_level','P',p_level); CALL questsoftware.DEBUGSET('p_url','P',p_url); CALL questsoftware.DEBUGSET('p_process_flag','P',p_process_flag); CALL questsoftware.DEBUGSET('p_home_id','P',p_home_id); CALL questsoftware.DEBUGSET('p_return','P',p_return); CALL questsoftware.DEBUGSET('v_error','L',v_error); CALL questsoftware.DEBUGSET('v_error_message','L',v_error_message); CALL questsoftware.DEBUGTRACE('PROCEDURE','crawler','p_create_url_pages',31); END CALL questsoftware.DEBUGSET('p_id','P',p_id); CALL questsoftware.DEBUGSET('p_level','P',p_level); CALL questsoftware.DEBUGSET('p_url','P',p_url); CALL questsoftware.DEBUGSET('p_process_flag','P',p_process_flag); CALL questsoftware.DEBUGSET('p_home_id','P',p_home_id); CALL questsoftware.DEBUGSET('p_return','P',p_return); CALL questsoftware.DEBUGSET('v_error','L',v_error); CALL questsoftware.DEBUGSET('v_error_message','L',v_error_message); CALL questsoftware.DEBUGTRACE('PROCEDURE','crawler','p_create_url_pages',31) ;; # initialize return code SET p_return = 0; --> end of my code The END statement is the END of my DECLARE EXIT HANDLER ..... normally it ends with a ';' -> but here the semicolon is missing. But in my source it is available. I have seent that the debug code was moved directly behind the END, so the last line of the debug code ends with an double semicolon ';;'. This causes the error and I found no solution to handle this error. By the way: Without debugging the procedure runs without error. Any ideas? Thanks. Kind regards Michael Here is the original code from error message: CREATE PROCEDURE questdebug.6c476170dc7e0dcd5b6c762c6a92138ab54df03fimpl(IN p_id BIGINT, IN p_level INT(4), IN p_url VARCHAR(512), IN p_process_flag INT(2), IN p_home_id BIGINT, OUT p_return BIGINT) BEGIN DECLARE v_error TINYINT DEFAULT 0; DECLARE v_error_message VARCHAR(512); BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT; IF @errno = 1062 THEN # duplicate key -> go ahead SET v_error_message = CONCAT('WARNING ', @errno, ' (', @sqlstate, '): ', @text); CALL crawler.p_create_url_log(p_id, 'PROCEDURE', 'p_create_url_pages', v_error_message, CURRENT_TIMESTAMP(6), @out_return); SET p_return = 0; ELSE -- -------------- -- logging error -- -------------- SET v_error_message = CONCAT('ERROR ', @errno, ' (', @sqlstate, '): ', @text); CALL crawler.p_create_url_log(p_id, 'PROCEDURE', 'p_create_url_pages', v_error_message, CURRENT_TIMESTAMP(6), @out_return); SET p_return = p_id; CALL questsoftware.DEBUGSET('p_id','P',p_id);CALL questsoftware.DEBUGSET('p_level','P',p_level);CALL questsoftware.DEBUGSET('p_url','P',p_url);CALL questsoftware.DEBUGSET('p_process_flag','P',p_process_flag);CALL questsoftware.DEBUGSET('p_home_id','P',p_home_id);CALL questsoftware.DEBUGSET('p_return','P',p_return);CALL questsoftware.DEBUGSET('v_error','L',v_error);CALL questsoftware.DEBUGSET('v_error_message','L',v_error_message);CALL questsoftware.DEBUGTRACE('PROCEDURE','crawler','p_create_url_pages',30);END IF; CALL questsoftware.DEBUGSET('p_id','P',p_id);CALL questsoftware.DEBUGSET('p_level','P',p_level);CALL questsoftware.DEBUGSET('p_url','P',p_url);CALL questsoftware.DEBUGSET('p_process_flag','P',p_process_flag);CALL questsoftware.DEBUGSET('p_home_id','P',p_home_id);CALL questsoftware.DEBUGSET('p_return','P',p_return);CALL questsoftware.DEBUGSET('v_error','L',v_error);CALL questsoftware.DEBUGSET('v_error_message','L',v_error_message);CALL questsoftware.DEBUGTRACE('PROCEDURE','crawler','p_create_url_pages',31); ENDCALL questsoftware.DEBUGSET('p_id','P',p_id);CALL questsoftware.DEBUGSET('p_level','P',p_level);CALL questsoftware.DEBUGSET('p_url','P',p_url);CALL questsoftware.DEBUGSET('p_process_flag','P',p_process_flag);CALL questsoftware.DEBUGSET('p_home_id','P',p_home_id);CALL questsoftware.DEBUGSET('p_return','P',p_return);CALL questsoftware.DEBUGSET('v_error','L',v_error);CALL questsoftware.DEBUGSET('v_error_message','L',v_error_message);CALL questsoftware.DEBUGTRACE('PROCEDURE','crawler','p_create_url_pages',31) ;; # initialize return code SET p_return = 0; -- ------------- -- insert record -- ------------- CALL questsoftware.DEBUGSET('p_return','P',p_return);CALL questsoftware.DEBUGSET('p_id','P',p_id);CALL questsoftware.DEBUGSET('p_level','P',p_level);CALL questsoftware.DEBUGSET('p_url','P',p_url);CALL questsoftware.DEBUGSET('p_process_flag','P',p_process_flag);CALL questsoftware.DEBUGSET('p_home_id','P',p_home_id);CALL questsoftware.DEBUGSET('v_error','L',v_error);CALL questsoftware.DEBUGSET('v_error_message','L',v_error_message);CALL questsoftware.DEBUGTRACE('PROCEDURE','crawler','p_create_url_pages',39);INSERT INTO crawler.t_url_pages(id, url_level, url, process_flag, id_home_url) VALUES (p_id, p_level, p_url, p_process_flag, p_home_id); CALL questsoftware.DEBUGSET('p_id','P',p_id);CALL questsoftware.DEBUGSET('p_level','P',p_level);CALL questsoftware.DEBUGSET('p_url','P',p_url);CALL questsoftware.DEBUGSET('p_process_flag','P',p_process_flag);CALL questsoftware.DEBUGSET('p_home_id','P',p_home_id);CALL questsoftware.DEBUGSET('p_return','P',p_return);CALL questsoftware.DEBUGSET('v_error','L',v_error);CALL questsoftware.DEBUGSET('v_error_message','L',v_error_message);CALL questsoftware.DEBUGTRACE('PROCEDURE','crawler','p_create_url_pages',40);END; CALL questsoftware.DEBUGSET('p_id','P',p_id);CALL questsoftware.DEBUGSET('p_level','P',p_level);CALL questsoftware.DEBUGSET('p_url','P',p_url);CALL questsoftware.DEBUGSET('p_process_flag','P',p_process_flag);CALL questsoftware.DEBUGSET('p_home_id','P',p_home_id);CALL questsoftware.DEBUGSET('p_return','P',p_return);CALL questsoftware.DEBUGSET('v_error','L',v_error);CALL questsoftware.DEBUGSET('v_error_message','L',v_error_message);CALL questsoftware.DEBUGTRACE('PROCEDURE','crawler','p_create_url_pages',42);END;

Viewing all articles
Browse latest Browse all 1315

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>