thewhistler1
Technical User
I have a table called "movie" and I would like to bring up the last X number of them with this function but it gives me error:
ERROR: return type mismatch in function declared to return text
DETAIL: Final SELECT must return exactly one column.
CONTEXT: SQL function "last_movie"
here is what it looks like :
create FUNCTION last_movie(int) returns setof movie
as 'SELECT m.movie_id, m.movie_name, m.kids
FROM movie m
WHERE m.movie_id > (( SELECT max(movie.movie_id) - $1
FROM movie));'
language SQl;
if I change the "m.movie_id, m.movie_name, m.kids" to "*" then it works but I would like just those particular fields in the results.
Any ideas? Thanks
ERROR: return type mismatch in function declared to return text
DETAIL: Final SELECT must return exactly one column.
CONTEXT: SQL function "last_movie"
here is what it looks like :
create FUNCTION last_movie(int) returns setof movie
as 'SELECT m.movie_id, m.movie_name, m.kids
FROM movie m
WHERE m.movie_id > (( SELECT max(movie.movie_id) - $1
FROM movie));'
language SQl;
if I change the "m.movie_id, m.movie_name, m.kids" to "*" then it works but I would like just those particular fields in the results.
Any ideas? Thanks