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 9170441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:01:11+00:00 2026-06-17T16:01:11+00:00

The following is my MySQL procedure. DELIMITER $$ DROP PROCEDURE IF EXISTS set_dummy_feedback $$

  • 0

The following is my MySQL procedure.

DELIMITER $$

DROP PROCEDURE IF EXISTS  set_dummy_feedback $$
CREATE PROCEDURE set_dummy_feedback ( )
BEGIN
-- First we declare all the variables we will need
DECLARE current_code,current_emp_id,current_subject_id        VARCHAR(150);
DECLARE current_count_facultyfeedback,current_count_studentfeedback     INT     DEFAULT 0;
DECLARE temp_index                                                      INT     DEFAULT 0;
DECLARE gpa                                                             DECIMAL(4,2);
-- flag which will be set to true, when cursor reaches end of table
DECLARE exit_loop BOOLEAN;         

-- Declare the sql for the cursor
DECLARE example_cursor CURSOR FOR
SELECT DISTINCT emp_id,subject_id,code,c
FROM feedback_subjectfaculty

ORDER BY `c` ASC ;
-- Let mysql set exit_loop to true, if there are no more rows to iterate
DECLARE CONTINUE HANDLER FOR NOT FOUND SET exit_loop = TRUE;

-- open the cursor
OPEN example_cursor;

-- marks the beginning of the loop
example_loop: LOOP

-- read the name from next row into the variable l_name
FETCH  example_cursor INTO   current_emp_id,current_subject_id,current_code,current_count_facultyfeedback;

-- check if the exit_loop flag has been set by mysql, 
-- if it has been set we close the cursor and exit 
-- the loop
IF exit_loop THEN
    CLOSE example_cursor;
    LEAVE example_loop;
END IF;
-- fetch data from table feedback_studentfeedback
SELECT SQL_CALC_FOUND_ROWS * FROM `feedback_studentfeedback` where 
fb_subjects_10 like CONCAT("%",current_code,"%") ;
-- save the number of rows fetched in the previous select
SET current_count_studentfeedback = FOUND_ROWS() ;
SET temp_index = current_count_studentfeedback ;
IF temp_index IS NULL
    THEN SET temp_index = 0;
END IF;
IF current_count_facultyfeedback IS NULL
    THEN SET current_count_facultyfeedback = 0;
END IF;

WHILE temp_index > current_count_facultyfeedback DO

    SET gpa = ((round( abs( (rand( ) *100 ) )) %5)*2)+2.12);
    IF gpa > 10.0
        THEN SET gpa = 8.12;
    END IF;

    INSERT INTO tbl2 VALUES             
    ('B.Tech',
    'CSE',
    current_emp_id,
    '0',
    current_subject_id,
    'MONSOON',
    "2012",
    (round( abs( (rand( ) *100 ) )) %5 +1),
    '',
    gpa);
SET temp_index = temp_index - 1;
END WHILE;
END LOOP;
CLOSE example_cursor;

END $$

DELIMITER ;

Despite my best efforts, it still gives me the following error:

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 

   '); 
    IF gpa > 10.0
        THEN SET gpa = 8.12;
    END IF;' 

I need to complete this at the earliest, but can’t seem to figure out what went wrong.
Thanks in advance.

  • 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-17T16:01:11+00:00Added an answer on June 17, 2026 at 4:01 pm

    Check this line:

    SET gpa = ((round( abs( (rand( ) *100 ) )) %5)*2)+2.12);
    

    You have 6 opening parenthesis and 7 closing ones, causing the syntax error!

    Remove the last closing one as it does not seem to be required

    SET gpa = ((round( abs( (rand( ) *100 ) )) %5)*2)+2.12;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following mysql query, DELIMITER $$ DROP PROCEDURE IF EXISTS `allied`.`aboutus_delete`$$ CREATE
I use the following mysql procedure, DROP PROCEDURE IF EXISTS `allied`.`GetRegistrationData`$$ CREATE DEFINER=`allied`@`%` PROCEDURE
I am using the following sql: DELIMITER $$ DROP PROCEDURE IF EXISTS `get_auto_increment_settings`$$ CREATE
Can you not do the following w/ MySQL stored procedures?/ DROP PROCEDURE IF EXISTS
I have the following code: delimiter ; DROP PROCEDURE IF EXISTS ufk_test; delimiter //
I have the following MySQL query: DELIMITER // CREATE PROCEDURE InsertResult (IN winnerID INT,
I have the following MySQL routine: DELIMITER $$ CREATE DEFINER=`root`@`%` PROCEDURE `getGroupOrders`(grp INT, ord
I want to make a MySQL Stored Procedure DELIMITER $$ DROP PROCEDURE IF EXISTS
I created one procedure called Sample1 delimiter ;; drop procedure if exists Sample1;; CREATE
I am running the following command in PHPMyAdmin: DELIMITER # CREATE PROCEDURE addid() BEGIN

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.