Store Procedure with Transaction 交易功能

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
declare exit handler for sqlexception
begin
GET DIAGNOSTICS CONDITION 1
@error_code = RETURNED_SQLSTATE,
@error_msg = MESSAGE_TEXT;
rollback;
insert into log_sql (log) values(@error_msg);
RESIGNAL;
end;

set trello_id = JSON_UNQUOTE(JSON_EXTRACT(params, '$.trello_id'));
set trello_name = JSON_UNQUOTE(JSON_EXTRACT(params, '$.trello_name'));
set customer = JSON_UNQUOTE(JSON_EXTRACT(params, '$.customer'));

start transaction;
insert into proposal_trello (id, name, customer)
values (trello_id, trello_name, customer);
commit;