Error while doing insert/update in MySql -


i want capture error occurring during inserting or updating data in mysql stored procedures.

when data updated in db, no of rows modified can checked know whether update or insert happened or not, if rows affected 0 (same data updated again), may not error condition.

i want capture insert/update failed. please share light on same

my sp below

delimiter $$      create procedure `sp_test`(             in param1 varchar(50),              in param2 varchar(50)         )         begin             if updatecount > 0                 update tbname set val = param1 con = param2;             else                 insert tbname set val = param1,con = param2;             end if;          end$$  delimiter ; 

i want track whether statements has executed or not.

i have added exception block below,

declare exit handler sqlexception begin     diagnostics condition 1 @sqlstate = returned_sqlstate,      @errno = mysql_errno, @text = message_text;     set @full_error = concat("error ", @errno, " (", @sqlstate, "): ", @text);     select @full_error; end; 

no getting errors. think fine scenario. if 1 find better answer please post here.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -