WHENEVER SQLERROR EXIT SQL.SQLCODE

CREATE OR REPLACE DATA GRANT ai_sales_rep_customers
  AS SELECT (customer_id, customer_name, region, account_owner, risk_rating)
  ON dds_ai_customers
  WHERE region = 'LATAM'
  TO sales_rep_role;

CREATE OR REPLACE DATA GRANT ai_regional_manager_customers
  AS SELECT (ALL COLUMNS EXCEPT tax_id)
  ON dds_ai_customers
  WHERE region = 'LATAM'
  TO regional_manager_role;

CREATE OR REPLACE DATA GRANT ai_hr_global_customers
  AS SELECT
  ON dds_ai_customers
  TO hr_global_role;

BEGIN
  EXECUTE IMMEDIATE 'SET USE DATA GRANTS ONLY ON dds_ai_customers ENABLED';
END;
/
