-- ============================================================
-- Step 3: create an Oracle-managed PostgreSQL Database Link.
-- Based on FY26 internal training, section 3.2.3.
-- Run as ADMIN.
-- Redmine: #730
-- ============================================================

BEGIN
  DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK(
    db_link_name       => 'HMM_RDS_PG_LINK',
    hostname           => 'database-1.czaaygccsncp.ap-northeast-2.rds.amazonaws.com',
    port               => 5432,
    service_name       => 'postgres',
    credential_name    => 'HMM_RDS_PG_CRED',
    ssl_server_cert_dn => NULL,
    private_target     => FALSE,
    gateway_params     => JSON_OBJECT('db_type' VALUE 'postgres')
  );
END;
/

SELECT db_link, username, host, created
FROM user_db_links
WHERE db_link = 'HMM_RDS_PG_LINK';
