MySQL Forums
Forum List  »  Stored Procedures

My first stored procedure
Posted by: Chevy Mark Sunderland
Date: March 16, 2012 10:03AM

Hi all.

This is my first stored procedure create in Mysql Workbench 5.2.38 CE.

I need show the output of stored procedure and I try this but:


-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `sp1`( ymstart char(6), ymstop char(6), flightspec char(2), inout result decimal(16,4) )
begin
  declare this char(6);
  set this=ymstart, result=0;
  while this <= ymstop do 
    set result = result + 
                 (select sum(my_number_of_flight_hours_e+my_number_of_flight_hours_e) 
                  from dotableone 
                  where year=left(this,4) and `month`=right(this,2) and left(my_flight_zone,2)=flightspec
                 );
    if right(this,2) >= '12' then
      set this = concat( 1+left(this,4), '01' );

    else

      set this = concat( left(this,4), if(right(this,2)<'09','0',''), 1+right(this,2) );
    end if;
  end while;
END

CALL sp1 (5, @a);
SELECT @a;

0	
16:56:05	
CALL sp1 (5, @a)	
Error Code: 1318. 
Incorrect number of arguments for PROCEDURE dbq.sp1; expected 4, got 2

Can you help me?
Many thanks

Options: ReplyQuote


Subject
Views
Written By
Posted
My first stored procedure
3456
March 16, 2012 10:03AM


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.