I've a PostgreSQL function that returns a string. I want to use this function into another one but I obtain an error.
These are the sample functions, with get_some_string that returns text, and use_the_string where I want to call the previous one and store the result in a variable:
CREATE OR REPLACE FUNCTION public.get_some_string()
RETURNS text AS
$func$
DECLARE
BEGIN
return 'mystring';
END
$func$ LANGUAGE plpgsql VOLATILE;
CREATE OR REPLACE FUNCTION public.use_the_string()
RETURNS boolean AS
$func$
DECLARE
mytext text;
BEGIN
mytext := select public.get_some_string();
END
$func$ LANGUAGE plpgsql VOLATILE;
If I run this query I obtain the error:
ERROR: syntax error at or near "select"
LINE 24: mytext := select public.get_some_string();
What I'm doing wrong? How can I use the return value of the first function into the second one?