   que text;
 BEGIN
   que='select isbn,library_book.title, take_authors(isbn), take_keywords(isbn)
-              ,language_id as language, cast(count(*) as int), getrating(isbn) from library_bookitem join
+              ,language_id as language, cast(count(*) as int), rating from library_bookitem join
               library_book on book_id=isbn where '||rot||'='||pid||' group by isbn';
   return query execute (que);
 END;

  $$
LANGUAGE plpgsql;

drop view allbooks;
create or replace view allbooks as
select isbn, title, take_authors(isbn) as authors, take_keywords(isbn) as keywords,
  language_id as language, (select count(*) from library_bookitem where library_bookitem.book_id=isbn) as itemcount,
  getrating(isbn) as rating
  from library_book
  group by isbn;


CREATE or replace FUNCTION take_authors(isbnIn varchar) RETURNS text AS $$
DECLARE
  authors text;
