标签:char sel set form roc rda ranch dealloc prepare
CREATE DEFINER=`ggs`@`%` PROCEDURE `auto_create_salesman_location`()
BEGIN
DECLARE table_prefix VARCHAR(100);
DECLARE table_suffix BIGINT;
DECLARE table_name VARCHAR(100);
DECLARE sql_text VARCHAR(4000);
#异常捕获
DECLARE ER_TABLE_EXISTS_ERROR CONDITION for 1050;
DECLARE EXIT HANDLER FOR ER_TABLE_EXISTS_ERROR SELECT CONCAT(‘ERROR: ‘,table_name,‘已经存在‘);
SET table_prefix = ‘salesman_location‘;
SET table_suffix = DATE_FORMAT(DATE_ADD(curdate(), INTERVAL 1 DAY),‘%Y%m%d‘);
SET table_name = CONCAT(table_prefix,‘_‘,table_suffix);
set sql_text=CONCAT(
‘create table ‘,table_name,
‘(branch_code int(11) NOT NULL,
salesman_code int(11) NOT NULL,
telphone char(11) NOT NULL,
longitude varchar(20) DEFAULT NULL,
latitude varchar(20) DEFAULT NULL,
height double DEFAULT NULL,
location_create_time datetime DEFAULT NULL,
create_time datetime DEFAULT NULL,
KEY location_index (branch_code,salesman_code) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8‘
);
set @sql_pre=sql_text;
PREPARE sql_exec from @sql_pre;
EXECUTE sql_exec;
deallocate prepare sql_exec;
END
标签:char sel set form roc rda ranch dealloc prepare
原文地址:http://www.cnblogs.com/tonggc1668/p/7815034.html