2,209
社区成员
发帖
与我相关
我的任务
分享
mysql> select * from t5;
+------+----------------------+
| id | c1 |
+------+----------------------+
| 1 | 2008-12-31按排期交货 |
| 2 | 2008-12-31????? |
| 3 | 2008-12-31????? |
| 4 | 2008-12-31????? |
| 11 | 111 |
+------+----------------------+
5 rows in set (0.00 sec)
mysql> delimiter //
mysql> create procedure p(in a char(15))
-> begin
-> set @st = concat('insert into ',a,'(id) values (9)');
-> PREPARE stmt1 FROM @st;
-> EXECUTE stmt1 ;
-> end;
-> //
Query OK, 0 rows affected (0.16 sec)
mysql> delimiter ;
mysql> call p('t5');
Query OK, 1 row affected (0.05 sec)
mysql> select * from t5;
+------+----------------------+
| id | c1 |
+------+----------------------+
| 1 | 2008-12-31按排期交货 |
| 2 | 2008-12-31????? |
| 3 | 2008-12-31????? |
| 4 | 2008-12-31????? |
| 11 | 111 |
| 9 | NULL |
+------+----------------------+
6 rows in set (0.00 sec)
mysql>
mysql> PREPARE stmt1 FROM 'SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse';
mysql> SET @a = 3;
mysql> SET @b = 4;
mysql> EXECUTE stmt1 USING @a, @b;