I have a function that in theory will give the country name as output when the input is the city name:
CREATE OR REPLACE FUNCTION public.country_by_city(city varchar, OUT Country varchar)
RETURNS varchar
LANGUAGE SQL AS
$function$
SELECT c.country
FROM country c
JOIN city c2 ON c2.country_id = c.country_id
WHERE c2.city = $1
$function$
;
And it's working if I will change c2.city to c2.city_id but when I am trying to call a function with a varchar
column in it, for example :
SELECT public.country_by_city(Abha);
I get this error:
SQL Error [42703]: ERROR: column "abha" does not exist
I tried to use UPPER()
or INITCAP()
, and it didn't help. It's worth mentioning that city name records in the city table have capitalized first letters.