You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CREATE FUNCTION library.get_books_borrowed_by_user(user_id_param integer) RETURNS TABLE(title character varying, borrow_date timestamp without time zone, due_date timestamp without time zone, returned boolean)
143
-
LANGUAGE plpgsql
144
-
AS $$
142
+
CREATE FUNCTION library.get_books_borrowed_by_user(user_id_param integer)
143
+
RETURNS TABLE(title character varying, borrow_date timestamp without time zone, due_date timestamp without time zone, returned boolean)
CREATE FUNCTION library.get_books_by_author(author_id integer) RETURNS TABLE(id character varying, title character varying, pages integer, year integer, synopsis character varying, cover character varying, "totalInventory" integer, available integer, binding character varying, language character varying, publisher character varying, "longTitle" character varying, "bookOfTheMonth" boolean)
163
-
LANGUAGE sql
164
-
AS $$SELECT * FROM books
165
-
WHERE id IN
166
-
(SELECT book_id from author_book
167
-
WHERE author_id = 2)$$;
162
+
CREATE FUNCTION library.get_books_by_author(author_id_param integer)
163
+
RETURNS SETOF library.books
164
+
LANGUAGE plpgsql
165
+
AS $function$
166
+
BEGIN
167
+
RETURN QUERY
168
+
SELECT * FROM library.books b
169
+
WHERE b.id IN (
170
+
SELECT ab.book_id
171
+
FROM library.author_book ab
172
+
WHERE ab.author_id = author_id_param);
173
+
END
174
+
$function$;
168
175
169
176
170
177
ALTER FUNCTION library.get_books_by_author(author_id integer) OWNER TO postgres;
@@ -174,17 +181,22 @@ ALTER FUNCTION library.get_books_by_author(author_id integer) OWNER TO postgres;
0 commit comments