user1682055
user1682055

Reputation: 103

mysql truncating error

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; #

This procedure is to insert random values starting from p_min to p_max with a total of p_loop_count values. But the problem is, there's an error around truncate:

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' 

I've searched online to check for the syntax for truncate, but I think I have this written correctly.

Suggestions? Thanks.

Upvotes: 0

Views: 846

Answers (1)

doublesharp
doublesharp

Reputation: 27609

The problem is not with TRUNCATE TABLE, the line before is missing a semicolon:

set v_loop_count := p_loop_count

Upvotes: 1

Related Questions