SPOOL create_uspr_v.lst

CREATE OR REPLACE VIEW user_profiles_v AS
SELECT syus_id
     , sypr_id
FROM   user_profiles
WHERE  syus_id IN
      ( SELECT syus_id
        FROM   system_users
        WHERE  UPPER(db_username) NOT IN ('SYSTEM','ADVANTICA')
        AND    cust_id IN
              ( SELECT cust_id
                FROM   customers
                WHERE  cuty_id IN
                      ( SELECT cuty_id
                        FROM   customer_types
                        WHERE  code IN
                              ( SELECT SUBSTR(granted_role,5,3)
                                FROM   user_role_privs
                                WHERE  granted_role IN ('EFT_OMT_RO','EFT_PUW_RO')
                              )
                      )
              )
      )
/

SPOOL OFF
