I created a dynamic SQL function for the first time and wondering what is the correct way to call the function? Here's the code
CREATE OR REPLACE FUNCTION functions.search_function(_columns text)
RETURNS TABLE(student text,
student_id text,
professor_name text,
subject text,
subject_time text,
room_number text,
building text)
LANGUAGE plpgsql AS
$func$
DECLARE
_columns text := 'student_id::text, subject_timetime::text, building::text';
BEGIN
RETURN QUERY EXECUTE '
SELECT
student,
professor_name,
subject,
room_number,
' || _columns || '
FROM "school_records_table" '
USING _columns;
END
$func$;
I have been receiving an error when I try this
SELECT functions.searchandfilter2_function(
('students') )