-1

The purpose of the program: Given the Country Code, Returns the Countries Region. My only error is my _code variable that I am TRYING to use as a parameter for the Code input(Will not tell me what is, see attached pdf). I used a very similar format when building a procedure, but some other rules must apply in this case.

Attached is a screen shot of the code with the error but as I said it doesn't specify. along with a screen shot of the country, class to see where I got "Code" and "country" from.

Any suggestions how to solve this in order to get the program to compile?

See these images:

Code w/ error

country Class

CREATE FUNCTION getRegion(@_code varchar(3)) 
RETURNS varchar(50)
AS
BEGIN
    DECLARE @region varchar(40)

    SELECT @region = Region 
    FROM country
    WHERE Code = @_code

    RETURN @region
END
Flexo
  • 87,323
  • 22
  • 191
  • 272

1 Answers1

0

I was not supposed to use the @ symbol to declare a variable.

CREATE FUNCTION `get_region`(_code VARCHAR(3)) 
RETURNS varchar(50) 
BEGIN 
DECLARE _region VARCHAR(50);
SELECT region INTO _region FROM country
WHERE Code = _code;   
RETURN region; 
END
Flexo
  • 87,323
  • 22
  • 191
  • 272