mysql 截断错误

标签 mysql syntax-error truncate

Create procedure a06_generate_data( p_loop_count int, 
                                    p_min int, 
                                    p_max int, 
                                    p_status char(1)) 
begin

declare v_max int;
declare v_min int;
declare v_loop_count int;

set v_max := p_max;
set v_min := p_min;
set v_loop_count := p_loop_count

-- clear the results table for each run
truncate table p_testbed.a06_rndData;
Repeat
   insert into p_testbed.a06_rndData (col_value)
        values (floor(v_min + rand()*(v_max – v_min)));
    set v_loop_count := v_loop_count – 1;
until v_loop_count <= 0 End Repeat;

select col_value p_testbed.a06_rndData ;


end; #

此过程是插入从 p_min 到 p_max 的随机值,总共有 p_loop_count 值。但问题是,截断时出现错误:

ERROR 1064 (42000): 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 'truncate table         p_testbed.a06_rndData;
    Repeat
       insert into p_testbed.a0' 

我在网上搜索过检查截断的语法,但我认为我写得正确。

建议?谢谢。

最佳答案

问题不在于 TRUNCATE TABLE,前面的行缺少分号:

set v_loop_count := p_loop_count

关于mysql 截断错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12557076/

相关文章:

php - MYSQL:查找多个ID匹配的行

mongoose - 最新版本的 mongoose-validator(1.3 或 1.3.2)给出了 SyntaxError

postgresql - TRUNCATE 145GB 表后,Postgres 没有释放空间给操作系统

javascript - 动态地使子容器在可变宽度父容器中获取可用宽度

mysql - #2014 - 命令不同步;你现在不能运行这个命令 SQL 子查询

jasper-reports - TextFied 表达式 : keep whitespaces at the end of a textfield

mysql - 多个表按行显示

mysql - Laravel 迁移 MySQL 外键

php - 多个sql查询运行问题

导入GLSL文件抛出错误 - Vite项目