To create an array of a type, use an explicit array constructor:
array[(1,100,'Arthur',1), (1,50,'Zaphod',1)]::books[]
So to call your function you would need to use:
select update_table(array[(1,100,'Arthur',1), (1,50,'Zaphod',1)]::books[])
But your function has an error: after the loop you are missing a return statement, because the one in the exception block is only executed if an exception occurs.
So you need something like this:
begin .... STATUS:='Saved'; return status; ---<<< this is missing exception when others then STATUS:='failure'; RETURN STATUS; --<<< this is only execute if an exception occursEND;
Alternatively you need another begin .. end;
block:
begin begin for ... end loop; STATUS:='Saved'; exception when others then STATUS:='failure'; end; RETURN STATUS; END;
Unrelated, but: you don't need the loop to iterate over the array. You can do that more efficiently using a single statement:
INSERT INTO books_table (Book_ID, Row_Num, Book_OWNER, Book_OWNER_ID)select *from unnest(row_book);