You attempted to execute a SET SESSION AUTHORIZATION, SET ROLE, or SET TRANSACTION statement from within an active transaction.
Issue the SET statement at the beginning of the transaction, before a DML statement, such as SELECT or INSERT, makes the transaction active. Otherwise, roll back or commit the transaction before you issue the SET statement.