List:General Discussion« Previous MessageNext Message »
From:Tomas Hylander Date:November 23 2007 10:10am
Subject:Problem with a Procedure
View as plain text  
Hi!
Hope you can help me with this one.
Im trying to learn this with stored procedures and optimize my databases.
Can someone point what wrong with this?
--------------------------------------------------------------------------------------------------------------------------------------

DELIMITER $$

DROP PROCEDURE IF EXISTS `vagsql`.`sok` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `sok`(skatt int,
                                datum1 DATE,
                                datum2 DATE,
                                OUT ut_summa decimal(8,2))
BEGIN

SELECT SUM(trans2.nettovikt) INTO ut_summa
FROM trans2 INNER JOIN artikel on trans2.artikel=artikel.artikel
WHERE trans2.transtid between 'datum1' and 'datum2'
and artikel.reservinteger='skatt'
group by artikel.volympris;

END $$

DELIMITER ;

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

call sok('01','2007-01-01 00:00:00', '2007-01-10 23:59:59', @out);
select @out;

All I get is that "No data - zero rows fetched, selected or processed"

When running this in query brower everything looks ok.
SELECT SUM(trans2.nettovikt) as summa FROM trans2 INNER JOIN artikel on
trans2.artikel=artikel.artikel WHERE trans2.transtid between '2007-07-01
00:00:00' and '2007-07-02 23:59:59' and artikel.reservinteger='01' group by
artikel.volympris;

Im running mysql 5.1.11.

Thanks in advance!
/Tomas

Thread
Problem with a ProcedureTomas Hylander23 Nov
  • RE: Problem with a ProcedureMartin Gainty23 Nov
    • Re: Problem with a ProcedureTomas Hylander26 Nov
  • Re: Problem with a ProcedureMartin Gainty13 Dec
    • Re: Problem with a ProcedureTomas Hylander13 Dec