Reputation: 31
I am trying to create a function to calculate the lateral area of a cylinder.
DELIMITER $$
DROP PROCEDURE IF EXISTS arealateral$$
CREATE PROCEDURE arealateral(input_number,input_number)
BEGIN
DECLARE raio DECIMAL(10,5);
DECLARE alt DECIMAL (10,5);
SET raio = input_number;
SET alt = input_number;
SELECT 2*pi()*raio*alt;
END$$
DELIMITER;
When I run
CALL arealateral(1,1)$$
the error appear
ERROR 1318 (42000): Incorrect number of arguments for PROCEDURE aula3.arealateral; expected 0, got 2
Upvotes: 1
Views: 381
Reputation: 92815
UPDATED: Change it to
DROP PROCEDURE IF EXISTS arealateral;
CREATE PROCEDURE arealateral(in raio DECIMAL(10,5), in alt DECIMAL(10,5))
SELECT 2*pi()*raio*alt;
UPDATE2: Based on your subsequent question posted in comments you should utilize functions
CREATE FUNCTION arealateral(raio DECIMAL(10,5), alt DECIMAL(10,5))
RETURNS DECIMAL(10,5) DETERMINISTIC
RETURN 2*pi()*raio*alt;
CREATE FUNCTION areatotal(raio DECIMAL(10,5), alt DECIMAL (10,5))
RETURNS DECIMAL(10,5) DETERMINISTIC
RETURN 2*areac(raio) + arealateral(raio,alt);
Then you can call them like any other function
SELECT areatotal(1,1);
SELECT arealateral(1,1);
Don't forget to create areac
function.
Upvotes: 2
Reputation: 11579
You should declare proc. parameter type as IN, OUT etc. and variable type as VARCHAR(10). For example,
CREATE PROCEDURE arealateral(IN input_number DECIMAL(10,2),IN input_number2 DECIMAL(10,2))
Upvotes: 0