472,090 Members | 1,319 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,090 software developers and data experts.

Error Code : 1329, No data - zero rows fetched, selected, or processed. MYSQL

Error Code : 1329, No data - zero rows fetched, selected, or processed. MYSQL
I am getting the following error while running a stored procedure in mysql5.0

Error Code : 1329
No data - zero rows fetched, selected, or processed.

I have an stored procedure SP1 which calls stored procedure SP2 and SP2 calls a function F1.

I have run this script from .bat file.

after executing i tried to call stored procedure 1 (update_stock), it gives error listed top.

But if i open stored procedure from sqlyog by clicking on alter procedure and rerun the stored procedure.

next time when i call the procedure it executes properly with out error.

Please help me with some solution.

The basic structre of procedure and function is given below


For eg.


----- stored procedure 1 -------------

Expand|Select|Wrap|Line Numbers
  1. DELIMITER $$;
  2.  
  3. DROP PROCEDURE IF EXISTS `update_stock`$$
  4. CREATE PROCEDURE `update_stock`(upload_date varchar(10))
  5. BEGIN
  6.  
  7. call update_closingstk(upload_date);
  8.  
  9. END$$
  10.  
  11. DELIMITER ;$$


----- stored procedure 2 -------------

Expand|Select|Wrap|Line Numbers
  1. DELIMITER $$;
  2.  
  3. DROP PROCEDURE IF EXISTS `update_closingstk`$$
  4. CREATE PROCEDURE `update_closingstk`(upload_date varchar(10))
  5. BEGIN
  6.  
  7. declare clsstock int default 0;
  8.  
  9. set clsstock = get_closing_stk
  10.  
  11. END$$
  12.  
  13. DELIMITER ;$$


--- Function 1--------------

Expand|Select|Wrap|Line Numbers
  1. DELIMITER $$;
  2.  
  3. DROP FUNCTION IF EXISTS `scm_db`.`get_closing_stk`$$
  4.  
  5. CREATE FUNCTION `get_closing_stk`(upload_date varchar(10),productrid int ,pkt2cbb2 int) RETURNS int(11)
  6. BEGIN
  7. declare closingstock int;
  8. select clsstock into closingstock from clsstk_tab where stk_prod_rid=10;
  9.  
  10. return IFNULL(closingstock ,0);
  11. END$$
  12.  
  13. DELIMITER ;$$
Jan 25 '08 #1
1 13409
Please change your stored function in the below mentioned way:

---------------------------------------------

DELIMITER $$
DROP FUNCTION IF EXISTS `DEMO`$$
CREATE FUNCTION `DEMO`(upload_date varchar(10),productrid int ,pkt2cbb2 int(11))
RETURNS int(11)
BEGIN
declare closingstock int;
select IF(COUNT(clsstock) > 0, clsstock, 0) into closingstock from clsstk_tab where stk_prod_rid=10;

return closingstock;
END $$

DELIMITER

---------------------------------------------

It will solve your problem
Sep 30 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Sonnich | last post: by
2 posts views Thread by kkshansid | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.