I'm trying to create a function that will be essentially taking various parameters perform pgrouting with Dijkstra's algorithm, according to the user input as parameters. So the I'm making a minimal example which is the following:
CREATE OR REPLACE FUNCTION _a_route(source integer, target integer) RETURNS SETOF record AS $$ BEGIN SELECT * FROM pgr_dijkstra('SELECT id, source, target, time AS cost FROM roads_noded', $1, $2, false); END; $$ LANGUAGE plpgsql;
This should be taking source and target as input and run the algorithm.
But I'm always getting the same error:
ERROR: query has no destination for result data HINT: If you want to discard the results of a SELECT, use PERFORM instead. CONTEXT: PL/pgSQL function _a_route(integer,integer) line 3 at SQL statement
So what am I doing wrong here? SETOF record is supposed to be the equivalent of returning a table
Postgresql Version: 9.6.1 PostGIS : 2.3.1