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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:40:46+00:00 2026-05-27T17:40:46+00:00

I get a duplicate record from my procedure which inserts 330+ records. But ONLY

  • 0

I get a duplicate record from my procedure which inserts 330+ records.
But ONLY on the very last record. So in other words the last 2 records are not distinct, they are the same. What is it about this procedure that allows the last record to get duplicated.

DELIMITER $$

DROP PROCEDURE IF EXISTS `zzExclude_Products` $$
CREATE DEFINER=`root`@`%` PROCEDURE `zzExclude_Products`()
BEGIN

DECLARE done INT DEFAULT 0;
DECLARE VAR_ENTITY_ID VARCHAR(50);

DECLARE CUR_NO CURSOR FOR

SELECT DISTINCT NO
FROM stage_product_data.ITEMMAST AS IM
JOIN stage_product_data.zzLive_Products AS LIVE ON IM.NO = LIVE.SKU
WHERE DIVISION = '30' AND STATUS NOT IN ('XX','YY','ZZ');


DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

OPEN CUR_NO;
REPEAT

FETCH CUR_NO INTO VAR_ENTITY_ID;
INSERT INTO zz_CATALOG (TYPE, ENTITY_ID, ESTRICTION_TYPE, RESTRICTION_VALUE)
VALUES ('Product', VAR_ENTITY_ID, 'Country', 'ALL');

UNTIL done END REPEAT;
CLOSE CUR_NO;

END $$

DELIMITER ;
  • 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-27T17:40:47+00:00Added an answer on May 27, 2026 at 5:40 pm

    There’s really no need for a cursor here. This can be done in a single INSERT statement.

    INSERT INTO zz_CATALOG 
        (TYPE, ENTITY_ID, ESTRICTION_TYPE, RESTRICTION_VALUE)
        SELECT DISTINCT 'Product', EDPNO, 'Country', 'ALL'
            FROM stage_product_data.ITEMMAST AS IM
                JOIN stage_product_data.zzLive_Products AS LIVE 
                    ON IM.EDPNO = LIVE.SKU
            WHERE DIVISION = '30' 
                AND STATUS NOT IN ('XX','YY','ZZ');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Can I get more than 1000 records from a DirectorySearcher in Asp.Net?
Possible Duplicate: Get all files from VSS for a given date? I need to
I've been using a Drupal module called FeedAPI De-Dupe to remove duplicate records from
On MS access, how to get the ID of the records having duplicate content
Possible Duplicate: Retrieving the last record in each group Hi all i am having
This question is not a duplicate of Get data file from microphone in windows
Working in SQL Server 2005, I have a stored procedure that inserts a record
I want to get redundant records from the database. Is my query correct for
Possible Duplicate: Get CVS history for a particular user Is it possible to list
When I try to use the code below I get a duplicate variable error

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.