what is problem of my stored procedure
Posted by: derek wong
Date: October 06, 2009 07:17AM

Hi , I created a stored procedure. I tried to call it by Call GetSystemCode('I'). I wonder how come it didn't return anything. At the below on the status bar, it only say that "the query is being run"....hope anyone can help me out.



DELIMITER $$

DROP PROCEDURE IF EXISTS `GetSystemCode` $$
CREATE DEFINER=`test`@`%` PROCEDURE `GetSystemCode`(p varchar(1))
BEGIN

DECLARE newSysCode varchar (30);
DeCLARE newDateTime varchar(8);
DECLARE counter int;
DECLARE returnData varchar (10);

Set newDateTime = DATE_Format(now(),'%Y%m%d');

SELECT count(*) into counter from systemparameter where DateFormat = newDAteTime;

if counter = 0 then
insert into systemparameter (DateFormat) values (newDAteTime);
end if;

CASE p
when 'I' then
select stockIn into returnData from systemparameter where DateFormat = newDAteTime;
update systemparameter set stockIn=stockIn+1 where DateFormat = newDAteTime;
when 'O' then select stockOut into returnData from systemparameter where DateFormat = newDAteTime;
update systemparameter set stockOut=stockOut+1 where DateFormat = newDAteTime;
when 'R' then select stockReserve into returnData from systemparameter where DateFormat = newDAteTime;
update systemparameter set stockReserve=stockReserve+1 where DateFormat = newDAteTime;
END case;

while LENGTH(returnData) < 6 do
set returnData = '0' + returnData;
end while;


select newDateTime + p + returnData;


END $$

DELIMITER ;

Options: ReplyQuote


Subject
Written By
Posted
what is problem of my stored procedure
October 06, 2009 07:17AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.