mysql 读写分离怎么执行存储过程
发布网友
发布时间:2022-04-07 23:48
我来回答
共1个回答
热心网友
时间:2022-04-08 01:17
你创建一个存储过程C
先执行存储过程A,并得到返回值
再判断返回值执行存储过程B
例如:
mysql> \d //
mysql> create procere test(v_name char(20),out v_id int)
-> BEGIN
-> SELECT id into v_id from t1 WHERE name=v_name;
-> END;
-> //
mysql> create procere test1(v_id int,out v_name char(20))
-> BEGIN
-> SELECT name into v_name from t2 where id=v_id;
-> END;
-> //
mysql> create procere test2(inout v_name char(20))
-> BEGIN
-> DECLARE v_id int;
-> CALL test(v_name,v_id);
-> CALL test1(v_id,v_name);
-> END;
-> //
mysql> set @aa='xx‘//
Query OK, 0 rows affected (0.00 sec)
mysql> call test2(@aa) //
Query OK, 0 rows affected (0.01 sec)
mysql> select @aa//
+------+
| @aa |
+------+
| x2 |
+------+
1 row in set (0.00 sec)