List:General Discussion« Previous MessageNext Message »
From:Martin Gainty Date:November 23 2007 3:43pm
Subject:RE: Problem with a Procedure
View as plain text  
Tomas-I would effect a quick iterative check on the table(s) to see if they are empty e.g.
 
SELECT count(trans2.nettovikt) from trans2;
(If recordcount>0) then
SELECT SUM(trans2.nettovikt)  FROM trans2 INNER JOIN artikel on
trans2.artikel=artikel.artikel
(If recordcount>0) then
SELECT SUM(trans2.nettovikt) INTO ut_summa FROM trans2 INNER JOIN artikel on
trans2.artikel=artikel.artikel WHERE trans2.transtid between 'datum1' and 'datum2'
 
(If recordcount > 0) then
 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'
 
(If recordcount > 0) then
 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;Does this help???
Martin Gainty______________________________________________Disclaimer and confidentiality
noteEverything in this e-mail and any attachments relates to the official business of
Sender. This transmission is of a confidential nature and Sender does not endorse
distribution to any party other than intended recipient. Sender does not necessarily
endorse content contained within this transmission.> Date: Fri, 23 Nov 2007 11:10:47
+0100> From: tomas.hylander@stripped> To: mysql@stripped> Subject:
Problem with a Procedure> > 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
_________________________________________________________________
Share life as it happens with the new Windows Live.Download today it's FREE!
http://www.windowslive.com/share.html?ocid=TXT_TAGLM_Wave2_sharelife_112007
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