WHENEVER SQLERROR EXIT SQL.SQLCODE

BEGIN
  EXECUTE IMMEDIATE q'[
    CREATE TABLE dds_mac_accounts (
      account_id   NUMBER PRIMARY KEY,
      account_name VARCHAR2(100),
      owner_name   VARCHAR2(60),
      region       VARCHAR2(30),
      balance      NUMBER(12,2)
    )
  ]';
EXCEPTION
  WHEN OTHERS THEN
    IF SQLCODE != -955 THEN
      RAISE;
    END IF;
END;
/

BEGIN
  EXECUTE IMMEDIATE q'[
    CREATE OR REPLACE VIEW dds_mac_accounts_view AS
    SELECT account_id, account_name, owner_name, region, balance
    FROM dds_mac_accounts
    WHERE UPPER(owner_name) = ORA_END_USER_CONTEXT.username
  ]';
END;
/
