Unsuccessful metadata update. STORE RDB$RELATION_FIELDS failed. attempt to store duplicate value (visible to active transactions) in unique index "RDB$INDEX_XYZ".
This error shows up when you try to create a table or view column under a name that already exists. It's a common problem that happens when you create views and do not supply explicit column names - and don't use column aliases in underlying select. Naming columns explicitly should fix the problem.