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

  • SEARCH
  • Home
  • 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 6371211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:01:59+00:00 2026-05-25T01:01:59+00:00

Some names and stuff changed to protect my work. DELIMITER // CREATE PROCEDURE glt(IN

  • 0

Some names and stuff changed to protect my work.

DELIMITER //
CREATE PROCEDURE glt(IN howMany INT)
BEGIN

  DECLARE f VARCHAR(32);
  DECLARE done INT DEFAULT 0;
  DECLARE curs CURSOR FOR SELECT DISTINCT id FROM tpd;
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
  OPEN curs;

  DROP TABLE IF EXISTS lt;
  CREATE TEMPORARY TABLE lt LIKE tpd;

  REPEAT
    FETCH curs INTO f;
    IF NOT done THEN
      INSERT INTO lt SELECT * FROM tpd WHERE id = f ORDER BY TIME DESC LIMIT howMany;
    END IF;
  UNTIL done END REPEAT;
  CLOSE curs;
END

The above code gives the following error on a linux machine, but not a mac machine despite both being case-sensitive filesystems and having the same MySQL version:

ERROR 1064 (42000) at line 172: 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 'howMany;
    END IF;
  UNTIL done END REPEAT;
  CLOSE curs;
END' at line 16
Bye
  • 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-05-25T01:02:00+00:00Added an answer on May 25, 2026 at 1:02 am

    Try to use Prepare Statement for INSERT query.
    Look at http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-prepared-statements.html

    It seems it will look like:

    PREPARE stmt FROM 'INSERT INTO lt SELECT * FROM tpd WHERE id = f ORDER BY TIME DESC LIMIT ?';
    EXECUTE stmt USING howMany;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

sTypeName = ... //do some string stuff here to get the name of the
I have a table containing some names and their associated ID, along with a
I have seen on the web some domain names having prefix of ww2 or
Im trying to add some short file names to a Wise installer to fix
I'm trying to store the names of some variables inside strings. For example: Dim
I've got a list of names which some code checks against to see if
Ok, so at some point in time, somebody checked in some files with names
On some .NET driven sites URLs don't end with asp.net page names, like default.aspx,
I need to sanitize some data which will be used in file names. Some
I have for some time tried to anthropomorphise (meaning human readable) the names I

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.