我用的数据库版本是5.1.30-community存储过程:
create procedure 'vartable' (in ename varchar(20))
begin
set @tname = concat('temp',ename);
prepare stmt from 'create table if not exists ?(
uid int,
uname varchar(20),
stime varchar(20),
etime varchar(20)
)
endsql:
call vartable('abc');出现的错误是:
错误代码:1064
you have an error in your SQL syntax: check the manual that corresponds to your MySQL server version for the right syntax to use near '? (uid int, uname varchar(20),stime varchar(20),etime varchar(20)' at line 1请求解决方法,谢谢
create procedure 'vartable' (in ename varchar(20))
begin
set @tname = concat('temp',ename);
prepare stmt from 'create table if not exists ?(
uid int,
uname varchar(20),
stime varchar(20),
etime varchar(20)
)
endsql:
call vartable('abc');出现的错误是:
错误代码:1064
you have an error in your SQL syntax: check the manual that corresponds to your MySQL server version for the right syntax to use near '? (uid int, uname varchar(20),stime varchar(20),etime varchar(20)' at line 1请求解决方法,谢谢
drop procedure if exists gf$$
CREATE
/*[DEFINER = { user | CURRENT_USER }]*/
PROCEDURE `zz`.`gf`(in ename varchar(20))
/*LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT 'string'*/
BEGIN
set @tname = concat('temp',ename);
set @ff=concat('create table if not exists ',@tname,' (uid int,uname varchar(20),stime varchar(20),etime varchar(20))');
select @ff;
prepare stmt1 from @ff;
EXECUTE stmt1;
END$$DELIMITER ;call gf('abc')