I am not so experienced with sql, and this is my (maybe stupid) question:
I have the following request
select *
from myTable
where lower(replace(lastname, 'ü', 'ue')) = lower(replace(someStr, 'ü', 'ue'))
Is it possible to replace
lower(replace(lastname, 'ü', 'ue')) = lower(replace(someStr, 'ü','ue'))
with function?
Something like that:
select *
from idmanlight.nethz_user
where myFunction(lastname) = myFunction(someStr)
I tried to define the function as follows:
CREATE FUNCTION myFunction(IN str character varying) RETURNS void AS $$
LOWER(replace(replace(replace((str, 'ü', 'ue'), 'ä', 'ae'), 'ö', 'oe'));
$$ LANGUAGE sql;
but running it, I get an error
ERROR: Syntax error by "LOWER" SQL state: 42601 Character: 88
All the examples I found always contain selection, deletion, updating, and insertion into the body of the function.
Actually it is possible to define a function that has no choice, deletion, update, insertion into it?
I am using PostgresSql 9.2.