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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:22:50+00:00 2026-06-16T02:22:50+00:00

I am in the process of converting a SQL Server 2005 database to MySQL

  • 0

I am in the process of converting a SQL Server 2005 database to MySQL and having problems with a Stored procedure. I’m new to MySQL stored procedures so I’m sure it is a problem with my conversion but I’m not seeing it.

The stored procedure is supposed to generate a temporary table which is used to populate a Data Grid View in a vb.net application. However, I’m getting the error “Data No Data – Zero rows fetched, selected or processed.”. Seems simple enough but the select procedure in the stored procedure will get data if I just run it as a query which is why I don’t understand why the error.

I’m really hoping someone can tell me why because I have several hundred stored procedures to convert and I’m having this problem on the very first one.

Here’s the Stored Procedure:

DELIMITER $$

DROP PROCEDURE IF EXISTS `usp_get_unassigned_media`$$

CREATE DEFINER=`showxx`@`67.111.11.110` PROCEDURE `usp_get_unassigned_media`()
BEGIN
    /* GET CURSOR WITH LOCAL LOCATIONS */
    DECLARE intKey INT; 
    DECLARE dteDateInserted DATETIME;
    DECLARE vchIdField VARCHAR(200); 
    DECLARE vchValueField VARCHAR(200); 
    DECLARE intLastKey INT;


/*TAKE OUT SPECIFIC PLAYLIST ITEMS IF TOO SLOW*/
DECLARE csrMediaToBeAssigned CURSOR FOR
SELECT
  `media`.`key`             AS `key`,
  `media`.`date_inserted`   AS `date_inserted`,
  `media_detail_types`.`id` AS `id`,
  `media_details`.`value`   AS `value`
FROM (`media`
   LEFT JOIN (`media_detail_types`
          JOIN `media_details`
        ON ((`media_detail_types`.`key` = `media_details`.`detail_key`)))
     ON ((`media_details`.`media_key` = `media`.`key`)))

WHERE ((`media`.`is_assigned` = 0)
       AND ((`media_detail_types`.`id` = 'Volume Name')
         OR (`media_detail_types`.`id` = 'Drive Id')))
ORDER BY `media`.`key`,`media`.`date_inserted`,`media_detail_types`.`id`;

OPEN csrMediaToBeAssigned;

DROP TEMPORARY TABLE IF EXISTS temp_unassigned_media;
CREATE TEMPORARY TABLE temp_unnassigned_media 
    (temp_key INT, DateInserted DATETIME, IdField VARCHAR(200), ValueField VARCHAR (200)) 
    ENGINE=MEMORY;
SET intLastKey = 0;
/*--GET FIRST RECORD */

FETCH FROM csrMediaToBeAssigned
    INTO intKey, dteDateInserted, vchIdField, vchValueField;
/*--LOOP THROUGH CURSOR */
WHILE intLastKey = 0 DO
    /*--DATA SHOULD BE IN DRIVE ID THEN VOLUME NAME */

    INSERT INTO  temp_unnassigned_media
        VALUES (intKey, dteDateInserted, vchValueField, '');
    FETCH NEXT FROM csrMediaToBeAssigned
        INTO intKey, dteDateInserted, vchIdField, vchValueField;

    UPDATE temp_unnassigned_media
        SET IdField = vchValueField
        WHERE temp_key = temp_key;
    FETCH NEXT FROM csrMediaToBeAssigned
        INTO intKey, dteDateInserted, vchIdField, vchValueField;

END WHILE;
SELECT * 
    FROM temp_unnassigned_media 
    ORDER BY date_inserted; 
CLOSE csrMediaToBeAssigned;     
/*DEALLOCATE csrMediaToBeAssigned   */
/*DROP TABLE #temp_unnassigned_media    */

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-06-16T02:22:52+00:00Added an answer on June 16, 2026 at 2:22 am

    You never hit a condition where that WHILE loop will exit; you initialize intLastKey variable, but it never changes, so you fetch through the entire resultset. The exception is thrown when you fetch again, after the last record.

    The normative pattern is to declare a CONTINUE HANDLER, which MySQL will execute when the NOT FOUND condition is triggered. The handler is normally used to set a variable, which you can then test, so you know when to exit the loop.

    In your case, it looks like just adding this line, after your DECLARE CURSOR statement and before the OPEN statement, would be sufficient:

    DECLARE CONTINUE HANDLER FOR NOT FOUND SET intLastKey = 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am in the process of converting an Access database to SQL Server 2005.
I am in a process of converting some legacy SQL Server Stored Procedures to
I'm working on converting a stored procedure from SQL server to Oracle. This stored
We're in the process of converting to SQL Server from MySQL . I'm trying
we are trying to create C# CLR Stored Procedure on a SQL Server 2005
We are in the process of converting SQL / Stored Procedures to LINQ to
I am trying to query an Microsoft SQL 2005 database, process the data and
I'm in the process of converting a system from sql server to mongodb. I
I am having problems with SQL Server dropping a connection after I have dropped
I have been assigned the task of converting an SQL Server Database to an

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.