MySQL Forums
Forum List  »  Stored Procedures

Re: How to replace in syntax when calling stored procedure?
Posted by: Clement Yap
Date: August 16, 2012 02:20AM

Hi

Thank you very much. It works.

However, I would like to use function instead of procedure .

Here it goes.
Building a stored function

DELIMITER $$

DROP FUNCTION IF EXISTS `dbprodigy`.`NumOfTests` $$
CREATE FUNCTION `dbprodigy`.`NumOfTests`(yr varchar(4), mth varchar(2)) RETURNS INT

BEGIN
Declare number int default 0;
Select count(distinct SN) into number from tester where Date > Str_to_Date(concat(yr, mth, '01'), '%y%m%d') and
Date < Str_to_Date(concat(yr, mth, '01'), '%y%m%d') + interval 1 Month group by SN;
Return(number);
END $$

DELIMITER ;


Calling syntax:

select dbprodigy.NumOfTests ('2012', '02');

But the error gave out is :- "truncated incorrect date value :'20120231"
and No data - zero rows fetched, selected or processed.

Where could I have gone wrong?

Please advise. Thanks again

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: How to replace in syntax when calling stored procedure?
1103
August 16, 2012 02:20AM


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.