Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8575311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:39:55+00:00 2026-06-11T19:39:55+00:00

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

  • 0
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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:39:56+00:00Added an answer on June 11, 2026 at 7:39 pm

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

    set v_loop_count := p_loop_count
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

CREATE procedure St_Proc_GetUserReportforCurrentDayTask @userID int as Begin set NoCount on; DECLARE @TODAY DATE SET
Given this : delimiter // create procedure setup() begin declare d datetime; set d
I made simple procedure just to demonstrate CREATE PROCEDURE `demo`(demo_int int) BEGIN DECLARE minid
CREATE PROCEDURE [test].[proc] @ConfiguredContentId int, @NumberOfGames int AS BEGIN SET NOCOUNT ON RETURN @WunNumbers
I have this proc: Create PROCEDURE [dbo].[myProc] @TableName nvarchar(100), @RowID int AS BEGIN SET
Create procedure count_loop( p_start int, p_stop int, p_step int unsigned, p_delim varchar(5)) begin declare
CREATE PROCEDURE new_SP ( @tablename varchar(50) ) AS BEGIN DECLARE @xxx varchar(50) SET @xxx=
I have created a procedure create procedure testProcedure_One as DECLARE @Query nvarchar(4000) begin SET
For example: CREATE PROCEDURE dbo.MyProc AS BEGIN SET NOCOUNT ON; BEGIN TRY ... DECLARE
I have following stored procedure: CREATE PROCEDURE testProc(IN p_idProject INTEGER) BEGIN DECLARE nowTime DATETIME;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.