--------------------------------------------------------
--  DDL for View SMD_CDBS_PRODUCTION_VW
--------------------------------------------------------

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "OTHQ_OWN"."SMD_CDBS_PRODUCTION_VW" ("CDBNAME", "THINNAME", "DBVERSION", "DATACENTER", "OPERATINGSTATUS", "PDBCAPACITY", "EXISTINGPDBCOUNT", "EXACS", "NODE1", "NODE2", "NODE1IPADDRESS", "NODE2IPADDRESS", "NODE1DBINSTANCEID", "NODE2DBINSTANCEID", "REGION", "ENDPOINT", "METADATA_DOWNLOADED_TIMESTAMP_UTC", "GROUP_", "QUARANTINED", "AVAILABLE_PDB_SLOT") DEFAULT COLLATION "USING_NLS_COMP"  AS 
  select
    CDBNAME, THINNAME, DBVERSION, DATACENTER, OPERATINGSTATUS, PDBCAPACITY, EXISTINGPDBCOUNT, EXACS, NODE1, NODE2, NODE1IPADDRESS, NODE2IPADDRESS, NODE1DBINSTANCEID, NODE2DBINSTANCEID, REGION, ENDPOINT, METADATA_DOWNLOADED_TIMESTAMP_UTC,
    "GROUP" as GROUP_,
    'false' as QUARANTINED,
    case when PDBCAPACITY - EXISTINGPDBCOUNT < 0 then 0 else PDBCAPACITY - EXISTINGPDBCOUNT end as AVAILABLE_PDB_SLOT
from
    SRC_SMD_CDBS_TB
where
    ENDPOINT like 'netsuite-production%'
;
