diff --git a/3682.pdf b/3682.pdf new file mode 100644 index 0000000..39cf585 Binary files /dev/null and b/3682.pdf differ diff --git a/3683.pdf b/3683.pdf new file mode 100644 index 0000000..a2af50e Binary files /dev/null and b/3683.pdf differ diff --git a/9781590598825.jpg b/9781590598825.jpg new file mode 100644 index 0000000..ffb2efa Binary files /dev/null and b/9781590598825.jpg differ diff --git a/AppendixA/create_user.sql b/AppendixA/create_user.sql new file mode 100644 index 0000000..2f240d8 --- /dev/null +++ b/AppendixA/create_user.sql @@ -0,0 +1,30 @@ +connect sys as sysdba; +create user bps identified by bps; +alter user bps default tablespace users temporary tablespace temp; +grant all privileges to bps; +grant execute on SYS.DBMS_LOCK to BPS; +set feedback off; +set linesize 1000; +set newpage 0; +set pagesize 32767; +set trimspool on; +spool create_user.sub +select 'grant select on '||view_name||' to bps;' +from SYS.DBA_VIEWS +where owner = 'SYS' +and view_name like 'DBA\_%' escape '\' +order by 1; +select 'grant select on '||view_name||' to bps;' +from SYS.DBA_VIEWS +where owner = 'SYS' +and view_name like 'V\_$%' escape '\' +order by 1; +spool off; +set feedback on; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +spool create_user_sub.txt; +@create_user.sub +spool off; diff --git a/AppendixA/create_user.sub b/AppendixA/create_user.sub new file mode 100644 index 0000000..784c1c1 --- /dev/null +++ b/AppendixA/create_user.sub @@ -0,0 +1,935 @@ + 'GRANTSELECTON'||VIEW_NAME||'TOBPS;' +------------------------------------------------------ +grant select on DBA_2PC_NEIGHBORS to bps; +grant select on DBA_2PC_PENDING to bps; +grant select on DBA_ADVISOR_ACTIONS to bps; +grant select on DBA_ADVISOR_COMMANDS to bps; +grant select on DBA_ADVISOR_DEFINITIONS to bps; +grant select on DBA_ADVISOR_DEF_PARAMETERS to bps; +grant select on DBA_ADVISOR_DIRECTIVES to bps; +grant select on DBA_ADVISOR_FINDINGS to bps; +grant select on DBA_ADVISOR_JOURNAL to bps; +grant select on DBA_ADVISOR_LOG to bps; +grant select on DBA_ADVISOR_OBJECTS to bps; +grant select on DBA_ADVISOR_OBJECT_TYPES to bps; +grant select on DBA_ADVISOR_PARAMETERS to bps; +grant select on DBA_ADVISOR_PARAMETERS_PROJ to bps; +grant select on DBA_ADVISOR_RATIONALE to bps; +grant select on DBA_ADVISOR_RECOMMENDATIONS to bps; +grant select on DBA_ADVISOR_SQLA_REC_SUM to bps; +grant select on DBA_ADVISOR_SQLA_WK_MAP to bps; +grant select on DBA_ADVISOR_SQLA_WK_STMTS to bps; +grant select on DBA_ADVISOR_SQLW_COLVOL to bps; +grant select on DBA_ADVISOR_SQLW_JOURNAL to bps; +grant select on DBA_ADVISOR_SQLW_PARAMETERS to bps; +grant select on DBA_ADVISOR_SQLW_STMTS to bps; +grant select on DBA_ADVISOR_SQLW_SUM to bps; +grant select on DBA_ADVISOR_SQLW_TABLES to bps; +grant select on DBA_ADVISOR_SQLW_TABVOL to bps; +grant select on DBA_ADVISOR_SQLW_TEMPLATES to bps; +grant select on DBA_ADVISOR_TASKS to bps; +grant select on DBA_ADVISOR_TEMPLATES to bps; +grant select on DBA_ADVISOR_USAGE to bps; +grant select on DBA_ALERT_ARGUMENTS to bps; +grant select on DBA_ALERT_HISTORY to bps; +grant select on DBA_ALL_TABLES to bps; +grant select on DBA_ANALYZE_OBJECTS to bps; +grant select on DBA_APPLICATION_ROLES to bps; +grant select on DBA_APPLY to bps; +grant select on DBA_APPLY_CONFLICT_COLUMNS to bps; +grant select on DBA_APPLY_DML_HANDLERS to bps; +grant select on DBA_APPLY_ENQUEUE to bps; +grant select on DBA_APPLY_ERROR to bps; +grant select on DBA_APPLY_EXECUTE to bps; +grant select on DBA_APPLY_INSTANTIATED_GLOBAL to bps; +grant select on DBA_APPLY_INSTANTIATED_OBJECTS to bps; +grant select on DBA_APPLY_INSTANTIATED_SCHEMAS to bps; +grant select on DBA_APPLY_KEY_COLUMNS to bps; +grant select on DBA_APPLY_PARAMETERS to bps; +grant select on DBA_APPLY_PROGRESS to bps; +grant select on DBA_APPLY_SPILL_TXN to bps; +grant select on DBA_APPLY_TABLE_COLUMNS to bps; +grant select on DBA_AQ_AGENTS to bps; +grant select on DBA_AQ_AGENT_PRIVS to bps; +grant select on DBA_ASSOCIATIONS to bps; +grant select on DBA_ATTRIBUTE_TRANSFORMATIONS to bps; +grant select on DBA_AUDIT_EXISTS to bps; +grant select on DBA_AUDIT_OBJECT to bps; +grant select on DBA_AUDIT_POLICIES to bps; +grant select on DBA_AUDIT_POLICY_COLUMNS to bps; +grant select on DBA_AUDIT_SESSION to bps; +grant select on DBA_AUDIT_STATEMENT to bps; +grant select on DBA_AUDIT_TRAIL to bps; +grant select on DBA_AUTO_SEGADV_CTL to bps; +grant select on DBA_AUTO_SEGADV_SUMMARY to bps; +grant select on DBA_AWS to bps; +grant select on DBA_AW_OBJ to bps; +grant select on DBA_AW_PROP to bps; +grant select on DBA_AW_PS to bps; +grant select on DBA_BASE_TABLE_MVIEWS to bps; +grant select on DBA_BLOCKERS to bps; +grant select on DBA_CACHEABLE_NONTABLE_OBJECTS to bps; +grant select on DBA_CACHEABLE_OBJECTS to bps; +grant select on DBA_CACHEABLE_OBJECTS_BASE to bps; +grant select on DBA_CACHEABLE_TABLES to bps; +grant select on DBA_CACHEABLE_TABLES_BASE to bps; +grant select on DBA_CAPTURE to bps; +grant select on DBA_CAPTURE_EXTRA_ATTRIBUTES to bps; +grant select on DBA_CAPTURE_PARAMETERS to bps; +grant select on DBA_CAPTURE_PREPARED_DATABASE to bps; +grant select on DBA_CAPTURE_PREPARED_SCHEMAS to bps; +grant select on DBA_CAPTURE_PREPARED_TABLES to bps; +grant select on DBA_CATALOG to bps; +grant select on DBA_CHANGE_NOTIFICATION_REGS to bps; +grant select on DBA_CLUSTERS to bps; +grant select on DBA_CLUSTER_HASH_EXPRESSIONS to bps; +grant select on DBA_CLU_COLUMNS to bps; +grant select on DBA_COLL_TYPES to bps; +grant select on DBA_COL_COMMENTS to bps; +grant select on DBA_COL_PRIVS to bps; +grant select on DBA_COMMON_AUDIT_TRAIL to bps; +grant select on DBA_CONNECT_ROLE_GRANTEES to bps; +grant select on DBA_CONSTRAINTS to bps; +grant select on DBA_CONS_COLUMNS to bps; +grant select on DBA_CONS_OBJ_COLUMNS to bps; +grant select on DBA_CONTEXT to bps; +grant select on DBA_CPU_USAGE_STATISTICS to bps; +grant select on DBA_DATAPUMP_JOBS to bps; +grant select on DBA_DATAPUMP_SESSIONS to bps; +grant select on DBA_DATA_FILES to bps; +grant select on DBA_DB_LINKS to bps; +grant select on DBA_DDL_LOCKS to bps; +grant select on DBA_DEPENDENCIES to bps; +grant select on DBA_DIMENSIONS to bps; +grant select on DBA_DIM_ATTRIBUTES to bps; +grant select on DBA_DIM_CHILD_OF to bps; +grant select on DBA_DIM_HIERARCHIES to bps; +grant select on DBA_DIM_JOIN_KEY to bps; +grant select on DBA_DIM_LEVELS to bps; +grant select on DBA_DIM_LEVEL_KEY to bps; +grant select on DBA_DIRECTORIES to bps; +grant select on DBA_DML_LOCKS to bps; +grant select on DBA_DMT_FREE_SPACE to bps; +grant select on DBA_DMT_USED_EXTENTS to bps; +grant select on DBA_ENABLED_AGGREGATIONS to bps; +grant select on DBA_ENABLED_TRACES to bps; +grant select on DBA_ENCRYPTED_COLUMNS to bps; +grant select on DBA_EPG_DAD_AUTHORIZATION to bps; +grant select on DBA_ERRORS to bps; +grant select on DBA_EVALUATION_CONTEXTS to bps; +grant select on DBA_EVALUATION_CONTEXT_TABLES to bps; +grant select on DBA_EVALUATION_CONTEXT_VARS to bps; +grant select on DBA_EXPORT_OBJECTS to bps; +grant select on DBA_EXP_FILES to bps; +grant select on DBA_EXP_OBJECTS to bps; +grant select on DBA_EXP_VERSION to bps; +grant select on DBA_EXTENTS to bps; +grant select on DBA_EXTERNAL_LOCATIONS to bps; +grant select on DBA_EXTERNAL_TABLES to bps; +grant select on DBA_FEATURE_USAGE_STATISTICS to bps; +grant select on DBA_FGA_AUDIT_TRAIL to bps; +grant select on DBA_FILE_GROUPS to bps; +grant select on DBA_FILE_GROUP_EXPORT_INFO to bps; +grant select on DBA_FILE_GROUP_FILES to bps; +grant select on DBA_FILE_GROUP_TABLES to bps; +grant select on DBA_FILE_GROUP_TABLESPACES to bps; +grant select on DBA_FILE_GROUP_VERSIONS to bps; +grant select on DBA_FREE_SPACE to bps; +grant select on DBA_FREE_SPACE_COALESCED to bps; +grant select on DBA_FREE_SPACE_COALESCED_TMP1 to bps; +grant select on DBA_FREE_SPACE_COALESCED_TMP2 to bps; +grant select on DBA_FREE_SPACE_COALESCED_TMP3 to bps; +grant select on DBA_FREE_SPACE_COALESCED_TMP4 to bps; +grant select on DBA_FREE_SPACE_COALESCED_TMP5 to bps; +grant select on DBA_FREE_SPACE_COALESCED_TMP6 to bps; +grant select on DBA_GLOBAL_CONTEXT to bps; +grant select on DBA_HIGH_WATER_MARK_STATISTICS to bps; +grant select on DBA_HIST_ACTIVE_SESS_HISTORY to bps; +grant select on DBA_HIST_BASELINE to bps; +grant select on DBA_HIST_BG_EVENT_SUMMARY to bps; +grant select on DBA_HIST_BUFFERED_QUEUES to bps; +grant select on DBA_HIST_BUFFERED_SUBSCRIBERS to bps; +grant select on DBA_HIST_BUFFER_POOL_STAT to bps; +grant select on DBA_HIST_COMP_IOSTAT to bps; +grant select on DBA_HIST_CR_BLOCK_SERVER to bps; +grant select on DBA_HIST_CURRENT_BLOCK_SERVER to bps; +grant select on DBA_HIST_DATABASE_INSTANCE to bps; +grant select on DBA_HIST_DATAFILE to bps; +grant select on DBA_HIST_DB_CACHE_ADVICE to bps; +grant select on DBA_HIST_DLM_MISC to bps; +grant select on DBA_HIST_ENQUEUE_STAT to bps; +grant select on DBA_HIST_EVENT_NAME to bps; +grant select on DBA_HIST_FILEMETRIC_HISTORY to bps; +grant select on DBA_HIST_FILESTATXS to bps; +grant select on DBA_HIST_INSTANCE_RECOVERY to bps; +grant select on DBA_HIST_INST_CACHE_TRANSFER to bps; +grant select on DBA_HIST_JAVA_POOL_ADVICE to bps; +grant select on DBA_HIST_LATCH to bps; +grant select on DBA_HIST_LATCH_CHILDREN to bps; +grant select on DBA_HIST_LATCH_MISSES_SUMMARY to bps; +grant select on DBA_HIST_LATCH_NAME to bps; +grant select on DBA_HIST_LATCH_PARENT to bps; +grant select on DBA_HIST_LIBRARYCACHE to bps; +grant select on DBA_HIST_LOG to bps; +grant select on DBA_HIST_METRIC_NAME to bps; +grant select on DBA_HIST_MTTR_TARGET_ADVICE to bps; +grant select on DBA_HIST_OPTIMIZER_ENV to bps; +grant select on DBA_HIST_OSSTAT to bps; +grant select on DBA_HIST_OSSTAT_NAME to bps; +grant select on DBA_HIST_PARAMETER to bps; +grant select on DBA_HIST_PARAMETER_NAME to bps; +grant select on DBA_HIST_PGASTAT to bps; +grant select on DBA_HIST_PGA_TARGET_ADVICE to bps; +grant select on DBA_HIST_PROCESS_MEM_SUMMARY to bps; +grant select on DBA_HIST_RESOURCE_LIMIT to bps; +grant select on DBA_HIST_ROWCACHE_SUMMARY to bps; +grant select on DBA_HIST_RULE_SET to bps; +grant select on DBA_HIST_SEG_STAT to bps; +grant select on DBA_HIST_SEG_STAT_OBJ to bps; +grant select on DBA_HIST_SERVICE_NAME to bps; +grant select on DBA_HIST_SERVICE_STAT to bps; +grant select on DBA_HIST_SERVICE_WAIT_CLASS to bps; +grant select on DBA_HIST_SESSMETRIC_HISTORY to bps; +grant select on DBA_HIST_SESS_TIME_STATS to bps; +grant select on DBA_HIST_SGA to bps; +grant select on DBA_HIST_SGASTAT to bps; +grant select on DBA_HIST_SGA_TARGET_ADVICE to bps; +grant select on DBA_HIST_SHARED_POOL_ADVICE to bps; +grant select on DBA_HIST_SNAPSHOT to bps; +grant select on DBA_HIST_SNAP_ERROR to bps; +grant select on DBA_HIST_SQLBIND to bps; +grant select on DBA_HIST_SQLSTAT to bps; +grant select on DBA_HIST_SQLTEXT to bps; +grant select on DBA_HIST_SQL_BIND_METADATA to bps; +grant select on DBA_HIST_SQL_PLAN to bps; +grant select on DBA_HIST_SQL_SUMMARY to bps; +grant select on DBA_HIST_SQL_WORKAREA_HSTGRM to bps; +grant select on DBA_HIST_STAT_NAME to bps; +grant select on DBA_HIST_STREAMS_APPLY_SUM to bps; +grant select on DBA_HIST_STREAMS_CAPTURE to bps; +grant select on DBA_HIST_STREAMS_POOL_ADVICE to bps; +grant select on DBA_HIST_SYSMETRIC_HISTORY to bps; +grant select on DBA_HIST_SYSMETRIC_SUMMARY to bps; +grant select on DBA_HIST_SYSSTAT to bps; +grant select on DBA_HIST_SYSTEM_EVENT to bps; +grant select on DBA_HIST_SYS_TIME_MODEL to bps; +grant select on DBA_HIST_TABLESPACE_STAT to bps; +grant select on DBA_HIST_TBSPC_SPACE_USAGE to bps; +grant select on DBA_HIST_TEMPFILE to bps; +grant select on DBA_HIST_TEMPSTATXS to bps; +grant select on DBA_HIST_THREAD to bps; +grant select on DBA_HIST_UNDOSTAT to bps; +grant select on DBA_HIST_WAITCLASSMET_HISTORY to bps; +grant select on DBA_HIST_WAITSTAT to bps; +grant select on DBA_HIST_WR_CONTROL to bps; +grant select on DBA_IAS_CONSTRAINT_EXP to bps; +grant select on DBA_IAS_GEN_STMTS to bps; +grant select on DBA_IAS_GEN_STMTS_EXP to bps; +grant select on DBA_IAS_OBJECTS to bps; +grant select on DBA_IAS_OBJECTS_BASE to bps; +grant select on DBA_IAS_OBJECTS_EXP to bps; +grant select on DBA_IAS_POSTGEN_STMTS to bps; +grant select on DBA_IAS_PREGEN_STMTS to bps; +grant select on DBA_IAS_SITES to bps; +grant select on DBA_IAS_TEMPLATES to bps; +grant select on DBA_INDEXES to bps; +grant select on DBA_INDEXTYPES to bps; +grant select on DBA_INDEXTYPE_ARRAYTYPES to bps; +grant select on DBA_INDEXTYPE_COMMENTS to bps; +grant select on DBA_INDEXTYPE_OPERATORS to bps; +grant select on DBA_IND_COLUMNS to bps; +grant select on DBA_IND_EXPRESSIONS to bps; +grant select on DBA_IND_PARTITIONS to bps; +grant select on DBA_IND_STATISTICS to bps; +grant select on DBA_IND_SUBPARTITIONS to bps; +grant select on DBA_INTERNAL_TRIGGERS to bps; +grant select on DBA_JAVA_ARGUMENTS to bps; +grant select on DBA_JAVA_CLASSES to bps; +grant select on DBA_JAVA_DERIVATIONS to bps; +grant select on DBA_JAVA_FIELDS to bps; +grant select on DBA_JAVA_IMPLEMENTS to bps; +grant select on DBA_JAVA_INNERS to bps; +grant select on DBA_JAVA_LAYOUTS to bps; +grant select on DBA_JAVA_METHODS to bps; +grant select on DBA_JAVA_NCOMPS to bps; +grant select on DBA_JAVA_POLICY to bps; +grant select on DBA_JAVA_RESOLVERS to bps; +grant select on DBA_JAVA_THROWS to bps; +grant select on DBA_JOBS to bps; +grant select on DBA_JOBS_RUNNING to bps; +grant select on DBA_JOIN_IND_COLUMNS to bps; +grant select on DBA_KGLLOCK to bps; +grant select on DBA_LIBRARIES to bps; +grant select on DBA_LMT_FREE_SPACE to bps; +grant select on DBA_LMT_USED_EXTENTS to bps; +grant select on DBA_LOBS to bps; +grant select on DBA_LOB_PARTITIONS to bps; +grant select on DBA_LOB_SUBPARTITIONS to bps; +grant select on DBA_LOB_TEMPLATES to bps; +grant select on DBA_LOCK to bps; +grant select on DBA_LOCK_INTERNAL to bps; +grant select on DBA_LOGMNR_LOG to bps; +grant select on DBA_LOGMNR_PURGED_LOG to bps; +grant select on DBA_LOGMNR_SESSION to bps; +grant select on DBA_LOGSTDBY_EVENTS to bps; +grant select on DBA_LOGSTDBY_HISTORY to bps; +grant select on DBA_LOGSTDBY_LOG to bps; +grant select on DBA_LOGSTDBY_NOT_UNIQUE to bps; +grant select on DBA_LOGSTDBY_PARAMETERS to bps; +grant select on DBA_LOGSTDBY_PROGRESS to bps; +grant select on DBA_LOGSTDBY_SKIP to bps; +grant select on DBA_LOGSTDBY_SKIP_TRANSACTION to bps; +grant select on DBA_LOGSTDBY_UNSUPPORTED to bps; +grant select on DBA_LOG_GROUPS to bps; +grant select on DBA_LOG_GROUP_COLUMNS to bps; +grant select on DBA_METHOD_PARAMS to bps; +grant select on DBA_METHOD_RESULTS to bps; +grant select on DBA_MVIEWS to bps; +grant select on DBA_MVIEW_AGGREGATES to bps; +grant select on DBA_MVIEW_ANALYSIS to bps; +grant select on DBA_MVIEW_COMMENTS to bps; +grant select on DBA_MVIEW_DETAIL_RELATIONS to bps; +grant select on DBA_MVIEW_JOINS to bps; +grant select on DBA_MVIEW_KEYS to bps; +grant select on DBA_MVIEW_LOGS to bps; +grant select on DBA_MVIEW_LOG_FILTER_COLS to bps; +grant select on DBA_MVIEW_REFRESH_TIMES to bps; +grant select on DBA_NESTED_TABLES to bps; +grant select on DBA_NESTED_TABLE_COLS to bps; +grant select on DBA_OBJECTS to bps; +grant select on DBA_OBJECT_SIZE to bps; +grant select on DBA_OBJECT_TABLES to bps; +grant select on DBA_OBJ_AUDIT_OPTS to bps; +grant select on DBA_OBJ_COLATTRS to bps; +grant select on DBA_OPANCILLARY to bps; +grant select on DBA_OPARGUMENTS to bps; +grant select on DBA_OPBINDINGS to bps; +grant select on DBA_OPERATORS to bps; +grant select on DBA_OPERATOR_COMMENTS to bps; +grant select on DBA_OPTSTAT_OPERATIONS to bps; +grant select on DBA_OUTLINES to bps; +grant select on DBA_OUTLINE_HINTS to bps; +grant select on DBA_OUTSTANDING_ALERTS to bps; +grant select on DBA_PARTIAL_DROP_TABS to bps; +grant select on DBA_PART_COL_STATISTICS to bps; +grant select on DBA_PART_HISTOGRAMS to bps; +grant select on DBA_PART_INDEXES to bps; +grant select on DBA_PART_KEY_COLUMNS to bps; +grant select on DBA_PART_LOBS to bps; +grant select on DBA_PART_TABLES to bps; +grant select on DBA_PENDING_CONV_TABLES to bps; +grant select on DBA_PENDING_TRANSACTIONS to bps; +grant select on DBA_PLSQL_OBJECT_SETTINGS to bps; +grant select on DBA_POLICIES to bps; +grant select on DBA_POLICY_CONTEXTS to bps; +grant select on DBA_POLICY_GROUPS to bps; +grant select on DBA_PRIV_AUDIT_OPTS to bps; +grant select on DBA_PROCEDURES to bps; +grant select on DBA_PROFILES to bps; +grant select on DBA_PROPAGATION to bps; +grant select on DBA_PROXIES to bps; +grant select on DBA_PUBLISHED_COLUMNS to bps; +grant select on DBA_QUEUES to bps; +grant select on DBA_QUEUE_PUBLISHERS to bps; +grant select on DBA_QUEUE_SCHEDULES to bps; +grant select on DBA_QUEUE_SUBSCRIBERS to bps; +grant select on DBA_QUEUE_TABLES to bps; +grant select on DBA_RCHILD to bps; +grant select on DBA_RECOVERABLE_SCRIPT to bps; +grant select on DBA_RECOVERABLE_SCRIPT_BLOCKS to bps; +grant select on DBA_RECOVERABLE_SCRIPT_ERRORS to bps; +grant select on DBA_RECOVERABLE_SCRIPT_PARAMS to bps; +grant select on DBA_RECYCLEBIN to bps; +grant select on DBA_REDEFINITION_ERRORS to bps; +grant select on DBA_REDEFINITION_OBJECTS to bps; +grant select on DBA_REFRESH to bps; +grant select on DBA_REFRESH_CHILDREN to bps; +grant select on DBA_REFS to bps; +grant select on DBA_REGISTERED_ARCHIVED_LOG to bps; +grant select on DBA_REGISTERED_MVIEWS to bps; +grant select on DBA_REGISTERED_MVIEW_GROUPS to bps; +grant select on DBA_REGISTERED_SNAPSHOTS to bps; +grant select on DBA_REGISTERED_SNAPSHOT_GROUPS to bps; +grant select on DBA_REGISTRY to bps; +grant select on DBA_REGISTRY_HIERARCHY to bps; +grant select on DBA_REGISTRY_HISTORY to bps; +grant select on DBA_REGISTRY_LOG to bps; +grant select on DBA_REPAUDIT_ATTRIBUTE to bps; +grant select on DBA_REPAUDIT_COLUMN to bps; +grant select on DBA_REPCAT to bps; +grant select on DBA_REPCATLOG to bps; +grant select on DBA_REPCAT_EXCEPTIONS to bps; +grant select on DBA_REPCAT_REFRESH_TEMPLATES to bps; +grant select on DBA_REPCAT_TEMPLATE_OBJECTS to bps; +grant select on DBA_REPCAT_TEMPLATE_PARMS to bps; +grant select on DBA_REPCAT_TEMPLATE_SITES to bps; +grant select on DBA_REPCAT_USER_AUTHORIZATIONS to bps; +grant select on DBA_REPCAT_USER_PARM_VALUES to bps; +grant select on DBA_REPCOLUMN to bps; +grant select on DBA_REPCOLUMN_GROUP to bps; +grant select on DBA_REPCONFLICT to bps; +grant select on DBA_REPDDL to bps; +grant select on DBA_REPEXTENSIONS to bps; +grant select on DBA_REPFLAVORS to bps; +grant select on DBA_REPFLAVOR_COLUMNS to bps; +grant select on DBA_REPFLAVOR_OBJECTS to bps; +grant select on DBA_REPGENERATED to bps; +grant select on DBA_REPGENOBJECTS to bps; +grant select on DBA_REPGROUP to bps; +grant select on DBA_REPGROUPED_COLUMN to bps; +grant select on DBA_REPGROUP_PRIVILEGES to bps; +grant select on DBA_REPKEY_COLUMNS to bps; +grant select on DBA_REPOBJECT to bps; +grant select on DBA_REPPARAMETER_COLUMN to bps; +grant select on DBA_REPPRIORITY to bps; +grant select on DBA_REPPRIORITY_GROUP to bps; +grant select on DBA_REPPROP to bps; +grant select on DBA_REPRESOLUTION to bps; +grant select on DBA_REPRESOLUTION_METHOD to bps; +grant select on DBA_REPRESOLUTION_STATISTICS to bps; +grant select on DBA_REPRESOL_STATS_CONTROL to bps; +grant select on DBA_REPSCHEMA to bps; +grant select on DBA_REPSITES to bps; +grant select on DBA_REPSITES_NEW to bps; +grant select on DBA_RESOURCE_INCARNATIONS to bps; +grant select on DBA_RESUMABLE to bps; +grant select on DBA_REWRITE_EQUIVALENCES to bps; +grant select on DBA_RGROUP to bps; +grant select on DBA_ROLES to bps; +grant select on DBA_ROLE_PRIVS to bps; +grant select on DBA_ROLLBACK_SEGS to bps; +grant select on DBA_RSRC_CONSUMER_GROUPS to bps; +grant select on DBA_RSRC_CONSUMER_GROUP_PRIVS to bps; +grant select on DBA_RSRC_GROUP_MAPPINGS to bps; +grant select on DBA_RSRC_MANAGER_SYSTEM_PRIVS to bps; +grant select on DBA_RSRC_MAPPING_PRIORITY to bps; +grant select on DBA_RSRC_PLANS to bps; +grant select on DBA_RSRC_PLAN_DIRECTIVES to bps; +grant select on DBA_RULES to bps; +grant select on DBA_RULESETS to bps; +grant select on DBA_RULE_SETS to bps; +grant select on DBA_RULE_SET_RULES to bps; +grant select on DBA_SCHEDULER_CHAINS to bps; +grant select on DBA_SCHEDULER_CHAIN_RULES to bps; +grant select on DBA_SCHEDULER_CHAIN_STEPS to bps; +grant select on DBA_SCHEDULER_GLOBAL_ATTRIBUTE to bps; +grant select on DBA_SCHEDULER_JOBS to bps; +grant select on DBA_SCHEDULER_JOB_ARGS to bps; +grant select on DBA_SCHEDULER_JOB_CLASSES to bps; +grant select on DBA_SCHEDULER_JOB_LOG to bps; +grant select on DBA_SCHEDULER_JOB_RUN_DETAILS to bps; +grant select on DBA_SCHEDULER_PROGRAMS to bps; +grant select on DBA_SCHEDULER_PROGRAM_ARGS to bps; +grant select on DBA_SCHEDULER_RUNNING_CHAINS to bps; +grant select on DBA_SCHEDULER_RUNNING_JOBS to bps; +grant select on DBA_SCHEDULER_SCHEDULES to bps; +grant select on DBA_SCHEDULER_WINDOWS to bps; +grant select on DBA_SCHEDULER_WINDOW_DETAILS to bps; +grant select on DBA_SCHEDULER_WINDOW_GROUPS to bps; +grant select on DBA_SCHEDULER_WINDOW_LOG to bps; +grant select on DBA_SCHEDULER_WINGROUP_MEMBERS to bps; +grant select on DBA_SECONDARY_OBJECTS to bps; +grant select on DBA_SEC_RELEVANT_COLS to bps; +grant select on DBA_SEGMENTS to bps; +grant select on DBA_SEGMENTS_OLD to bps; +grant select on DBA_SEQUENCES to bps; +grant select on DBA_SERVER_REGISTRY to bps; +grant select on DBA_SERVICES to bps; +grant select on DBA_SNAPSHOTS to bps; +grant select on DBA_SNAPSHOT_LOGS to bps; +grant select on DBA_SOURCE to bps; +grant select on DBA_SOURCE_TABLES to bps; +grant select on DBA_SQLJ_TYPES to bps; +grant select on DBA_SQLJ_TYPE_ATTRS to bps; +grant select on DBA_SQLJ_TYPE_METHODS to bps; +grant select on DBA_SQLSET to bps; +grant select on DBA_SQLSET_BINDS to bps; +grant select on DBA_SQLSET_PLANS to bps; +grant select on DBA_SQLSET_REFERENCES to bps; +grant select on DBA_SQLSET_STATEMENTS to bps; +grant select on DBA_SQLTUNE_BINDS to bps; +grant select on DBA_SQLTUNE_PLANS to bps; +grant select on DBA_SQLTUNE_RATIONALE_PLAN to bps; +grant select on DBA_SQLTUNE_STATISTICS to bps; +grant select on DBA_SQL_PROFILES to bps; +grant select on DBA_STMT_AUDIT_OPTS to bps; +grant select on DBA_STORED_SETTINGS to bps; +grant select on DBA_STREAMS_ADD_COLUMN to bps; +grant select on DBA_STREAMS_ADMINISTRATOR to bps; +grant select on DBA_STREAMS_DELETE_COLUMN to bps; +grant select on DBA_STREAMS_GLOBAL_RULES to bps; +grant select on DBA_STREAMS_MESSAGE_CONSUMERS to bps; +grant select on DBA_STREAMS_MESSAGE_RULES to bps; +grant select on DBA_STREAMS_NEWLY_SUPPORTED to bps; +grant select on DBA_STREAMS_RENAME_COLUMN to bps; +grant select on DBA_STREAMS_RENAME_SCHEMA to bps; +grant select on DBA_STREAMS_RENAME_TABLE to bps; +grant select on DBA_STREAMS_RULES to bps; +grant select on DBA_STREAMS_SCHEMA_RULES to bps; +grant select on DBA_STREAMS_TABLE_RULES to bps; +grant select on DBA_STREAMS_TRANSFORMATIONS to bps; +grant select on DBA_STREAMS_TRANSFORM_FUNCTION to bps; +grant select on DBA_STREAMS_UNSUPPORTED to bps; +grant select on DBA_SUBPARTITION_TEMPLATES to bps; +grant select on DBA_SUBPART_COL_STATISTICS to bps; +grant select on DBA_SUBPART_HISTOGRAMS to bps; +grant select on DBA_SUBPART_KEY_COLUMNS to bps; +grant select on DBA_SUBSCRIBED_COLUMNS to bps; +grant select on DBA_SUBSCRIBED_TABLES to bps; +grant select on DBA_SUBSCRIPTIONS to bps; +grant select on DBA_SUMMARIES to bps; +grant select on DBA_SUMMARY_AGGREGATES to bps; +grant select on DBA_SUMMARY_DETAIL_TABLES to bps; +grant select on DBA_SUMMARY_JOINS to bps; +grant select on DBA_SUMMARY_KEYS to bps; +grant select on DBA_SYNONYMS to bps; +grant select on DBA_SYS_PRIVS to bps; +grant select on DBA_TABLES to bps; +grant select on DBA_TABLESPACES to bps; +grant select on DBA_TABLESPACE_GROUPS to bps; +grant select on DBA_TABLESPACE_USAGE_METRICS to bps; +grant select on DBA_TAB_COLS to bps; +grant select on DBA_TAB_COLUMNS to bps; +grant select on DBA_TAB_COL_STATISTICS to bps; +grant select on DBA_TAB_COMMENTS to bps; +grant select on DBA_TAB_HISTOGRAMS to bps; +grant select on DBA_TAB_MODIFICATIONS to bps; +grant select on DBA_TAB_PARTITIONS to bps; +grant select on DBA_TAB_PRIVS to bps; +grant select on DBA_TAB_STATISTICS to bps; +grant select on DBA_TAB_STATS_HISTORY to bps; +grant select on DBA_TAB_SUBPARTITIONS to bps; +grant select on DBA_TEMPLATE_REFGROUPS to bps; +grant select on DBA_TEMPLATE_TARGETS to bps; +grant select on DBA_TEMP_FILES to bps; +grant select on DBA_THRESHOLDS to bps; +grant select on DBA_TRANSFORMATIONS to bps; +grant select on DBA_TRIGGERS to bps; +grant select on DBA_TRIGGER_COLS to bps; +grant select on DBA_TSM_DESTINATION to bps; +grant select on DBA_TSM_HISTORY to bps; +grant select on DBA_TSM_SOURCE to bps; +grant select on DBA_TS_QUOTAS to bps; +grant select on DBA_TUNE_MVIEW to bps; +grant select on DBA_TYPES to bps; +grant select on DBA_TYPE_ATTRS to bps; +grant select on DBA_TYPE_METHODS to bps; +grant select on DBA_TYPE_VERSIONS to bps; +grant select on DBA_UNDO_EXTENTS to bps; +grant select on DBA_UNUSED_COL_TABS to bps; +grant select on DBA_UPDATABLE_COLUMNS to bps; +grant select on DBA_USERS to bps; +grant select on DBA_USTATS to bps; +grant select on DBA_VARRAYS to bps; +grant select on DBA_VIEWS to bps; +grant select on DBA_WAITERS to bps; +grant select on DBA_WARNING_SETTINGS to bps; +grant select on DBA_WORKSPACES to bps; +grant select on DBA_WORKSPACE_SESSIONS to bps; +grant select on DBA_XML_INDEXES to bps; +grant select on DBA_XML_SCHEMAS to bps; +grant select on DBA_XML_TABLES to bps; +grant select on DBA_XML_TAB_COLS to bps; +grant select on DBA_XML_VIEWS to bps; +grant select on DBA_XML_VIEW_COLS to bps; + 'GRANTSELECTON'||VIEW_NAME||'TOBPS;' +------------------------------------------------------ +grant select on V_$ACCESS to bps; +grant select on V_$ACTIVE_INSTANCES to bps; +grant select on V_$ACTIVE_SERVICES to bps; +grant select on V_$ACTIVE_SESSION_HISTORY to bps; +grant select on V_$ACTIVE_SESS_POOL_MTH to bps; +grant select on V_$ADVISOR_PROGRESS to bps; +grant select on V_$ALERT_TYPES to bps; +grant select on V_$AQ to bps; +grant select on V_$AQ1 to bps; +grant select on V_$ARCHIVE to bps; +grant select on V_$ARCHIVED_LOG to bps; +grant select on V_$ARCHIVE_DEST to bps; +grant select on V_$ARCHIVE_DEST_STATUS to bps; +grant select on V_$ARCHIVE_GAP to bps; +grant select on V_$ARCHIVE_PROCESSES to bps; +grant select on V_$ASM_ALIAS to bps; +grant select on V_$ASM_CLIENT to bps; +grant select on V_$ASM_DISK to bps; +grant select on V_$ASM_DISKGROUP to bps; +grant select on V_$ASM_DISKGROUP_STAT to bps; +grant select on V_$ASM_DISK_STAT to bps; +grant select on V_$ASM_FILE to bps; +grant select on V_$ASM_OPERATION to bps; +grant select on V_$ASM_TEMPLATE to bps; +grant select on V_$AW_AGGREGATE_OP to bps; +grant select on V_$AW_ALLOCATE_OP to bps; +grant select on V_$AW_CALC to bps; +grant select on V_$AW_LONGOPS to bps; +grant select on V_$AW_OLAP to bps; +grant select on V_$AW_SESSION_INFO to bps; +grant select on V_$BACKUP to bps; +grant select on V_$BACKUP_ARCHIVELOG_DETAILS to bps; +grant select on V_$BACKUP_ARCHIVELOG_SUMMARY to bps; +grant select on V_$BACKUP_ASYNC_IO to bps; +grant select on V_$BACKUP_CONTROLFILE_DETAILS to bps; +grant select on V_$BACKUP_CONTROLFILE_SUMMARY to bps; +grant select on V_$BACKUP_COPY_DETAILS to bps; +grant select on V_$BACKUP_COPY_SUMMARY to bps; +grant select on V_$BACKUP_CORRUPTION to bps; +grant select on V_$BACKUP_DATAFILE to bps; +grant select on V_$BACKUP_DATAFILE_DETAILS to bps; +grant select on V_$BACKUP_DATAFILE_SUMMARY to bps; +grant select on V_$BACKUP_DEVICE to bps; +grant select on V_$BACKUP_FILES to bps; +grant select on V_$BACKUP_PIECE to bps; +grant select on V_$BACKUP_PIECE_DETAILS to bps; +grant select on V_$BACKUP_REDOLOG to bps; +grant select on V_$BACKUP_SET to bps; +grant select on V_$BACKUP_SET_DETAILS to bps; +grant select on V_$BACKUP_SET_SUMMARY to bps; +grant select on V_$BACKUP_SPFILE to bps; +grant select on V_$BACKUP_SPFILE_DETAILS to bps; +grant select on V_$BACKUP_SPFILE_SUMMARY to bps; +grant select on V_$BACKUP_SYNC_IO to bps; +grant select on V_$BGPROCESS to bps; +grant select on V_$BH to bps; +grant select on V_$BLOCKING_QUIESCE to bps; +grant select on V_$BLOCK_CHANGE_TRACKING to bps; +grant select on V_$BSP to bps; +grant select on V_$BUFFERED_PUBLISHERS to bps; +grant select on V_$BUFFERED_QUEUES to bps; +grant select on V_$BUFFERED_SUBSCRIBERS to bps; +grant select on V_$BUFFER_POOL to bps; +grant select on V_$BUFFER_POOL_STATISTICS to bps; +grant select on V_$CIRCUIT to bps; +grant select on V_$CLASS_CACHE_TRANSFER to bps; +grant select on V_$CLASS_PING to bps; +grant select on V_$CLIENT_STATS to bps; +grant select on V_$CLUSTER_INTERCONNECTS to bps; +grant select on V_$CONFIGURED_INTERCONNECTS to bps; +grant select on V_$CONTEXT to bps; +grant select on V_$CONTROLFILE to bps; +grant select on V_$CONTROLFILE_RECORD_SECTION to bps; +grant select on V_$COPY_CORRUPTION to bps; +grant select on V_$CR_BLOCK_SERVER to bps; +grant select on V_$CURRENT_BLOCK_SERVER to bps; +grant select on V_$DATABASE to bps; +grant select on V_$DATABASE_BLOCK_CORRUPTION to bps; +grant select on V_$DATABASE_INCARNATION to bps; +grant select on V_$DATAFILE to bps; +grant select on V_$DATAFILE_COPY to bps; +grant select on V_$DATAFILE_HEADER to bps; +grant select on V_$DATAGUARD_CONFIG to bps; +grant select on V_$DATAGUARD_STATS to bps; +grant select on V_$DATAGUARD_STATUS to bps; +grant select on V_$DATAPUMP_JOB to bps; +grant select on V_$DATAPUMP_SESSION to bps; +grant select on V_$DBFILE to bps; +grant select on V_$DBLINK to bps; +grant select on V_$DB_CACHE_ADVICE to bps; +grant select on V_$DB_OBJECT_CACHE to bps; +grant select on V_$DB_PIPES to bps; +grant select on V_$DB_TRANSPORTABLE_PLATFORM to bps; +grant select on V_$DELETED_OBJECT to bps; +grant select on V_$DISPATCHER to bps; +grant select on V_$DISPATCHER_CONFIG to bps; +grant select on V_$DISPATCHER_RATE to bps; +grant select on V_$DLM_ALL_LOCKS to bps; +grant select on V_$DLM_CONVERT_LOCAL to bps; +grant select on V_$DLM_CONVERT_REMOTE to bps; +grant select on V_$DLM_LATCH to bps; +grant select on V_$DLM_LOCKS to bps; +grant select on V_$DLM_MISC to bps; +grant select on V_$DLM_RESS to bps; +grant select on V_$DLM_TRAFFIC_CONTROLLER to bps; +grant select on V_$ENABLEDPRIVS to bps; +grant select on V_$ENQUEUE_LOCK to bps; +grant select on V_$ENQUEUE_STAT to bps; +grant select on V_$ENQUEUE_STATISTICS to bps; +grant select on V_$EVENTMETRIC to bps; +grant select on V_$EVENT_HISTOGRAM to bps; +grant select on V_$EVENT_NAME to bps; +grant select on V_$EXECUTION to bps; +grant select on V_$FAST_START_SERVERS to bps; +grant select on V_$FAST_START_TRANSACTIONS to bps; +grant select on V_$FILEMETRIC to bps; +grant select on V_$FILEMETRIC_HISTORY to bps; +grant select on V_$FILESPACE_USAGE to bps; +grant select on V_$FILESTAT to bps; +grant select on V_$FILE_CACHE_TRANSFER to bps; +grant select on V_$FILE_HISTOGRAM to bps; +grant select on V_$FILE_PING to bps; +grant select on V_$FIXED_TABLE to bps; +grant select on V_$FIXED_VIEW_DEFINITION to bps; +grant select on V_$FLASHBACK_DATABASE_LOG to bps; +grant select on V_$FLASHBACK_DATABASE_LOGFILE to bps; +grant select on V_$FLASHBACK_DATABASE_STAT to bps; +grant select on V_$FLASH_RECOVERY_AREA_USAGE to bps; +grant select on V_$GCSHVMASTER_INFO to bps; +grant select on V_$GCSPFMASTER_INFO to bps; +grant select on V_$GC_ELEMENT to bps; +grant select on V_$GC_ELEMENTS_W_COLLISIONS to bps; +grant select on V_$GES_BLOCKING_ENQUEUE to bps; +grant select on V_$GES_ENQUEUE to bps; +grant select on V_$GLOBALCONTEXT to bps; +grant select on V_$GLOBAL_BLOCKED_LOCKS to bps; +grant select on V_$GLOBAL_TRANSACTION to bps; +grant select on V_$HS_AGENT to bps; +grant select on V_$HS_PARAMETER to bps; +grant select on V_$HS_SESSION to bps; +grant select on V_$HVMASTER_INFO to bps; +grant select on V_$INDEXED_FIXED_COLUMN to bps; +grant select on V_$INSTANCE to bps; +grant select on V_$INSTANCE_CACHE_TRANSFER to bps; +grant select on V_$INSTANCE_LOG_GROUP to bps; +grant select on V_$INSTANCE_RECOVERY to bps; +grant select on V_$JAVAPOOL to bps; +grant select on V_$JAVA_LIBRARY_CACHE_MEMORY to bps; +grant select on V_$JAVA_POOL_ADVICE to bps; +grant select on V_$KCCDI to bps; +grant select on V_$KCCFE to bps; +grant select on V_$LATCH to bps; +grant select on V_$LATCHHOLDER to bps; +grant select on V_$LATCHNAME to bps; +grant select on V_$LATCH_CHILDREN to bps; +grant select on V_$LATCH_MISSES to bps; +grant select on V_$LATCH_PARENT to bps; +grant select on V_$LIBRARYCACHE to bps; +grant select on V_$LIBRARY_CACHE_MEMORY to bps; +grant select on V_$LICENSE to bps; +grant select on V_$LOADISTAT to bps; +grant select on V_$LOADPSTAT to bps; +grant select on V_$LOCK to bps; +grant select on V_$LOCKED_OBJECT to bps; +grant select on V_$LOCKS_WITH_COLLISIONS to bps; +grant select on V_$LOCK_ACTIVITY to bps; +grant select on V_$LOCK_ELEMENT to bps; +grant select on V_$LOCK_TYPE to bps; +grant select on V_$LOG to bps; +grant select on V_$LOGFILE to bps; +grant select on V_$LOGHIST to bps; +grant select on V_$LOGMNR_CALLBACK to bps; +grant select on V_$LOGMNR_CONTENTS to bps; +grant select on V_$LOGMNR_DICTIONARY to bps; +grant select on V_$LOGMNR_DICTIONARY_LOAD to bps; +grant select on V_$LOGMNR_LATCH to bps; +grant select on V_$LOGMNR_LOGFILE to bps; +grant select on V_$LOGMNR_LOGS to bps; +grant select on V_$LOGMNR_PARAMETERS to bps; +grant select on V_$LOGMNR_PROCESS to bps; +grant select on V_$LOGMNR_REGION to bps; +grant select on V_$LOGMNR_SESSION to bps; +grant select on V_$LOGMNR_STATS to bps; +grant select on V_$LOGMNR_TRANSACTION to bps; +grant select on V_$LOGSTDBY to bps; +grant select on V_$LOGSTDBY_PROCESS to bps; +grant select on V_$LOGSTDBY_PROGRESS to bps; +grant select on V_$LOGSTDBY_STATE to bps; +grant select on V_$LOGSTDBY_STATS to bps; +grant select on V_$LOGSTDBY_TRANSACTION to bps; +grant select on V_$LOG_HISTORY to bps; +grant select on V_$MANAGED_STANDBY to bps; +grant select on V_$MAP_COMP_LIST to bps; +grant select on V_$MAP_ELEMENT to bps; +grant select on V_$MAP_EXT_ELEMENT to bps; +grant select on V_$MAP_FILE to bps; +grant select on V_$MAP_FILE_EXTENT to bps; +grant select on V_$MAP_FILE_IO_STACK to bps; +grant select on V_$MAP_LIBRARY to bps; +grant select on V_$MAP_SUBELEMENT to bps; +grant select on V_$MAX_ACTIVE_SESS_TARGET_MTH to bps; +grant select on V_$METRIC to bps; +grant select on V_$METRICGROUP to bps; +grant select on V_$METRICNAME to bps; +grant select on V_$METRIC_HISTORY to bps; +grant select on V_$MTTR_TARGET_ADVICE to bps; +grant select on V_$MUTEX_SLEEP to bps; +grant select on V_$MUTEX_SLEEP_HISTORY to bps; +grant select on V_$MVREFRESH to bps; +grant select on V_$MYSTAT to bps; +grant select on V_$NLS_PARAMETERS to bps; +grant select on V_$NLS_VALID_VALUES to bps; +grant select on V_$OBJECT_DEPENDENCY to bps; +grant select on V_$OBSOLETE_PARAMETER to bps; +grant select on V_$OFFLINE_RANGE to bps; +grant select on V_$OPEN_CURSOR to bps; +grant select on V_$OPTION to bps; +grant select on V_$OSSTAT to bps; +grant select on V_$PARALLEL_DEGREE_LIMIT_MTH to bps; +grant select on V_$PARAMETER to bps; +grant select on V_$PARAMETER2 to bps; +grant select on V_$PARAMETER_VALID_VALUES to bps; +grant select on V_$PGASTAT to bps; +grant select on V_$PGA_TARGET_ADVICE to bps; +grant select on V_$PGA_TARGET_ADVICE_HISTOGRAM to bps; +grant select on V_$PQ_SESSTAT to bps; +grant select on V_$PQ_SLAVE to bps; +grant select on V_$PQ_SYSSTAT to bps; +grant select on V_$PQ_TQSTAT to bps; +grant select on V_$PROCESS to bps; +grant select on V_$PROCESS_MEMORY to bps; +grant select on V_$PROCESS_MEMORY_DETAIL to bps; +grant select on V_$PROCESS_MEMORY_DETAIL_PROG to bps; +grant select on V_$PROPAGATION_RECEIVER to bps; +grant select on V_$PROPAGATION_SENDER to bps; +grant select on V_$PROXY_ARCHIVEDLOG to bps; +grant select on V_$PROXY_ARCHIVELOG_DETAILS to bps; +grant select on V_$PROXY_ARCHIVELOG_SUMMARY to bps; +grant select on V_$PROXY_COPY_DETAILS to bps; +grant select on V_$PROXY_COPY_SUMMARY to bps; +grant select on V_$PROXY_DATAFILE to bps; +grant select on V_$PWFILE_USERS to bps; +grant select on V_$PX_BUFFER_ADVICE to bps; +grant select on V_$PX_PROCESS to bps; +grant select on V_$PX_PROCESS_SYSSTAT to bps; +grant select on V_$PX_SESSION to bps; +grant select on V_$PX_SESSTAT to bps; +grant select on V_$QUEUE to bps; +grant select on V_$QUEUEING_MTH to bps; +grant select on V_$RECOVERY_FILE_DEST to bps; +grant select on V_$RECOVERY_FILE_STATUS to bps; +grant select on V_$RECOVERY_LOG to bps; +grant select on V_$RECOVERY_PROGRESS to bps; +grant select on V_$RECOVERY_STATUS to bps; +grant select on V_$RECOVER_FILE to bps; +grant select on V_$REPLPROP to bps; +grant select on V_$REPLQUEUE to bps; +grant select on V_$REQDIST to bps; +grant select on V_$RESERVED_WORDS to bps; +grant select on V_$RESOURCE to bps; +grant select on V_$RESOURCE_LIMIT to bps; +grant select on V_$RESTORE_POINT to bps; +grant select on V_$RESUMABLE to bps; +grant select on V_$RFS_THREAD to bps; +grant select on V_$RMAN_BACKUP_JOB_DETAILS to bps; +grant select on V_$RMAN_BACKUP_SUBJOB_DETAILS to bps; +grant select on V_$RMAN_BACKUP_TYPE to bps; +grant select on V_$RMAN_CONFIGURATION to bps; +grant select on V_$RMAN_OUTPUT to bps; +grant select on V_$RMAN_STATUS to bps; +grant select on V_$ROLLNAME to bps; +grant select on V_$ROLLSTAT to bps; +grant select on V_$ROWCACHE to bps; +grant select on V_$ROWCACHE_PARENT to bps; +grant select on V_$ROWCACHE_SUBORDINATE to bps; +grant select on V_$RSRC_CONSUMER_GROUP to bps; +grant select on V_$RSRC_CONSUMER_GROUP_CPU_MTH to bps; +grant select on V_$RSRC_CONS_GROUP_HISTORY to bps; +grant select on V_$RSRC_PLAN to bps; +grant select on V_$RSRC_PLAN_CPU_MTH to bps; +grant select on V_$RSRC_PLAN_HISTORY to bps; +grant select on V_$RSRC_SESSION_INFO to bps; +grant select on V_$RULE to bps; +grant select on V_$RULE_SET to bps; +grant select on V_$RULE_SET_AGGREGATE_STATS to bps; +grant select on V_$SCHEDULER_RUNNING_JOBS to bps; +grant select on V_$SEGMENT_STATISTICS to bps; +grant select on V_$SEGSTAT to bps; +grant select on V_$SEGSTAT_NAME to bps; +grant select on V_$SERVICEMETRIC to bps; +grant select on V_$SERVICEMETRIC_HISTORY to bps; +grant select on V_$SERVICES to bps; +grant select on V_$SERVICE_EVENT to bps; +grant select on V_$SERVICE_STATS to bps; +grant select on V_$SERVICE_WAIT_CLASS to bps; +grant select on V_$SERV_MOD_ACT_STATS to bps; +grant select on V_$SESSION to bps; +grant select on V_$SESSION_CONNECT_INFO to bps; +grant select on V_$SESSION_CURSOR_CACHE to bps; +grant select on V_$SESSION_EVENT to bps; +grant select on V_$SESSION_LONGOPS to bps; +grant select on V_$SESSION_OBJECT_CACHE to bps; +grant select on V_$SESSION_WAIT to bps; +grant select on V_$SESSION_WAIT_CLASS to bps; +grant select on V_$SESSION_WAIT_HISTORY to bps; +grant select on V_$SESSMETRIC to bps; +grant select on V_$SESSTAT to bps; +grant select on V_$SESS_IO to bps; +grant select on V_$SESS_TIME_MODEL to bps; +grant select on V_$SES_OPTIMIZER_ENV to bps; +grant select on V_$SGA to bps; +grant select on V_$SGAINFO to bps; +grant select on V_$SGASTAT to bps; +grant select on V_$SGA_CURRENT_RESIZE_OPS to bps; +grant select on V_$SGA_DYNAMIC_COMPONENTS to bps; +grant select on V_$SGA_DYNAMIC_FREE_MEMORY to bps; +grant select on V_$SGA_RESIZE_OPS to bps; +grant select on V_$SGA_TARGET_ADVICE to bps; +grant select on V_$SHARED_POOL_ADVICE to bps; +grant select on V_$SHARED_POOL_RESERVED to bps; +grant select on V_$SHARED_SERVER to bps; +grant select on V_$SHARED_SERVER_MONITOR to bps; +grant select on V_$SORT_SEGMENT to bps; +grant select on V_$SORT_USAGE to bps; +grant select on V_$SPPARAMETER to bps; +grant select on V_$SQL to bps; +grant select on V_$SQLAREA to bps; +grant select on V_$SQLAREA_PLAN_HASH to bps; +grant select on V_$SQLSTATS to bps; +grant select on V_$SQLTEXT to bps; +grant select on V_$SQLTEXT_WITH_NEWLINES to bps; +grant select on V_$SQL_BIND_CAPTURE to bps; +grant select on V_$SQL_BIND_DATA to bps; +grant select on V_$SQL_BIND_METADATA to bps; +grant select on V_$SQL_CURSOR to bps; +grant select on V_$SQL_JOIN_FILTER to bps; +grant select on V_$SQL_OPTIMIZER_ENV to bps; +grant select on V_$SQL_PLAN to bps; +grant select on V_$SQL_PLAN_STATISTICS to bps; +grant select on V_$SQL_PLAN_STATISTICS_ALL to bps; +grant select on V_$SQL_REDIRECTION to bps; +grant select on V_$SQL_SHARED_CURSOR to bps; +grant select on V_$SQL_SHARED_MEMORY to bps; +grant select on V_$SQL_WORKAREA to bps; +grant select on V_$SQL_WORKAREA_ACTIVE to bps; +grant select on V_$SQL_WORKAREA_HISTOGRAM to bps; +grant select on V_$STANDBY_APPLY_SNAPSHOT to bps; +grant select on V_$STANDBY_LOG to bps; +grant select on V_$STATISTICS_LEVEL to bps; +grant select on V_$STATNAME to bps; +grant select on V_$STREAMS_APPLY_COORDINATOR to bps; +grant select on V_$STREAMS_APPLY_READER to bps; +grant select on V_$STREAMS_APPLY_SERVER to bps; +grant select on V_$STREAMS_CAPTURE to bps; +grant select on V_$STREAMS_POOL_ADVICE to bps; +grant select on V_$STREAMS_TRANSACTION to bps; +grant select on V_$SUBCACHE to bps; +grant select on V_$SYSAUX_OCCUPANTS to bps; +grant select on V_$SYSMETRIC to bps; +grant select on V_$SYSMETRIC_HISTORY to bps; +grant select on V_$SYSMETRIC_SUMMARY to bps; +grant select on V_$SYSSTAT to bps; +grant select on V_$SYSTEM_CURSOR_CACHE to bps; +grant select on V_$SYSTEM_EVENT to bps; +grant select on V_$SYSTEM_PARAMETER to bps; +grant select on V_$SYSTEM_PARAMETER2 to bps; +grant select on V_$SYSTEM_WAIT_CLASS to bps; +grant select on V_$SYS_OPTIMIZER_ENV to bps; +grant select on V_$SYS_TIME_MODEL to bps; +grant select on V_$TABLESPACE to bps; +grant select on V_$TEMPFILE to bps; +grant select on V_$TEMPORARY_LOBS to bps; +grant select on V_$TEMPSTAT to bps; +grant select on V_$TEMP_CACHE_TRANSFER to bps; +grant select on V_$TEMP_EXTENT_MAP to bps; +grant select on V_$TEMP_EXTENT_POOL to bps; +grant select on V_$TEMP_HISTOGRAM to bps; +grant select on V_$TEMP_PING to bps; +grant select on V_$TEMP_SPACE_HEADER to bps; +grant select on V_$THREAD to bps; +grant select on V_$THRESHOLD_TYPES to bps; +grant select on V_$TIMER to bps; +grant select on V_$TIMEZONE_FILE to bps; +grant select on V_$TIMEZONE_NAMES to bps; +grant select on V_$TRANSACTION to bps; +grant select on V_$TRANSACTION_ENQUEUE to bps; +grant select on V_$TRANSPORTABLE_PLATFORM to bps; +grant select on V_$TSM_SESSIONS to bps; +grant select on V_$TYPE_SIZE to bps; +grant select on V_$UNDOSTAT to bps; +grant select on V_$UNUSABLE_BACKUPFILE_DETAILS to bps; +grant select on V_$VERSION to bps; +grant select on V_$VPD_POLICY to bps; +grant select on V_$WAITCLASSMETRIC to bps; +grant select on V_$WAITCLASSMETRIC_HISTORY to bps; +grant select on V_$WAITSTAT to bps; +grant select on V_$WALLET to bps; +grant select on V_$XML_AUDIT_TRAIL to bps; +grant select on V_$_LOCK to bps; diff --git a/AppendixA/create_user_sub.txt b/AppendixA/create_user_sub.txt new file mode 100644 index 0000000..585f024 --- /dev/null +++ b/AppendixA/create_user_sub.txt @@ -0,0 +1,2795 @@ +SP2-0734: unknown command beginning "'GRANTSELE..." - rest of line ignored. + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + +SP2-0734: unknown command beginning "'GRANTSELE..." - rest of line ignored. + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + + +Grant succeeded. + diff --git a/AppendixA/drop_user.sql b/AppendixA/drop_user.sql new file mode 100644 index 0000000..7db4f03 --- /dev/null +++ b/AppendixA/drop_user.sql @@ -0,0 +1,2 @@ +connect sys as sysdba; +drop user bps cascade; diff --git a/Chapter01/README.txt b/Chapter01/README.txt new file mode 100644 index 0000000..fe63ebc --- /dev/null +++ b/Chapter01/README.txt @@ -0,0 +1,142 @@ +README.txt for Chapter 1 +by Donald J. Bales on 4/15/2007 + +This is the first of eleven example source directories for the book +"Beginning PL/SQL: From Novice to Professional". Each example source directory +for this book contains the source code for the examples in the book, and a +subdirectory solutions that contains the solutions to the exercises. + +I doubt that my source code examples are perfect. So don't assume they are. +I've only tested the source following the text of the book 3 times, so I may +have missed something. If you would like to send me a note on any errors, +please feel free to email me at don@donaldbales.com. Include the name of the +source file and a description of the suspected defect. I will then correct the +problem (given time) and repost my examples. + +If you'd like to see more examples of object-relational SQL and PL/SQL, or want +to post your own, please visit http://www.pl-sql.org. + + +OBJECT NAME DESCRIPTION +--------------------------------------- -------------------------------------- +author.tab Create table AUTHOR + +author.upd Update table AUTHOR + +author_100.ins Insert Edgar F Codd into AUTHOR + +author_200.ins Insert Chris J Date into AUTHOR + +author_300.del Delete Hugh Darwen from AUTHOR + +author_300.ins Insert Hugh Darwen into AUTHOR + +author_bir.trg Create a before insert for each row + trigger against AUTHOR to prevent the + insert of the name Jonathan Gennick + +author_name.sql Query author names + +author_name_before_1940.sql Query author names born before 1940 + +author_pk.pkc Create a primary key constraint + against AUTHOR + +author_publication.vw Create a view of author publications + +author_publication_from_join.sql Query author publications using the + newer table join sytax + +author_publication_from_join.vw Create a view of author publications + using the newer table join syntax + +author_publication_where_join.sql Query author publications using the + traditional table join syntax + +author_publication_where_join.vw Create a view of author publications + using the traditional table join + syntax + +author_uk1.ndx Create a unique index against AUTHOR + +author_uk1.ukc Create a unique constraint against + AUTHOR + +be.sql Show package body compilation errors + +ci.sql Compile invalid objects + +solutions\coauthor_publication.sql Query coauthored publications + +solutions\coauthor.sql Query coauthor names + +desc.sql Describe an object + +fe.sql Show function compilation errors + +solutions\gender_t.ins Insert gender code values + +solutions\gender_t.tab Create table GENDER_T + +solutions\hazard_level_t.ins Insert hazard level code values + +solutions\hazard_level_t.tab Create table HAZARD_LEVEL_T + +logical_assignment_t.tab Create table LOGICAL_ASSIGNMENT_T + +logical_workplace_t.tab Create table LOGICAL_WORKPLACE_T + +login.sql Set my SQL*Plus session defaults + +pe.sql Show procedure compilation errors + +solutions\physical_assignment_t.tab Create table PHYSICAL_ASSIGNMENT_T + +solutions\physical_workplace_t.tab Create table PHYSICAL_WORKPLACE_T + +pl.sql Stored procedure PL, a short cut for + calling SYS.DBMS_OUTPUT.put_line() + +publication.ins Insert publications into PUBLICATION + +solutions\publication.tab Create table PUBLICATION + +solutions\publication.upd Update publications in PUBLICATION + +solutions\publication_100.ins Insert author 100's publications into + PUBLICATION + +solutions\publication_200.ins Insert author 200's publications into + PUBLICATION + +solutions\publication_300.del Delete author 300's publications from + PUBLICATION + +solutions\publication_300.ins Insert author 300's publications into + PUBLICATION + +publication_fk1.fkc Create a foreign key constraint against + PUBLICATION + +solutions\publication_k1.ndx Create a non-unique index against + PUBLICATION + +solutions\publication_pk.pkc Create a primary key constraint against + PUBLICATION + +se.sql Show package specification compilation + errors + +solutions\work_assignment_t.tab Create table WORK_ASSIGNMENT_T + +solutions\work_t.tab Create table WORK_T + +worker_t.tab Create table WORKER_T + +worker_type_t.ins Insert worker type code values + +worker_type_t.tab Create table WORKER_TYPE_T + +solutions\workplace_type_t.ins Insert workplace type code values + +solutions\workplace_type_t.tab Create table WORKPLACE_TYPE_T diff --git a/Chapter01/author.tab b/Chapter01/author.tab new file mode 100644 index 0000000..9a466fc --- /dev/null +++ b/Chapter01/author.tab @@ -0,0 +1,6 @@ +CREATE TABLE author ( +id number, +name varchar(100), +birth_date date, +gender varchar2(30) ); + diff --git a/Chapter01/author.upd b/Chapter01/author.upd new file mode 100644 index 0000000..89ab8eb --- /dev/null +++ b/Chapter01/author.upd @@ -0,0 +1,4 @@ +UPDATE author +set name = upper(name); + +COMMIT; diff --git a/Chapter01/author_100.ins b/Chapter01/author_100.ins new file mode 100644 index 0000000..e5c6d1c --- /dev/null +++ b/Chapter01/author_100.ins @@ -0,0 +1,11 @@ +INSERT INTO author ( + id, + name, + birth_date, + gender ) +VALUES ( + 100, + 'Edgar F Codd', + to_date('19230823', 'YYYYMMDD'), + 'MALE' ); +COMMIT; diff --git a/Chapter01/author_200.ins b/Chapter01/author_200.ins new file mode 100644 index 0000000..95a4beb --- /dev/null +++ b/Chapter01/author_200.ins @@ -0,0 +1,12 @@ +INSERT INTO author ( + id, + name, + birth_date, + gender ) +SELECT 200, + 'Chris J Date', + NULL, + 'MALE' +from DUAL; + +COMMIT; diff --git a/Chapter01/author_300.del b/Chapter01/author_300.del new file mode 100644 index 0000000..91d933c --- /dev/null +++ b/Chapter01/author_300.del @@ -0,0 +1,2 @@ +DELETE FROM author +WHERE id = 300; diff --git a/Chapter01/author_300.ins b/Chapter01/author_300.ins new file mode 100644 index 0000000..e5d8629 --- /dev/null +++ b/Chapter01/author_300.ins @@ -0,0 +1,16 @@ +INSERT INTO author ( + id, + name, + birth_date, + gender ) +SELECT 300, + 'Hugh Darwen', + NULL, + 'MALE' +from dual d +where not exists ( + SELECT 1 + FROM author x + WHERE x.id = '300' ); + +COMMIT; diff --git a/Chapter01/author_bir.trg b/Chapter01/author_bir.trg new file mode 100644 index 0000000..eae33dd --- /dev/null +++ b/Chapter01/author_bir.trg @@ -0,0 +1,10 @@ +CREATE TRIGGER author_bir +BEFORE INSERT ON author +FOR EACH ROW + +begin + if upper(:new.name) = 'JONATHAN GENNICK' then + raise_application_error(20000, 'Sorry, that genius is not allowed.'); + end if; +end; +/ diff --git a/Chapter01/author_name.sql b/Chapter01/author_name.sql new file mode 100644 index 0000000..d5a20b3 --- /dev/null +++ b/Chapter01/author_name.sql @@ -0,0 +1,3 @@ +SELECT name +FROM author +ORDER BY name; diff --git a/Chapter01/author_name_before_1940.sql b/Chapter01/author_name_before_1940.sql new file mode 100644 index 0000000..c93d4f6 --- /dev/null +++ b/Chapter01/author_name_before_1940.sql @@ -0,0 +1,4 @@ +SELECT name +FROM author +WHERE birth_date < to_date('19400101', 'YYYYMMDD') +ORDER BY name; diff --git a/Chapter01/author_pk.pkc b/Chapter01/author_pk.pkc new file mode 100644 index 0000000..dd3aa93 --- /dev/null +++ b/Chapter01/author_pk.pkc @@ -0,0 +1,4 @@ +ALTER TABLE author ADD +CONSTRAINT author_pk +primary key ( +id ); diff --git a/Chapter01/author_publication.vw b/Chapter01/author_publication.vw new file mode 100644 index 0000000..e08ab57 --- /dev/null +++ b/Chapter01/author_publication.vw @@ -0,0 +1,8 @@ +CREATE OR REPLACE VIEW author_publication as +SELECT author.id, + author.name, + publication.title, + publication.written_date +FROM author, + publication +WHERE author.id = publication.id; diff --git a/Chapter01/author_publication_from_join.sql b/Chapter01/author_publication_from_join.sql new file mode 100644 index 0000000..8993ac7 --- /dev/null +++ b/Chapter01/author_publication_from_join.sql @@ -0,0 +1,10 @@ +SELECT a.id, + a.name, + p.title, + p.written_date +FROM author a JOIN + publication p +ON a.id = p.id +ORDER BY a.name, + p.written_date, + p.title; diff --git a/Chapter01/author_publication_from_join.vw b/Chapter01/author_publication_from_join.vw new file mode 100644 index 0000000..77bc873 --- /dev/null +++ b/Chapter01/author_publication_from_join.vw @@ -0,0 +1,8 @@ +CREATE OR REPLACE VIEW author_publication as +SELECT author.id, + author.name, + publication.title, + publication.written_date +FROM author JOIN + publication +ON author.id = publication.id; diff --git a/Chapter01/author_publication_where_join.sql b/Chapter01/author_publication_where_join.sql new file mode 100644 index 0000000..82d256f --- /dev/null +++ b/Chapter01/author_publication_where_join.sql @@ -0,0 +1,10 @@ +SELECT a.id, + a.name, + p.title, + p.written_date +FROM author a, + publication p +WHERE a.id = p.id +ORDER BY a.name, + p.written_date, + p.title; diff --git a/Chapter01/author_publication_where_join.vw b/Chapter01/author_publication_where_join.vw new file mode 100644 index 0000000..e08ab57 --- /dev/null +++ b/Chapter01/author_publication_where_join.vw @@ -0,0 +1,8 @@ +CREATE OR REPLACE VIEW author_publication as +SELECT author.id, + author.name, + publication.title, + publication.written_date +FROM author, + publication +WHERE author.id = publication.id; diff --git a/Chapter01/author_uk1.ndx b/Chapter01/author_uk1.ndx new file mode 100644 index 0000000..f80b3e9 --- /dev/null +++ b/Chapter01/author_uk1.ndx @@ -0,0 +1,5 @@ +CREATE UNIQUE INDEX author_uk1 +on author ( +name, +birth_date, +gender ); \ No newline at end of file diff --git a/Chapter01/author_uk1.ukc b/Chapter01/author_uk1.ukc new file mode 100644 index 0000000..514c052 --- /dev/null +++ b/Chapter01/author_uk1.ukc @@ -0,0 +1,6 @@ +ALTER TABLE author ADD +CONSTRAINT author_uk1 +UNIQUE ( +name, +birth_date, +gender ); diff --git a/Chapter01/be.sql b/Chapter01/be.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter01/be.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter01/ci.sql b/Chapter01/ci.sql new file mode 100644 index 0000000..6dcc7e7 --- /dev/null +++ b/Chapter01/ci.sql @@ -0,0 +1,50 @@ +rem ci.sql +rem by Donald J. Bales on 12/15/2006 +rem Compile my invalid objects + +set feedback off; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +set serveroutput on size 1000000; + +spool ci.txt; +declare + +cursor c1 is +select object_type, + object_name +from SYS.USER_OBJECTS +where status = 'INVALID' +order by 1, 2; + +v_sql varchar2(100); + +begin + for r1 in c1 loop + begin + if r1.object_type = 'PACKAGE BODY' then + v_sql := 'alter PACKAGE '||r1.object_name||' compile BODY'; + elsif r1.object_type = 'TYPE BODY' then + v_sql := 'alter TYPE '||r1.object_name||' compile BODY'; + else + v_sql := 'alter '||r1.object_type||' '||r1.object_name||' compile'; + end if; + execute immediate v_sql; + pl(r1.object_type||' '||r1.object_name||' compiled successfully'); + exception + when OTHERS then + pl(SQLERRM||' on '||v_sql); + end; + end loop; +end; +/ + +spool off; + +set feedback on; + + + + \ No newline at end of file diff --git a/Chapter01/ci.txt b/Chapter01/ci.txt new file mode 100644 index 0000000..e69de29 diff --git a/Chapter01/compile_all.sql b/Chapter01/compile_all.sql new file mode 100644 index 0000000..c52f1bc --- /dev/null +++ b/Chapter01/compile_all.sql @@ -0,0 +1,48 @@ +set echo on; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +spool compile_all.txt; + +@author.tab +@author_100.ins +@author_200.ins +@author_300.ins +@author.upd + +@.\solutions\publication.tab +@.\solutions\publication_100.ins +@.\solutions\publication_200.ins +@.\solutions\publication_300.ins +@.\solutions\publication.upd +@.\solutions\publication_300.del + +@author_300.del + +@author_publication.vw +@author_publication_from_join.vw +@author_publication_where_join.vw + +@pl.prc + +@worker_type_t.tab +@worker_type_t.ins +@.\solutions\gender_t.tab +@.\solutions\gender_t.ins +@worker_t.tab +@.\solutions\hazard_level_t.tab +@.\solutions\hazard_level_t.ins +@.\solutions\workplace_type_t.tab +@.\solutions\workplace_type_t.ins +@logical_workplace_t.tab +@logical_assignment_t.tab +@.\solutions\physical_workplace_t.tab +@.\solutions\physical_assignment_t.tab +@.\solutions\work_t.tab +@.\solutions\work_assignment_t.tab + +spool off; +set echo off; +@ci.sql +@ci.sql diff --git a/Chapter01/desc.sql b/Chapter01/desc.sql new file mode 100644 index 0000000..45206dc --- /dev/null +++ b/Chapter01/desc.sql @@ -0,0 +1,6 @@ +define table_name="&1"; +set linesize 78; +prompt &table_name +desc &table_name +set linesize 1000; +undefine table_name \ No newline at end of file diff --git a/Chapter01/fe.sql b/Chapter01/fe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter01/fe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter01/logical_assignment_t.tab b/Chapter01/logical_assignment_t.tab new file mode 100644 index 0000000..2a75b1d --- /dev/null +++ b/Chapter01/logical_assignment_t.tab @@ -0,0 +1,45 @@ +rem logical_assignment_t.tab +rem by Donald J. Bales on 12/15/2006 +rem + +--drop table LOGICAL_ASSIGNMENT_T; +create table LOGICAL_ASSIGNMENT_T ( +id number not null, +worker_id number not null, +logical_workplace_id number not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence LOGICAL_ASSIGNMENT_ID_SEQ; +create sequence LOGICAL_ASSIGNMENT_ID_SEQ +start with 1; + +alter table LOGICAL_ASSIGNMENT_T add +constraint LOGICAL_ASSIGNMENT_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table LOGICAL_ASSIGNMENT_T add +constraint LOGICAL_ASSIGNMENT_T_UK +unique ( +worker_id, +active_date ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table LOGICAL_ASSIGNMENT_T add +constraint LOGICAL_ASSIGNMENT_T_FK1 +foreign key ( worker_id ) +references WORKER_T ( id ); + +alter table LOGICAL_ASSIGNMENT_T add +constraint LOGICAL_ASSIGNMENT_T_FK2 +foreign key ( logical_workplace_id ) +references LOGICAL_WORKPLACE_T ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'LOGICAL_ASSIGNMENT_T'); diff --git a/Chapter01/logical_workplace_t.tab b/Chapter01/logical_workplace_t.tab new file mode 100644 index 0000000..00958eb --- /dev/null +++ b/Chapter01/logical_workplace_t.tab @@ -0,0 +1,58 @@ +rem logical_workplace_t.tab +rem by Donald J. Bales on 12/15/2006 +rem + +--drop table LOGICAL_WORKPLACE_T; +create table LOGICAL_WORKPLACE_T ( +id number not null, +parent_id number, +id_context varchar2(100) not null, +workplace_type_id number not null, +code varchar2(30) not null, +name varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence LOGICAL_WORKPLACE_ID_SEQ; +create sequence LOGICAL_WORKPLACE_ID_SEQ +start with 1; + +alter table LOGICAL_WORKPLACE_T add +constraint LOGICAL_WORKPLACE_T_PK +primary key ( +id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table LOGICAL_WORKPLACE_T add +constraint LOGICAL_WORKPLACE_T_UK1 +unique ( +id_context ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table LOGICAL_WORKPLACE_T add +constraint LOGICAL_WORKPLACE_T_UK2 +unique ( +code, +name, +active_date ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table LOGICAL_WORKPLACE_T add +constraint LOGICAL_WORKPLACE_T_FK1 +foreign key ( parent_id ) +references LOGICAL_WORKPLACE_T ( id ); + +alter table LOGICAL_WORKPLACE_T add +constraint LOGICAL_WORKPLACE_T_FK2 +foreign key ( workplace_type_id ) +references WORKPLACE_TYPE_T ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'LOGICAL_WORKPLACE_T'); diff --git a/Chapter01/login.sql b/Chapter01/login.sql new file mode 100644 index 0000000..f2cd4a4 --- /dev/null +++ b/Chapter01/login.sql @@ -0,0 +1,10 @@ +rem logical_assignment_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Set my default SQL*Plus environment +set linesize 1000; +set newpage 1; +set pagesize 32767; +set serveroutput on size 1000000; +set trimspool on; +alter session set nls_date_format = 'SYYYYMMDD HH24MISS'; +prompt BPS' default settings loaded successfully! diff --git a/Chapter01/pe.sql b/Chapter01/pe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter01/pe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter01/pl.prc b/Chapter01/pl.prc new file mode 100644 index 0000000..10b8e34 --- /dev/null +++ b/Chapter01/pl.prc @@ -0,0 +1,14 @@ +create or replace PROCEDURE pl( +aiv_text in varchar2 ) is +/* +pl.prc +by Donald J. Bales on 12/15/2006 +A wrapper procedure for SYS.DBMS_OUTPUT.put_line() +for the lazy typist. +*/ + +begin + SYS.DBMS_OUTPUT.put_line(aiv_text); +end pl; +/ +@pe.sql pl diff --git a/Chapter01/pl.sql b/Chapter01/pl.sql new file mode 100644 index 0000000..587dcf7 --- /dev/null +++ b/Chapter01/pl.sql @@ -0,0 +1,24 @@ +rem pl.sql +rem by Donald J. Bales on 12/15/2006 +rem pl's test unit + +prompt 'Test a line <= 255'; -- 20 21 22 23 24 25 +exec pl('12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '1234567890123456789012345678901234567890123456789012345'); +prompt 'Test a line > 255'; +exec pl('12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'); +prompt 'Test a multi-line'; +exec pl('12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'||chr(10)|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'||chr(10)|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'); diff --git a/Chapter01/publication_fk1.fkc b/Chapter01/publication_fk1.fkc new file mode 100644 index 0000000..27c3ec7 --- /dev/null +++ b/Chapter01/publication_fk1.fkc @@ -0,0 +1,4 @@ +ALTER TABLE publication ADD +CONSTRAINT publication_fk1 +FOREIGN KEY (id) +REFERENCES author (id); diff --git a/Chapter01/se.sql b/Chapter01/se.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter01/se.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter01/solutions/coauthor.sql b/Chapter01/solutions/coauthor.sql new file mode 100644 index 0000000..6d82533 --- /dev/null +++ b/Chapter01/solutions/coauthor.sql @@ -0,0 +1,10 @@ +SELECT a.name +FROM author a +WHERE EXISTS ( +SELECT 1 +FROM publication x1, + publication x2 +WHERE x1.id = a.id +and x1.title = x2.title +and x2.id <> a.id ) +ORDER BY a.name; diff --git a/Chapter01/solutions/coauthor_publication.sql b/Chapter01/solutions/coauthor_publication.sql new file mode 100644 index 0000000..6581066 --- /dev/null +++ b/Chapter01/solutions/coauthor_publication.sql @@ -0,0 +1,12 @@ +SELECT p.title, + a.name +FROM author a, + publication p +WHERE a.id = p.id +AND EXISTS ( +SELECT 1 +FROM publication x +WHERE x.title = p.title +AND x.id <> p.id ) +ORDER BY p.title, + a.name; diff --git a/Chapter01/solutions/gender_t.ins b/Chapter01/solutions/gender_t.ins new file mode 100644 index 0000000..140153f --- /dev/null +++ b/Chapter01/solutions/gender_t.ins @@ -0,0 +1,10 @@ +rem gender_t.ins +rem by Donald J. Bales on 12/15/2006 +rem Add code values to the gender table + +insert into GENDER_T ( id, code, description ) values ( GENDER_ID_SEQ.nextval, 'F', 'Female' ); +insert into GENDER_T ( id, code, description ) values ( GENDER_ID_SEQ.nextval, 'M', 'Male' ); +insert into GENDER_T ( id, code, description ) values ( GENDER_ID_SEQ.nextval, 'U', 'Unknown' ); +commit; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'GENDER_T'); diff --git a/Chapter01/solutions/gender_t.tab b/Chapter01/solutions/gender_t.tab new file mode 100644 index 0000000..df23d4c --- /dev/null +++ b/Chapter01/solutions/gender_t.tab @@ -0,0 +1,33 @@ +rem gender_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold gender code values + +--drop table GENDER_T; +create table GENDER_T ( +id number not null, +code varchar2(30) not null, +description varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence GENDER_ID_SEQ; +create sequence GENDER_ID_SEQ +start with 1; + +alter table GENDER_T add +constraint GENDER_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table GENDER_T add +constraint GENDER_UK +unique ( code ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'GENDER_T'); diff --git a/Chapter01/solutions/hazard_level_t.ins b/Chapter01/solutions/hazard_level_t.ins new file mode 100644 index 0000000..acdacfb --- /dev/null +++ b/Chapter01/solutions/hazard_level_t.ins @@ -0,0 +1,13 @@ +rem hazard_level_t.ins +rem by Donald J. Bales on 12/15/2006 +rem Add code values to hazard level + +insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 0, 'N', 'None' ); +insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 2, 'M', 'May Be Bad' ); +insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 4, 'B', 'Bad' ); +insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 6, 'U', 'Unknown' ); +insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 8, 'R', 'Really Bad' ); +insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 10, 'W', 'Wholly Crap (as not to offend anyone)' ); +commit; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'HAZARD_LEVEL_T'); diff --git a/Chapter01/solutions/hazard_level_t.tab b/Chapter01/solutions/hazard_level_t.tab new file mode 100644 index 0000000..ee22508 --- /dev/null +++ b/Chapter01/solutions/hazard_level_t.tab @@ -0,0 +1,34 @@ +rem hazard_level_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a hazard level code table + +--drop table HAZARD_LEVEL_T; +create table HAZARD_LEVEL_T ( +id number not null, +magnitude number not null, +code varchar2(30) not null, +description varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence HAZARD_LEVEL_ID_SEQ; +create sequence HAZARD_LEVEL_ID_SEQ +start with 1; + +alter table HAZARD_LEVEL_T add +constraint HAZARD_LEVEL_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table HAZARD_LEVEL_T add +constraint HAZARD_LEVEL_UK +unique ( code ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'HAZARD_LEVEL_T'); diff --git a/Chapter01/solutions/physical_assignment_t.tab b/Chapter01/solutions/physical_assignment_t.tab new file mode 100644 index 0000000..b100e07 --- /dev/null +++ b/Chapter01/solutions/physical_assignment_t.tab @@ -0,0 +1,45 @@ +rem physical_assignment_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold physical workplace assignments + +--drop table PHYSICAL_ASSIGNMENT_T; +create table PHYSICAL_ASSIGNMENT_T ( +id number not null, +worker_id number not null, +physical_workplace_id number not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence PHYSICAL_ASSIGNMENT_ID_SEQ; +create sequence PHYSICAL_ASSIGNMENT_ID_SEQ +start with 1; + +alter table PHYSICAL_ASSIGNMENT_T add +constraint PHYSICAL_ASSIGNMENT_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table PHYSICAL_ASSIGNMENT_T add +constraint PHYSICAL_ASSIGNMENT_T_UK +unique ( +worker_id, +active_date ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table PHYSICAL_ASSIGNMENT_T add +constraint PHYSICAL_ASSIGNMENT_T_FK1 +foreign key ( worker_id ) +references WORKER_T ( id ); + +alter table PHYSICAL_ASSIGNMENT_T add +constraint PHYSICAL_ASSIGNMENT_T_FK2 +foreign key ( physical_workplace_id ) +references PHYSICAL_WORKPLACE_T ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'PHYSICAL_ASSIGNMENT_T'); diff --git a/Chapter01/solutions/physical_workplace_t.tab b/Chapter01/solutions/physical_workplace_t.tab new file mode 100644 index 0000000..03afb13 --- /dev/null +++ b/Chapter01/solutions/physical_workplace_t.tab @@ -0,0 +1,46 @@ +rem physical_workplace_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold physical workplaces + +--drop table PHYSICAL_WORKPLACE_T; +create table PHYSICAL_WORKPLACE_T ( +id number not null, +workplace_type_id number not null, +id_context varchar2(100) not null, +parent_id number, +code varchar2(30) not null, +name varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence PHYSICAL_WORKPLACE_ID_SEQ; +create sequence PHYSICAL_WORKPLACE_ID_SEQ +start with 1; + +alter table PHYSICAL_WORKPLACE_T add +constraint PHYSICAL_WORKPLACE_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table PHYSICAL_WORKPLACE_T add +constraint PHYSICAL_WORKPLACE_T_UK +unique ( id_context ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table PHYSICAL_WORKPLACE_T add +constraint PHYSICAL_WORKPLACE_T_FK1 +foreign key ( parent_id ) +references PHYSICAL_WORKPLACE_T ( id ); + +alter table PHYSICAL_WORKPLACE_T add +constraint PHYSICAL_WORKPLACE_T_FK2 +foreign key ( workplace_type_id ) +references WORKPLACE_TYPE_T ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'PHYSICAL_WORKPLACE_T'); diff --git a/Chapter01/solutions/publication.tab b/Chapter01/solutions/publication.tab new file mode 100644 index 0000000..f3245dc --- /dev/null +++ b/Chapter01/solutions/publication.tab @@ -0,0 +1,4 @@ +CREATE TABLE publication ( +id number, +title varchar2(100), +written_date date ); \ No newline at end of file diff --git a/Chapter01/solutions/publication.upd b/Chapter01/solutions/publication.upd new file mode 100644 index 0000000..16e9d4b --- /dev/null +++ b/Chapter01/solutions/publication.upd @@ -0,0 +1,5 @@ +UPDATE publication +SET title = upper(title) +where title <> upper(title); + +COMMIT; diff --git a/Chapter01/solutions/publication_100.ins b/Chapter01/solutions/publication_100.ins new file mode 100644 index 0000000..9ba9c1f --- /dev/null +++ b/Chapter01/solutions/publication_100.ins @@ -0,0 +1,21 @@ +INSERT INTO publication ( + id, + title, + written_date ) +VALUES ( + 100, + 'A Relation Model of Data for Large Shared Data Banks', + to_date('19700101', 'YYYYMMDD') ); + +INSERT INTO publication ( + id, + title, + written_date ) +VALUES ( + 100, + 'The Relational Model for Database Management', + to_date('19900101', 'YYYYMMDD') ); + +COMMIT; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'PUBLICATION'); diff --git a/Chapter01/solutions/publication_200.ins b/Chapter01/solutions/publication_200.ins new file mode 100644 index 0000000..200ce06 --- /dev/null +++ b/Chapter01/solutions/publication_200.ins @@ -0,0 +1,39 @@ +INSERT INTO publication ( + id, + title, + written_date ) +VALUES ( + 200, + 'An introduction to Database Systems', + to_date('20030101', 'YYYYMMDD') ); + +INSERT INTO publication ( + id, + title, + written_date ) +VALUES ( + 200, + 'The Third Manifesto', + to_date('20000101', 'YYYYMMDD') ); + +INSERT INTO publication ( + id, + title, + written_date ) +VALUES ( + 200, + 'Temporal Data and the Relational Model', + to_date('20020101', 'YYYYMMDD') ); + +INSERT INTO publication ( + id, + title, + written_date ) +VALUES ( + 200, + 'Database in Depth: Relational Theory for Practitioners', + to_date('20050101', 'YYYYMMDD') ); + +COMMIT; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'PUBLICATION'); diff --git a/Chapter01/solutions/publication_300.del b/Chapter01/solutions/publication_300.del new file mode 100644 index 0000000..aa66cd8 --- /dev/null +++ b/Chapter01/solutions/publication_300.del @@ -0,0 +1,2 @@ +DELETE FROM publication +WHERE id = 300; diff --git a/Chapter01/solutions/publication_300.ins b/Chapter01/solutions/publication_300.ins new file mode 100644 index 0000000..80eb187 --- /dev/null +++ b/Chapter01/solutions/publication_300.ins @@ -0,0 +1,31 @@ +INSERT INTO publication ( + id, + title, + written_date ) +SELECT 300, + 'The Third Manifesto', + to_date('20000101', 'YYYYMMDD') +FROM dual +where not exists ( + SELECT 1 + FROM publication x + WHERE x.id = '300' + AND x.title = 'The Third Manifesto' ); + +INSERT INTO publication ( + id, + title, + written_date ) +SELECT 300, + 'Temporal Data and the Relational Model', + to_date('20020101', 'YYYYMMDD') +FROM dual +where not exists ( + SELECT 1 + FROM publication x + WHERE x.id = '300' + AND x.title = 'Temporal Data and the Relational Model' ); + +COMMIT; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'PUBLICATION'); diff --git a/Chapter01/solutions/publication_k1.ndx b/Chapter01/solutions/publication_k1.ndx new file mode 100644 index 0000000..e37cda6 --- /dev/null +++ b/Chapter01/solutions/publication_k1.ndx @@ -0,0 +1,5 @@ +CREATE INDEX publication_k1 +on publication ( +title ); + +SYS.DBMS_STATS.gather_table_stats(USER, 'PUBLICATION'); diff --git a/Chapter01/solutions/publication_pk.pkc b/Chapter01/solutions/publication_pk.pkc new file mode 100644 index 0000000..cffa78a --- /dev/null +++ b/Chapter01/solutions/publication_pk.pkc @@ -0,0 +1,7 @@ +ALTER TABLE publication ADD +CONSTRAINT publication_pk +PRIMARY KEY ( +id, +title); + +SYS.DBMS_STATS.gather_table_stats(USER, 'PUBLICATION'); diff --git a/Chapter01/solutions/work_assignment_t.tab b/Chapter01/solutions/work_assignment_t.tab new file mode 100644 index 0000000..c932725 --- /dev/null +++ b/Chapter01/solutions/work_assignment_t.tab @@ -0,0 +1,46 @@ +rem work_assignment_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold work assignments + +--drop table WORK_ASSIGNMENT_T; +create table WORK_ASSIGNMENT_T ( +id number not null, +worker_id number not null, +work_id number not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence WORK_ASSIGNMENT_ID_SEQ; +create sequence WORK_ASSIGNMENT_ID_SEQ +start with 1; + +alter table WORK_ASSIGNMENT_T add +constraint WORK_ASSIGNMENT_T_PK +primary key ( +id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORK_ASSIGNMENT_T add +constraint WORK_ASSIGNMENT_T_UK +unique ( +worker_id, +active_date ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORK_ASSIGNMENT_T add +constraint WORK_ASSIGNMENT_T_FK1 +foreign key ( worker_id ) +references WORKER_T ( id ); + +alter table WORK_ASSIGNMENT_T add +constraint WORK_ASSIGNMENT_T_FK2 +foreign key ( work_id ) +references WORK_T ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORK_ASSIGNMENT_T'); diff --git a/Chapter01/solutions/work_t.tab b/Chapter01/solutions/work_t.tab new file mode 100644 index 0000000..d3e1d31 --- /dev/null +++ b/Chapter01/solutions/work_t.tab @@ -0,0 +1,36 @@ +rem work_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold work descriptions + +--drop table WORK_T; +create table WORK_T ( +id number not null, +code varchar2(30) not null, +name varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence WORK_ID_SEQ; +create sequence WORK_ID_SEQ +start with 1; + +alter table WORK_T add +constraint WORK_T_PK +primary key ( +id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORK_T add +constraint WORK_T_UK +unique ( +code, +name ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORK_T'); diff --git a/Chapter01/solutions/workplace_type_t.ins b/Chapter01/solutions/workplace_type_t.ins new file mode 100644 index 0000000..627146c --- /dev/null +++ b/Chapter01/solutions/workplace_type_t.ins @@ -0,0 +1,14 @@ +rem workplace_type_t.ins +rem by Donald J. Bales on 12/15/2006 +rem Add workplace type code values + +insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'Y', 'N', 'B', 'Business Unit' ); +insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'Y', 'N', 'C', 'Company' ); +insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'Y', 'N', 'D', 'Department' ); +insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'N', 'Y', 'L', 'Line' ); +insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'N', 'Y', 'M', 'Machine' ); +insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'N', 'Y', 'S', 'Site' ); +insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'Y', 'Y', 'U', 'Unknown' ); +commit; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKPLACE_TYPE_T'); diff --git a/Chapter01/solutions/workplace_type_t.tab b/Chapter01/solutions/workplace_type_t.tab new file mode 100644 index 0000000..87716e3 --- /dev/null +++ b/Chapter01/solutions/workplace_type_t.tab @@ -0,0 +1,35 @@ +rem workplace_type_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold workplace types + +--drop table WORKPLACE_TYPE_T; +create table WORKPLACE_TYPE_T ( +id number not null, +logical_indicator varchar2(1) default 'N' not null, +physical_indicator varchar2(1) default 'N' not null, +code varchar2(30) not null, +description varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence WORKPLACE_TYPE_ID_SEQ; +create sequence WORKPLACE_TYPE_ID_SEQ +start with 1; + +alter table WORKPLACE_TYPE_T add +constraint WORKPLACE_TYPE_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKPLACE_TYPE_T add +constraint WORKPLACE_TYPE_UK +unique ( code ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKPLACE_TYPE_T'); diff --git a/Chapter01/sqlnet.log b/Chapter01/sqlnet.log new file mode 100644 index 0000000..75c9ff6 --- /dev/null +++ b/Chapter01/sqlnet.log @@ -0,0 +1,38 @@ + + +*********************************************************************** +Fatal NI connect error 12541, connecting to: + (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xp1.donaldbales.com)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=infr1012.donaldbales.com)(CID=(PROGRAM=C:\oracle\infr1012\bin\sqlplusw.exe)(HOST=XP1)(USER=balesd)))) + + VERSION INFORMATION: + TNS for 32-bit Windows: Version 10.1.0.4.0 - Production + Windows NT TCP/IP NT Protocol Adapter for 32-bit Windows: Version 10.1.0.4.0 - Production + Time: 30-APR-2007 12:25:08 + Tracing not turned on. + Tns error struct: + ns main err code: 12541 + TNS-12541: TNS:no listener + ns secondary err code: 12560 + nt main err code: 511 + TNS-00511: No listener + nt secondary err code: 61 + nt OS err code: 0 + + +*********************************************************************** +Fatal NI connect error 12541, connecting to: + (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=ora1020.donaldbales.com)(CID=(PROGRAM=C:\oracle\infr1012\bin\sqlplusw.exe)(HOST=XP1)(USER=balesd)))(ADDRESS=(PROTOCOL=TCP)(HOST=205.178.145.65)(PORT=1521))) + + VERSION INFORMATION: + TNS for 32-bit Windows: Version 10.1.0.4.0 - Production + Windows NT TCP/IP NT Protocol Adapter for 32-bit Windows: Version 10.1.0.4.0 - Production + Time: 21-MAY-2007 19:33:22 + Tracing not turned on. + Tns error struct: + ns main err code: 12541 + TNS-12541: TNS:no listener + ns secondary err code: 12560 + nt main err code: 511 + TNS-00511: No listener + nt secondary err code: 61 + nt OS err code: 0 diff --git a/Chapter01/worker_t.tab b/Chapter01/worker_t.tab new file mode 100644 index 0000000..029e92e --- /dev/null +++ b/Chapter01/worker_t.tab @@ -0,0 +1,61 @@ +rem worker_t.tab +rem by Donald J. Bales on 12/15/2006 +rem + +--drop table WORKER_T; +create table WORKER_T ( +id number not null, +worker_type_id number not null, +external_id varchar2(30) not null, +first_name varchar2(30) not null, +middle_name varchar2(30), +last_name varchar2(30) not null, +name varchar2(100) not null, +birth_date date not null, +gender_id number not null ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence WORKER_ID_SEQ; +create sequence WORKER_ID_SEQ +start with 1; + +--drop sequence EXTERNAL_ID_SEQ; +create sequence EXTERNAL_ID_SEQ +start with 100000000 order; + +alter table WORKER_T add +constraint WORKER_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKER_T add +constraint WORKER_T_UK1 +unique ( external_id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKER_T add +constraint WORKER_T_UK2 +unique ( +name, +birth_date, +gender_id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKER_T add +constraint WORKER_T_FK1 +foreign key ( worker_type_id ) +references WORKER_TYPE_T ( id ); + +alter table WORKER_T add +constraint WORKER_T_FK2 +foreign key ( gender_id ) +references GENDER_T ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKER_T'); diff --git a/Chapter01/worker_type_t.ins b/Chapter01/worker_type_t.ins new file mode 100644 index 0000000..d58b203 --- /dev/null +++ b/Chapter01/worker_type_t.ins @@ -0,0 +1,34 @@ +rem worker_type_t.ins +rem by Donald J. Bales on 12/15/2006 +rem + +insert into WORKER_TYPE_T ( + id, + code, + description ) +values ( + WORKER_TYPE_ID_SEQ.nextval, + 'C', + 'Contractor' ); + +insert into WORKER_TYPE_T ( + id, + code, + description ) +values ( + WORKER_TYPE_ID_SEQ.nextval, + 'E', + 'Employee' ); + +insert into WORKER_TYPE_T ( + id, + code, + description ) +values ( + WORKER_TYPE_ID_SEQ.nextval, + 'U', + 'Unknown' ); + +commit; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKER_TYPE_T'); diff --git a/Chapter01/worker_type_t.tab b/Chapter01/worker_type_t.tab new file mode 100644 index 0000000..7fafa51 --- /dev/null +++ b/Chapter01/worker_type_t.tab @@ -0,0 +1,33 @@ +rem worker_type_t.tab +rem by Donald J. Bales on 12/15/2006 +rem + +--drop table WORKER_TYPE_T; +create table WORKER_TYPE_T ( +id number not null, +code varchar2(30) not null, +description varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence WORKER_TYPE_ID_SEQ; +create sequence WORKER_TYPE_ID_SEQ +start with 1; + +alter table WORKER_TYPE_T add +constraint WORKER_TYPE_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKER_TYPE_T add +constraint WORKER_TYPE_UK +unique ( code ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKER_TYPE_T'); diff --git a/Chapter02/README.txt b/Chapter02/README.txt new file mode 100644 index 0000000..a0675ec --- /dev/null +++ b/Chapter02/README.txt @@ -0,0 +1,122 @@ +README.txt for Chapter 2 +by Donald J. Bales on 4/15/2007 + +OBJECT NAME DESCRIPTION +--------------------------------------- ------------------------------------- +a_thru_z.ins Insert letters A - Z into A_THRU_Z + +a_thru_z.tab Create table A_THRU_Z + +anonymous.sql An example of an anonymous PL/SQL + block + +be.sql Show package body compilation errors + +ci.sql Compile invalid objects + +create_relational.sql Create all the relational tables + +dates.pkb Create utility package DATES' body + +dates.pks Create utility package DATES' spec + +desc.sql Describe an object + +drop_if_exists.prc Don's handy-dandy "drop it if it + exists" stored procedure + +drop_relational.sql Drop all relational tables + +fe.sql Show function compilation errors + +gender_t.ins Add gender code values + +gender_t.tab Create table GENDER_T + +hazard_level_t.ins Add hazard type code values + +hazard_level_t.tab Create table HARZARD_TYPE_T + +logical_assignment_t.tab Create table LOGICAL_ASSIGNMENT_T + +logical_workplace_t.ins Add logical workplace values + +logical_workplace_t.tab Create table LOGICAL_WORKPLACE_T + +logical_workplace_ts.pkb Create table package + LOGICAL_WORKPLACE_TS's spec + +logical_workplace_ts.pks Create table package + LOGICAL_WORPLACE_TS's body + +login.sql Set my SQL*Plus defaults + +solutions\numbers.pkb Create utility package NUMBERS' body + +solutions\numbers.pks Create utility package NUMBERS' spec + +pe.sql Show procedure compilation errors + +physical_assignment_t.tab Create table PHYSICAL_ASSIGNMENT_T + +physical_workplace_t.tab Create table PHYSICAL_WORKPLACE_T + +solutions\pl.prc Don's handy-dandy "put line" stored + procedure, a short cut to + SYS.DBMS_OUTPUT.put_line() + +solutions\pl.sql Test unit for pl() + +pl2.sql Test unit #2 for pl() + +se.sql Show package specification + compilation errors + +substance_t.ins Add substances + +substance_t.tab Create table SUBSTANCE_T + +task_substance_t.tab Create table TASK_SUBSTANCE_T + +task_t.tab Create table TASK + +solutions\to_mmsddsyyyy_or_null.fun Create stored function + to_mmsddsyyyy_or_null() + +solutions\to_mmsddsyyyy_or_null.sql Test unit for to_mmsddsyyyy_or_null() + +to_number_or_null.fun Create stored function + to_number_or_null() + +top_100_first_name.ins Add the top 100 first names + +top_100_first_name.tab Create table TOP_100_FIRST_NAME + +top_100_last_name.ins Add the top 100 last names + +top_100_last_name.tab Create table TOP_100_LAST_NAME + +wait.prc Create stored procedure wait() + +work_assignment_t.tab Create table WORK_ASSIGNMENT_T + +work_t.tab Create table WORK_T + +work_task_t.tab Create table WORK_TASK_T + +worker_t.tab Create table WORKER_T + +worker_type_t.ins Add worker type code values + +worker_type_t.tab Create table WORKER_TYPE_T + +workplace_type_t.ins Add workplace type code values + +workplace_type_t.tab Create table WORKPLACE_TYPE_T + +workplace_type_ts.pkb Create table package + WORKPLACE_TYPE_TS' body + +workplace_type_ts.pks Create table package + WORKPLACE_TYPE_TS' spec + \ No newline at end of file diff --git a/Chapter02/a_thru_z.ins b/Chapter02/a_thru_z.ins new file mode 100644 index 0000000..c13d6df --- /dev/null +++ b/Chapter02/a_thru_z.ins @@ -0,0 +1,16 @@ +rem a_thru_z.ins +rem by Donald J. Bales on 12/15/2006 +rem The letters A through Z + +declare + +begin + for i in ascii('A')..ascii('Z') loop + insert into A_THRU_Z ( + letter ) + values ( + chr(i)); + end loop; + commit; +end; +/ diff --git a/Chapter02/a_thru_z.tab b/Chapter02/a_thru_z.tab new file mode 100644 index 0000000..8bb2f88 --- /dev/null +++ b/Chapter02/a_thru_z.tab @@ -0,0 +1,15 @@ +rem a_thru_z.tab +rem by Donald J. Bales on 12/15/2006 +rem The letters A through Z + +execute drop_if_exists('table', 'A_THRU_Z'); +create table A_THRU_Z ( +letter varchar2(1)); + +alter table A_THRU_Z add +constraint A_THRU_Z_PK +primary key ( +letter ) +using index; + +@a_thru_z.ins diff --git a/Chapter02/anonymous.sql b/Chapter02/anonymous.sql new file mode 100644 index 0000000..8be2da8 --- /dev/null +++ b/Chapter02/anonymous.sql @@ -0,0 +1,16 @@ +-- This is an anonymous procedure, so it has no name +declare + /* + You declare local cursors, variables, and methods here, + but you don't need to have a declaration section. + */ +begin + -- You write your logic here + + null; -- Ahhh, you've got to have at least one command! +exception + when NO_DATA_FOUND then + raise_application_error(-20000, 'Hey, No Data Found!'); +end; +/ +-- the forward slash on a line by itself says execute this procedure diff --git a/Chapter02/be.sql b/Chapter02/be.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter02/be.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter02/ci.sql b/Chapter02/ci.sql new file mode 100644 index 0000000..6dcc7e7 --- /dev/null +++ b/Chapter02/ci.sql @@ -0,0 +1,50 @@ +rem ci.sql +rem by Donald J. Bales on 12/15/2006 +rem Compile my invalid objects + +set feedback off; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +set serveroutput on size 1000000; + +spool ci.txt; +declare + +cursor c1 is +select object_type, + object_name +from SYS.USER_OBJECTS +where status = 'INVALID' +order by 1, 2; + +v_sql varchar2(100); + +begin + for r1 in c1 loop + begin + if r1.object_type = 'PACKAGE BODY' then + v_sql := 'alter PACKAGE '||r1.object_name||' compile BODY'; + elsif r1.object_type = 'TYPE BODY' then + v_sql := 'alter TYPE '||r1.object_name||' compile BODY'; + else + v_sql := 'alter '||r1.object_type||' '||r1.object_name||' compile'; + end if; + execute immediate v_sql; + pl(r1.object_type||' '||r1.object_name||' compiled successfully'); + exception + when OTHERS then + pl(SQLERRM||' on '||v_sql); + end; + end loop; +end; +/ + +spool off; + +set feedback on; + + + + \ No newline at end of file diff --git a/Chapter02/ci.txt b/Chapter02/ci.txt new file mode 100644 index 0000000..6aaa256 --- /dev/null +++ b/Chapter02/ci.txt @@ -0,0 +1,30 @@ +SQL> declare + 2 + 3 cursor c1 is + 4 select object_type, + 5 object_name + 6 from SYS.USER_OBJECTS + 7 where status = 'INVALID' + 8 order by 1, 2; + 9 + 10 v_sql varchar2(100); + 11 + 12 begin + 13 for r1 in c1 loop + 14 begin + 15 if r1.object_type = 'PACKAGE BODY' then + 16 v_sql := 'alter PACKAGE '||r1.object_name||' compile BODY'; + 17 else + 18 v_sql := 'alter '||r1.object_type||' '||r1.object_name||' compile'; + 19 end if; + 20 execute immediate v_sql; + 21 pl(r1.object_type||' '||r1.object_name||' compiled successfully'); + 22 exception + 23 when OTHERS then + 24 pl(SQLERRM||' on '||v_sql); + 25 end; + 26 end loop; + 27 end; + 28 / +SQL> +SQL> spool off; diff --git a/Chapter02/compile_all.sql b/Chapter02/compile_all.sql new file mode 100644 index 0000000..9e3e52f --- /dev/null +++ b/Chapter02/compile_all.sql @@ -0,0 +1,49 @@ +@pl.prc +@drop_if_exists.prc +@drop_relational.sql +set echo on; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +spool compile_all.txt; +@a_thru_z.tab +@gender_t.tab +@gender_t.ins +@hazard_level_t.tab +@hazard_level_t.ins +@substance_t.tab +@substance_t.ins +@top_100_first_name.tab +@top_100_last_name.tab +@worker_type_t.tab +@worker_type_t.ins +@workplace_type_t.tab +@workplace_type_t.ins +@worker_t.tab +@logical_workplace_t.tab +@logical_workplace_t.ins +@logical_assignment_t.tab +@physical_workplace_t.tab +@physical_assignment_t.tab +@task_t.tab +@task_substance_t.tab +@work_t.tab +@work_task_t.tab +@work_assignment_t.tab +@dates.pks +@logical_workplace_ts.pks +@workplace_type_ts.pks +@dates.pkb +@logical_workplace_ts.pkb +@workplace_type_ts.pkb +@wait.prc +@to_number_or_null.fun +@.\solutions\pl.prc +@.\solutions\numbers.pks +@.\solutions\numbers.pkb +@.\solutions\to_mmsddsyyyy_or_null.fun +spool off; +set echo off; +@ci.sql +@ci.sql diff --git a/Chapter02/create_relational.sql b/Chapter02/create_relational.sql new file mode 100644 index 0000000..a93f907 --- /dev/null +++ b/Chapter02/create_relational.sql @@ -0,0 +1,63 @@ +rem create_relational.sql +rem by Donald J. Bales on 12/15/2006 +rem Create all the relational tables + +set echo on; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; + +spool create_relational.txt; + +@pl.prc +@drop_if_exists.prc +@drop_relational.sql + +@top_100_first_name.tab +@a_thru_z.tab +@top_100_last_name.tab + +-- tables in order of dependence +@worker_type_t.tab +@gender_t.tab +@worker_t.tab + +@workplace_type_t.tab +@logical_workplace_t.tab +@logical_assignment_t.tab +@physical_workplace_t.tab +@physical_assignment_t.tab +@work_t.tab +@work_assignment_t.tab + +@substance_t.tab +@hazard_level_t.tab +@task_t.tab +@work_task_t.tab +@task_substance_t.tab + +-- codes +@gender_t.ins +@hazard_level_t.ins +@substance_t.ins +@worker_type_t.ins +@workplace_type_t.ins + +-- package specs +@dates.pks +@workplace_type_ts.pks +@logical_workplace_ts.pks + +-- package bodies +@dates.pkb +@workplace_type_ts.pkb +@logical_workplace_ts.pkb + +-- content +@logical_workplace_t.ins + +spool off; + +set echo off; +@ci.sql diff --git a/Chapter02/create_relational.txt b/Chapter02/create_relational.txt new file mode 100644 index 0000000..0a5e0ab --- /dev/null +++ b/Chapter02/create_relational.txt @@ -0,0 +1,9860 @@ +SQL> +SQL> @pl.prc +SQL> create or replace PROCEDURE pl( + 2 aiv_text in varchar2 ) is + 3 /* + 4 pl.prc + 5 by Donald J. Bales on 12/15/2006 + 6 A wrapper procedure for SYS.DBMS_OUTPUT.put_line() + 7 for the lazy typist. + 8 */ + 9 + 10 begin + 11 SYS.DBMS_OUTPUT.put_line(aiv_text); + 12 end pl; + 13 / + +Procedure created. + +SQL> @pe.sql pl +SQL> show errors +No errors. +SQL> @drop_if_exists.prc +SQL> create or replace PROCEDURE drop_if_exists( + 2 aiv_object_type in varchar2, + 3 aiv_object_name in varchar2) is + 4 /* + 5 drop_if_exists.prc + 6 by Donald J. Bales on 12/15/2006 + 7 Drop the object if it exists + 8 */ + 9 + 10 cursor c_constraint( + 11 aiv_table_name in varchar2) is + 12 select f.table_name, + 13 f.constraint_name + 14 from SYS.USER_CONSTRAINTS f, + 15 SYS.USER_CONSTRAINTS p + 16 where f.constraint_type = 'R' + 17 and f.r_owner = p.owner + 18 and f.r_constraint_name = p.constraint_name + 19 and p.table_name = aiv_table_name; + 20 + 21 n_count number; + 22 v_sql varchar2(100); + 23 + 24 begin + 25 select count(1) + 26 into n_count + 27 from SYS.USER_OBJECTS + 28 where object_type = upper(aiv_object_type) + 29 and object_name = upper(aiv_object_name); + 30 + 31 if n_count > 0 then + 32 if upper(aiv_object_type) = 'TABLE' then + 33 for r_constraint in c_constraint(upper(aiv_object_name)) loop + 34 v_sql := 'alter table '|| + 35 r_constraint.table_name|| + 36 ' drop constraint '|| + 37 r_constraint.constraint_name; + 38 begin + 39 execute immediate v_sql; + 40 exception + 41 when OTHERS then + 42 pl(SQLERRM||': '||v_sql); + 43 end; + 44 end loop; + 45 end if; + 46 v_sql := 'drop '||aiv_object_type||' '||aiv_object_name; + 47 begin + 48 execute immediate v_sql; + 49 exception + 50 when OTHERS then + 51 pl(SQLERRM||': '||v_sql); + 52 end; + 53 end if; + 54 end drop_if_exists; + 55 / + +Procedure created. + +SQL> @pe.sql +SQL> show errors +No errors. +SQL> @drop_relational.sql +SQL> rem drop_relational.sql +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Drop the relational tables +SQL> +SQL> set feedback off; +SQL> +SQL> rem create the procedure drop_if_exists used in this script +SQL> +SQL> @drop_if_exists.prc +SQL> create or replace PROCEDURE drop_if_exists( + 2 aiv_object_type in varchar2, + 3 aiv_object_name in varchar2) is + 4 /* + 5 drop_if_exists.prc + 6 by Donald J. Bales on 12/15/2006 + 7 Drop the object if it exists + 8 */ + 9 + 10 cursor c_constraint( + 11 aiv_table_name in varchar2) is + 12 select f.table_name, + 13 f.constraint_name + 14 from SYS.USER_CONSTRAINTS f, + 15 SYS.USER_CONSTRAINTS p + 16 where f.constraint_type = 'R' + 17 and f.r_owner = p.owner + 18 and f.r_constraint_name = p.constraint_name + 19 and p.table_name = aiv_table_name; + 20 + 21 n_count number; + 22 v_sql varchar2(100); + 23 + 24 begin + 25 select count(1) + 26 into n_count + 27 from SYS.USER_OBJECTS + 28 where object_type = upper(aiv_object_type) + 29 and object_name = upper(aiv_object_name); + 30 + 31 if n_count > 0 then + 32 if upper(aiv_object_type) = 'TABLE' then + 33 for r_constraint in c_constraint(upper(aiv_object_name)) loop + 34 v_sql := 'alter table '|| + 35 r_constraint.table_name|| + 36 ' drop constraint '|| + 37 r_constraint.constraint_name; + 38 begin + 39 execute immediate v_sql; + 40 exception + 41 when OTHERS then + 42 pl(SQLERRM||': '||v_sql); + 43 end; + 44 end loop; + 45 end if; + 46 v_sql := 'drop '||aiv_object_type||' '||aiv_object_name; + 47 begin + 48 execute immediate v_sql; + 49 exception + 50 when OTHERS then + 51 pl(SQLERRM||': '||v_sql); + 52 end; + 53 end if; + 54 end drop_if_exists; + 55 / +SQL> @pe.sql +SQL> show errors +No errors. +SQL> +SQL> rem drop package specs +SQL> +SQL> exec drop_if_exists('PACKAGE', 'TASK_SUBSTANCE_TS'); +SQL> exec drop_if_exists('PACKAGE', 'WORK_TASK_TS'); +SQL> exec drop_if_exists('PACKAGE', 'TASK_TS'); +SQL> exec drop_if_exists('PACKAGE', 'HAZARD_LEVEL_TS'); +SQL> exec drop_if_exists('PACKAGE', 'SUBSTANCE_TS'); +SQL> exec drop_if_exists('PACKAGE', 'WORK_ASSIGNMENT_TS'); +SQL> exec drop_if_exists('PACKAGE', 'WORK_TS'); +SQL> exec drop_if_exists('PACKAGE', 'PHYSICAL_ASSIGNMENT_TS'); +SQL> exec drop_if_exists('PACKAGE', 'PHYSICAL_WORKPLACE_TS'); +SQL> exec drop_if_exists('PACKAGE', 'LOGICAL_ASSIGNMENT_TS'); +SQL> exec drop_if_exists('PACKAGE', 'LOGICAL_WORKPLACE_TS'); +SQL> exec drop_if_exists('PACKAGE', 'WORKPLACE_TYPE_TS'); +SQL> exec drop_if_exists('PACKAGE', 'WORKER_TS'); +SQL> exec drop_if_exists('PACKAGE', 'GENDER_TS'); +SQL> exec drop_if_exists('PACKAGE', 'WORKER_TYPE_TS'); +SQL> +SQL> rem drop relational tables, indexes, and foreign keys +SQL> +SQL> exec drop_if_exists('TABLE', 'TASK_SUBSTANCE_T'); +SQL> exec drop_if_exists('TABLE', 'WORK_TASK_T'); +SQL> exec drop_if_exists('TABLE', 'TASK_T'); +SQL> exec drop_if_exists('TABLE', 'HAZARD_LEVEL_T'); +SQL> exec drop_if_exists('TABLE', 'SUBSTANCE_T'); +SQL> exec drop_if_exists('TABLE', 'WORK_ASSIGNMENT_T'); +SQL> exec drop_if_exists('TABLE', 'WORK_T'); +SQL> exec drop_if_exists('TABLE', 'PHYSICAL_ASSIGNMENT_T'); +SQL> exec drop_if_exists('TABLE', 'PHYSICAL_WORKPLACE_T'); +SQL> exec drop_if_exists('TABLE', 'LOGICAL_ASSIGNMENT_T'); +SQL> exec drop_if_exists('TABLE', 'LOGICAL_WORKPLACE_T'); +SQL> exec drop_if_exists('TABLE', 'WORKPLACE_TYPE_T'); +SQL> exec drop_if_exists('TABLE', 'WORKER_T'); +SQL> exec drop_if_exists('TABLE', 'GENDER_T'); +SQL> exec drop_if_exists('TABLE', 'WORKER_TYPE_T'); +SQL> +SQL> rem drop sequences +SQL> +SQL> exec drop_if_exists('SEQUENCE', 'TASK_SUBSTANCE_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'WORK_TASK_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'TASK_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'HAZARD_LEVEL_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'SUBSTANCE_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'WORK_ASSIGNMENT_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'WORK_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'PHYSICAL_ASSIGNMENT_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'PHYSICAL_WORKPLACE_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'LOGICAL_ASSIGNMENT_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'LOGICAL_WORKPLACE_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'WORKPLACE_TYPE_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'EXTERNAL_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'WORKER_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'GENDER_ID_SEQ'); +SQL> exec drop_if_exists('SEQUENCE', 'WORKER_TYPE_ID_SEQ'); +SQL> +SQL> set feedback on; +SQL> +SQL> @top_100_first_name.tab +SQL> rem top_100_first_name.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Top 100 first names from www.namestatistics.com +SQL> +SQL> drop table TOP_100_FIRST_NAME; + +Table dropped. + +SQL> create table TOP_100_FIRST_NAME ( + 2 first_name varchar2(30) not null, + 3 gender_code varchar2(1) not null); + +Table created. + +SQL> +SQL> alter table TOP_100_FIRST_NAME add + 2 constraint TOP_100_FIRST_NAME_PK + 3 primary key ( + 4 first_name, + 5 gender_code ) + 6 using index; + +Table altered. + +SQL> +SQL> @top_100_first_name.ins +SQL> rem top_100_first_name.ins +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Top 100 first names from www.namestatistics.com +SQL> +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ALICE', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('AMANDA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('AMY', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANDREW', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANGELA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANN', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANNA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANTHONY', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('BARBARA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('BETTY', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('BRENDA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('BRIAN', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CARL', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CAROL', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CAROLYN', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CATHERINE', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CHARLES', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CHRISTINE', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CHRISTOPHER', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CYNTHIA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DANIEL', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DAVID', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DEBORAH', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DEBRA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DENNIS', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DIANE', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DONALD', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DONNA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DOROTHY', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DOUGLAS', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('EDWARD', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ELIZABETH', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ERIC', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('FRANCES', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('FRANK', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('GARY', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('GEORGE', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('GREGORY', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('HAROLD', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('HEATHER', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('HELEN', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('HENRY', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JAMES', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JANET', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JASON', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JEFFREY', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JENNIFER', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JERRY', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JESSICA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOHN', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOSE', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOSEPH', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOSHUA', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOYCE', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JULIE', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KAREN', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KATHLEEN', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KENNETH', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KEVIN', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KIMBERLY', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('LARRY', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('LAURA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('LINDA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('LISA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARGARET', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARIA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARIE', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARK', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARTHA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARY', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MATTHEW', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MELISSA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MICHAEL', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MICHELLE', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('NANCY', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PAMELA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PATRICIA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PATRICK', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PAUL', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PETER', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('RAYMOND', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('REBECCA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('RICHARD', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ROBERT', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('RONALD', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('RUTH', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SANDRA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SARAH', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SCOTT', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SHARON', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SHIRLEY', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('STEPHANIE', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('STEPHEN', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('STEVEN', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SUSAN', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('THOMAS', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('TIMOTHY', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('VIRGINIA', 'F'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('WALTER', 'M'); + +1 row created. + +SQL> insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('WILLIAM', 'M'); + +1 row created. + +SQL> +SQL> commit; + +Commit complete. + +SQL> @a_thru_z.tab +SQL> rem a_thru_z.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem The letters A through Z +SQL> +SQL> execute drop_if_exists('table', 'A_THRU_Z'); + +PL/SQL procedure successfully completed. + +SQL> create table A_THRU_Z ( + 2 letter varchar2(1)); + +Table created. + +SQL> +SQL> alter table A_THRU_Z add + 2 constraint A_THRU_Z_PK + 3 primary key ( + 4 letter ) + 5 using index; + +Table altered. + +SQL> +SQL> @a_thru_z.ins +SQL> rem a_thru_z.ins +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem The letters A through Z +SQL> +SQL> declare + 2 + 3 begin + 4 for i in ascii('A')..ascii('Z') loop + 5 insert into A_THRU_Z ( + 6 letter ) + 7 values ( + 8 chr(i)); + 9 end loop; + 10 commit; + 11 end; + 12 / + +PL/SQL procedure successfully completed. + +SQL> @top_100_last_name.tab +SQL> rem top_100_last_name.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Top 100 last names from www.namestatistics.com +SQL> +SQL> drop table TOP_100_LAST_NAME; + +Table dropped. + +SQL> create table TOP_100_LAST_NAME ( + 2 last_name varchar2(30)); + +Table created. + +SQL> +SQL> alter table TOP_100_LAST_NAME add + 2 constraint TOP_100_LAST_NAME_PK + 3 primary key ( + 4 last_name) + 5 using index; + +Table altered. + +SQL> +SQL> @top_100_last_name.ins +SQL> rem top_100_last_name.ins +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Top 100 last names from www.namestatistics.com +SQL> +SQL> insert into TOP_100_LAST_NAME (last_name) values ('ADAMS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('ALEXANDER'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('ALLEN'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('ANDERSON'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('BAILEY'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('BAKER'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('BARNES'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('BELL'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('BENNETT'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('BROOKS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('BROWN'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('BRYANT'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('BUTLER'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('CAMPBELL'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('CARTER'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('CLARK'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('COLEMAN'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('COLLINS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('COOK'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('COOPER'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('COX'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('DAVIS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('DIAZ'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('EDWARDS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('EVANS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('FLORES'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('FOSTER'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('GARCIA'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('GONZALES'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('GONZALEZ'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('GRAY'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('GREEN'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('GRIFFIN'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('HALL'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('HARRIS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('HAYES'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('HENDERSON'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('HERNANDEZ'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('HILL'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('HOWARD'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('HUGHES'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('JACKSON'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('JAMES'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('JENKINS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('JOHNSON'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('JONES'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('KELLY'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('KING'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('LEE'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('LEWIS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('LONG'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('LOPEZ'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('MARTIN'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('MARTINEZ'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('MILLER'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('MITCHELL'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('MOORE'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('MORGAN'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('MORRIS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('MURPHY'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('NELSON'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('PARKER'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('PATTERSON'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('PEREZ'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('PERRY'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('PETERSON'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('PHILLIPS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('POWELL'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('PRICE'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('RAMIREZ'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('REED'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('RICHARDSON'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('RIVERA'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('ROBERTS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('ROBINSON'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('RODRIGUEZ'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('ROGERS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('ROSS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('RUSSELL'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('SANCHEZ'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('SANDERS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('SCOTT'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('SIMMONS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('SMITH'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('STEWART'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('TAYLOR'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('THOMAS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('THOMPSON'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('TORRES'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('TURNER'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('WALKER'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('WARD'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('WASHINGTON'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('WATSON'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('WHITE'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('WILLIAMS'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('WILSON'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('WOOD'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('WRIGHT'); + +1 row created. + +SQL> insert into TOP_100_LAST_NAME (last_name) values ('YOUNG'); + +1 row created. + +SQL> +SQL> commit; + +Commit complete. + +SQL> +SQL> -- tables in order of dependence +SQL> @worker_type_t.tab +SQL> rem worker_type_t.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem +SQL> +SQL> --drop table WORKER_TYPE_T; +SQL> create table WORKER_TYPE_T ( + 2 id number not null, + 3 code varchar2(30) not null, + 4 description varchar2(80) not null, + 5 active_date date default SYSDATE not null, + 6 inactive_date date ) + 7 tablespace USERS pctfree 20 + 8 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> --drop sequence WORKER_TYPE_ID_SEQ; +SQL> create sequence WORKER_TYPE_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> alter table WORKER_TYPE_T add + 2 constraint WORKER_TYPE_T_PK + 3 primary key ( id ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table WORKER_TYPE_T add + 2 constraint WORKER_TYPE_UK + 3 unique ( code ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> @gender_t.tab +SQL> rem gender_t.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Create a table to hold gender code values +SQL> +SQL> --drop table GENDER_T; +SQL> create table GENDER_T ( + 2 id number not null, + 3 code varchar2(30) not null, + 4 description varchar2(80) not null, + 5 active_date date default SYSDATE not null, + 6 inactive_date date ) + 7 tablespace USERS pctfree 20 + 8 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> --drop sequence GENDER_ID_SEQ; +SQL> create sequence GENDER_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> alter table GENDER_T add + 2 constraint GENDER_T_PK + 3 primary key ( id ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table GENDER_T add + 2 constraint GENDER_UK + 3 unique ( code ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> @worker_t.tab +SQL> rem worker_t.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem +SQL> +SQL> --drop table WORKER_T; +SQL> create table WORKER_T ( + 2 id number not null, + 3 worker_type_id number not null, + 4 external_id varchar2(30) not null, + 5 first_name varchar2(30) not null, + 6 middle_name varchar2(30), + 7 last_name varchar2(30) not null, + 8 name varchar2(100) not null, + 9 birth_date date not null, + 10 gender_id number not null ) + 11 tablespace USERS pctfree 20 + 12 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> --drop sequence WORKER_ID_SEQ; +SQL> create sequence WORKER_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> --drop sequence EXTERNAL_ID_SEQ; +SQL> create sequence EXTERNAL_ID_SEQ + 2 start with 100000000 order; + +Sequence created. + +SQL> +SQL> alter table WORKER_T add + 2 constraint WORKER_T_PK + 3 primary key ( id ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table WORKER_T add + 2 constraint WORKER_T_UK1 + 3 unique ( external_id ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table WORKER_T add + 2 constraint WORKER_T_UK2 + 3 unique ( + 4 name, + 5 birth_date, + 6 gender_id ) + 7 using index + 8 tablespace USERS pctfree 20 + 9 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table WORKER_T add + 2 constraint WORKER_T_FK1 + 3 foreign key ( worker_type_id ) + 4 references WORKER_TYPE_T ( id ); + +Table altered. + +SQL> +SQL> alter table WORKER_T add + 2 constraint WORKER_T_FK2 + 3 foreign key ( gender_id ) + 4 references GENDER_T ( id ); + +Table altered. + +SQL> +SQL> @workplace_type_t.tab +SQL> rem workplace_type_t.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Create a table to hold workplace types +SQL> +SQL> --drop table WORKPLACE_TYPE_T; +SQL> create table WORKPLACE_TYPE_T ( + 2 id number not null, + 3 logical_indicator varchar2(1) default 'N' not null, + 4 physical_indicator varchar2(1) default 'N' not null, + 5 code varchar2(30) not null, + 6 description varchar2(80) not null, + 7 active_date date default SYSDATE not null, + 8 inactive_date date ) + 9 tablespace USERS pctfree 20 + 10 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> --drop sequence WORKPLACE_TYPE_ID_SEQ; +SQL> create sequence WORKPLACE_TYPE_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> alter table WORKPLACE_TYPE_T add + 2 constraint WORKPLACE_TYPE_T_PK + 3 primary key ( id ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table WORKPLACE_TYPE_T add + 2 constraint WORKPLACE_TYPE_UK + 3 unique ( code ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> @logical_workplace_t.tab +SQL> rem logical_workplace_t.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem +SQL> +SQL> --drop table LOGICAL_WORKPLACE_T; +SQL> create table LOGICAL_WORKPLACE_T ( + 2 id number not null, + 3 parent_id number, + 4 id_context varchar2(100) not null, + 5 workplace_type_id number not null, + 6 code varchar2(30) not null, + 7 name varchar2(80) not null, + 8 active_date date default SYSDATE not null, + 9 inactive_date date ) + 10 tablespace USERS pctfree 20 + 11 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> --drop sequence LOGICAL_WORKPLACE_ID_SEQ; +SQL> create sequence LOGICAL_WORKPLACE_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> alter table LOGICAL_WORKPLACE_T add + 2 constraint LOGICAL_WORKPLACE_T_PK + 3 primary key ( + 4 id ) + 5 using index + 6 tablespace USERS pctfree 20 + 7 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table LOGICAL_WORKPLACE_T add + 2 constraint LOGICAL_WORKPLACE_T_UK1 + 3 unique ( + 4 id_context ) + 5 using index + 6 tablespace USERS pctfree 20 + 7 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table LOGICAL_WORKPLACE_T add + 2 constraint LOGICAL_WORKPLACE_T_UK2 + 3 unique ( + 4 code, + 5 name, + 6 active_date ) + 7 using index + 8 tablespace USERS pctfree 20 + 9 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table LOGICAL_WORKPLACE_T add + 2 constraint LOGICAL_WORKPLACE_T_FK1 + 3 foreign key ( parent_id ) + 4 references LOGICAL_WORKPLACE_T ( id ); + +Table altered. + +SQL> +SQL> alter table LOGICAL_WORKPLACE_T add + 2 constraint LOGICAL_WORKPLACE_T_FK2 + 3 foreign key ( workplace_type_id ) + 4 references WORKPLACE_TYPE_T ( id ); + +Table altered. + +SQL> @logical_assignment_t.tab +SQL> rem logical_assignment_t.tab +SQL> rem copyright by Donald J. Bales on 12/15/2006 +SQL> rem +SQL> +SQL> --drop table LOGICAL_ASSIGNMENT_T; +SQL> create table LOGICAL_ASSIGNMENT_T ( + 2 id number not null, + 3 worker_id number not null, + 4 logical_workplace_id number not null, + 5 active_date date default SYSDATE not null, + 6 inactive_date date ) + 7 tablespace USERS pctfree 20 + 8 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> --drop sequence LOGICAL_ASSIGNMENT_ID_SEQ; +SQL> create sequence LOGICAL_ASSIGNMENT_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> alter table LOGICAL_ASSIGNMENT_T add + 2 constraint LOGICAL_ASSIGNMENT_T_PK + 3 primary key ( id ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table LOGICAL_ASSIGNMENT_T add + 2 constraint LOGICAL_ASSIGNMENT_T_UK + 3 unique ( + 4 worker_id, + 5 active_date ) + 6 using index + 7 tablespace USERS pctfree 20 + 8 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table LOGICAL_ASSIGNMENT_T add + 2 constraint LOGICAL_ASSIGNMENT_T_FK1 + 3 foreign key ( worker_id ) + 4 references WORKER_T ( id ); + +Table altered. + +SQL> +SQL> alter table LOGICAL_ASSIGNMENT_T add + 2 constraint LOGICAL_ASSIGNMENT_T_FK2 + 3 foreign key ( logical_workplace_id ) + 4 references LOGICAL_WORKPLACE_T ( id ); + +Table altered. + +SQL> @physical_workplace_t.tab +SQL> rem physical_workplace_t.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Create a table to hold physical workplaces +SQL> +SQL> --drop table PHYSICAL_WORKPLACE_T; +SQL> create table PHYSICAL_WORKPLACE_T ( + 2 id number not null, + 3 workplace_type_id number not null, + 4 id_context varchar2(100) not null, + 5 parent_id number, + 6 code varchar2(30) not null, + 7 name varchar2(80) not null, + 8 active_date date default SYSDATE not null, + 9 inactive_date date ) + 10 tablespace USERS pctfree 20 + 11 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> --drop sequence PHYSICAL_WORKPLACE_ID_SEQ; +SQL> create sequence PHYSICAL_WORKPLACE_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> alter table PHYSICAL_WORKPLACE_T add + 2 constraint PHYSICAL_WORKPLACE_T_PK + 3 primary key ( id ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table PHYSICAL_WORKPLACE_T add + 2 constraint PHYSICAL_WORKPLACE_T_UK + 3 unique ( id_context ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table PHYSICAL_WORKPLACE_T add + 2 constraint PHYSICAL_WORKPLACE_T_FK1 + 3 foreign key ( parent_id ) + 4 references PHYSICAL_WORKPLACE_T ( id ); + +Table altered. + +SQL> +SQL> alter table PHYSICAL_WORKPLACE_T add + 2 constraint PHYSICAL_WORKPLACE_T_FK2 + 3 foreign key ( workplace_type_id ) + 4 references WORKPLACE_TYPE_T ( id ); + +Table altered. + +SQL> @physical_assignment_t.tab +SQL> rem physical_assignment_t.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Create a table to hold physical workplace assignments +SQL> +SQL> --drop table PHYSICAL_ASSIGNMENT_T; +SQL> create table PHYSICAL_ASSIGNMENT_T ( + 2 id number not null, + 3 worker_id number not null, + 4 physical_workplace_id number not null, + 5 active_date date default SYSDATE not null, + 6 inactive_date date ) + 7 tablespace USERS pctfree 20 + 8 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> --drop sequence PHYSICAL_ASSIGNMENT_ID_SEQ; +SQL> create sequence PHYSICAL_ASSIGNMENT_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> alter table PHYSICAL_ASSIGNMENT_T add + 2 constraint PHYSICAL_ASSIGNMENT_T_PK + 3 primary key ( id ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table PHYSICAL_ASSIGNMENT_T add + 2 constraint PHYSICAL_ASSIGNMENT_T_UK + 3 unique ( + 4 worker_id, + 5 active_date ) + 6 using index + 7 tablespace USERS pctfree 20 + 8 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table PHYSICAL_ASSIGNMENT_T add + 2 constraint PHYSICAL_ASSIGNMENT_T_FK1 + 3 foreign key ( worker_id ) + 4 references WORKER_T ( id ); + +Table altered. + +SQL> +SQL> alter table PHYSICAL_ASSIGNMENT_T add + 2 constraint PHYSICAL_ASSIGNMENT_T_FK2 + 3 foreign key ( physical_workplace_id ) + 4 references PHYSICAL_WORKPLACE_T ( id ); + +Table altered. + +SQL> @work_t.tab +SQL> rem work_t.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Create a table to hold work descriptions +SQL> +SQL> --drop table WORK_T; +SQL> create table WORK_T ( + 2 id number not null, + 3 code varchar2(30) not null, + 4 name varchar2(80) not null, + 5 active_date date default SYSDATE not null, + 6 inactive_date date ) + 7 tablespace USERS pctfree 20 + 8 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> --drop sequence WORK_ID_SEQ; +SQL> create sequence WORK_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> alter table WORK_T add + 2 constraint WORK_T_PK + 3 primary key ( + 4 id ) + 5 using index + 6 tablespace USERS pctfree 20 + 7 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table WORK_T add + 2 constraint WORK_T_UK + 3 unique ( + 4 code, + 5 name ) + 6 using index + 7 tablespace USERS pctfree 20 + 8 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> @work_assignment_t.tab +SQL> rem work_assignment_t.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Create a table to hold work assignments +SQL> +SQL> --drop table WORK_ASSIGNMENT_T; +SQL> create table WORK_ASSIGNMENT_T ( + 2 id number not null, + 3 worker_id number not null, + 4 work_id number not null, + 5 active_date date default SYSDATE not null, + 6 inactive_date date ) + 7 tablespace USERS pctfree 20 + 8 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> --drop sequence WORK_ASSIGNMENT_ID_SEQ; +SQL> create sequence WORK_ASSIGNMENT_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> alter table WORK_ASSIGNMENT_T add + 2 constraint WORK_ASSIGNMENT_T_PK + 3 primary key ( + 4 id ) + 5 using index + 6 tablespace USERS pctfree 20 + 7 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table WORK_ASSIGNMENT_T add + 2 constraint WORK_ASSIGNMENT_T_UK + 3 unique ( + 4 worker_id, + 5 active_date ) + 6 using index + 7 tablespace USERS pctfree 20 + 8 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table WORK_ASSIGNMENT_T add + 2 constraint WORK_ASSIGNMENT_T_FK1 + 3 foreign key ( worker_id ) + 4 references WORKER_T ( id ); + +Table altered. + +SQL> +SQL> alter table WORK_ASSIGNMENT_T add + 2 constraint WORK_ASSIGNMENT_T_FK2 + 3 foreign key ( work_id ) + 4 references WORK_T ( id ); + +Table altered. + +SQL> +SQL> @substance_t.tab +SQL> rem substance_t.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Create a table to hold substances +SQL> +SQL> execute drop_if_exists('table', 'SUBSTANCE_T'); + +PL/SQL procedure successfully completed. + +SQL> create table SUBSTANCE_T ( + 2 id number not null, + 3 cas_number varchar2(30) not null, + 4 name varchar2(80) not null, + 5 active_date date default SYSDATE not null, + 6 inactive_date date ) + 7 tablespace USERS pctfree 20 + 8 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> execute drop_if_exists('sequence', 'SUBSTANCE_ID_SEQ'); + +PL/SQL procedure successfully completed. + +SQL> create sequence SUBSTANCE_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> alter table SUBSTANCE_T add + 2 constraint SUBSTANCE_T_PK + 3 primary key ( id ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table SUBSTANCE_T add + 2 constraint SUBSTANCE_T_UK + 3 unique ( + 4 cas_number, + 5 name ) + 6 using index + 7 tablespace USERS pctfree 20 + 8 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> analyze table SUBSTANCE_T estimate statistics; + +Table analyzed. + +SQL> +SQL> @hazard_level_t.tab +SQL> rem hazard_level_t.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Create a hazard level code table +SQL> +SQL> --drop table HAZARD_LEVEL_T; +SQL> create table HAZARD_LEVEL_T ( + 2 id number not null, + 3 magnitude number not null, + 4 code varchar2(30) not null, + 5 description varchar2(80) not null, + 6 active_date date default SYSDATE not null, + 7 inactive_date date ) + 8 tablespace USERS pctfree 20 + 9 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> --drop sequence HAZARD_LEVEL_ID_SEQ; +SQL> create sequence HAZARD_LEVEL_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> alter table HAZARD_LEVEL_T add + 2 constraint HAZARD_LEVEL_T_PK + 3 primary key ( id ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table HAZARD_LEVEL_T add + 2 constraint HAZARD_LEVEL_UK + 3 unique ( code ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> @task_t.tab +SQL> rem task_t.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Create a table to hold task definitions +SQL> +SQL> execute drop_if_exists('table', 'TASK_T'); + +PL/SQL procedure successfully completed. + +SQL> create table TASK_T ( + 2 id number not null, + 3 name varchar2(80) not null, + 4 narrative varchar2(2000) not null, + 5 hazard_level_id number not null, + 6 active_date date default SYSDATE not null, + 7 inactive_date date ) + 8 tablespace USERS pctfree 20 + 9 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> execute drop_if_exists('sequence', 'TASK_ID_SEQ'); + +PL/SQL procedure successfully completed. + +SQL> create sequence TASK_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> alter table TASK_T add + 2 constraint TASK_T_PK + 3 primary key ( id ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table TASK_T add + 2 constraint TASK_T_UK + 3 unique ( name ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table TASK_T add + 2 constraint TASK_T_FK1 + 3 foreign key ( hazard_level_id ) + 4 references HAZARD_LEVEL_T ( id ); + +Table altered. + +SQL> +SQL> analyze table TASK_T estimate statistics; + +Table analyzed. + +SQL> @work_task_t.tab +SQL> rem work_task_t.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Create a table to hold the tasks associated with a work definition +SQL> +SQL> execute drop_if_exists('table', 'WORK_TASK_T'); + +PL/SQL procedure successfully completed. + +SQL> create table WORK_TASK_T ( + 2 id number not null, + 3 work_id number not null, + 4 task_id number not null, + 5 hazard_level_id number not null, + 6 active_date date default SYSDATE not null, + 7 inactive_date date ) + 8 tablespace USERS pctfree 20 + 9 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> execute drop_if_exists('sequence', 'WORK_TASK_ID_SEQ'); + +PL/SQL procedure successfully completed. + +SQL> create sequence WORK_TASK_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> alter table WORK_TASK_T add + 2 constraint WORK_TASK_T_PK + 3 primary key ( id ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table WORK_TASK_T add + 2 constraint WORK_TASK_T_UK + 3 unique ( + 4 work_id, + 5 task_id, + 6 active_date ) + 7 using index + 8 tablespace USERS pctfree 20 + 9 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table WORK_TASK_T add + 2 constraint WORK_TASK_T_FK1 + 3 foreign key ( work_id ) + 4 references WORK_T ( id ); + +Table altered. + +SQL> +SQL> alter table WORK_TASK_T add + 2 constraint WORK_TASK_T_FK2 + 3 foreign key ( task_id ) + 4 references TASK_T ( id ); + +Table altered. + +SQL> +SQL> alter table WORK_TASK_T add + 2 constraint WORK_TASK_T_FK3 + 3 foreign key ( hazard_level_id ) + 4 references HAZARD_LEVEL_T ( id ); + +Table altered. + +SQL> +SQL> analyze table WORK_TASK_T estimate statistics; + +Table analyzed. + +SQL> @task_substance_t.tab +SQL> rem task_substance_t.tab +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Create a table to hold the substances assicated with a task +SQL> +SQL> execute drop_if_exists('table', 'TASK_SUBSTANCE_T'); + +PL/SQL procedure successfully completed. + +SQL> create table TASK_SUBSTANCE_T ( + 2 id number not null, + 3 task_id number not null, + 4 substance_id number not null, + 5 hazard_level_id number not null, + 6 active_date date default SYSDATE not null, + 7 inactive_date date ) + 8 tablespace USERS pctfree 20 + 9 storage (initial 10K next 10K pctincrease 0); + +Table created. + +SQL> +SQL> execute drop_if_exists('sequence', 'TASK_SUBSTANCE_ID_SEQ'); + +PL/SQL procedure successfully completed. + +SQL> create sequence TASK_SUBSTANCE_ID_SEQ + 2 start with 1; + +Sequence created. + +SQL> +SQL> alter table TASK_SUBSTANCE_T add + 2 constraint TASK_SUBSTANCE_T_PK + 3 primary key ( id ) + 4 using index + 5 tablespace USERS pctfree 20 + 6 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table TASK_SUBSTANCE_T add + 2 constraint TASK_SUBSTANCE_T_UK + 3 unique ( + 4 task_id, + 5 substance_id, + 6 active_date ) + 7 using index + 8 tablespace USERS pctfree 20 + 9 storage (initial 10K next 10K pctincrease 0); + +Table altered. + +SQL> +SQL> alter table TASK_SUBSTANCE_T add + 2 constraint TASK_SUBSTANCE_T_FK1 + 3 foreign key ( task_id ) + 4 references TASK_T ( id ); + +Table altered. + +SQL> +SQL> alter table TASK_SUBSTANCE_T add + 2 constraint TASK_SUBSTANCE_T_FK2 + 3 foreign key ( substance_id ) + 4 references SUBSTANCE_T ( id ); + +Table altered. + +SQL> +SQL> alter table TASK_SUBSTANCE_T add + 2 constraint TASK_SUBSTANCE_T_FK3 + 3 foreign key ( hazard_level_id ) + 4 references HAZARD_LEVEL_T ( id ); + +Table altered. + +SQL> +SQL> analyze table TASK_SUBSTANCE_T estimate statistics; + +Table analyzed. + +SQL> +SQL> -- codes +SQL> @gender_t.ins +SQL> rem gender_t.ins +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Add code values to the gender table +SQL> +SQL> insert into GENDER_T ( id, code, description ) values ( GENDER_ID_SEQ.nextval, 'F', 'Female' ); + +1 row created. + +SQL> insert into GENDER_T ( id, code, description ) values ( GENDER_ID_SEQ.nextval, 'M', 'Male' ); + +1 row created. + +SQL> insert into GENDER_T ( id, code, description ) values ( GENDER_ID_SEQ.nextval, 'U', 'Unknown' ); + +1 row created. + +SQL> commit; + +Commit complete. + +SQL> +SQL> analyze table GENDER_T estimate statistics; + +Table analyzed. + +SQL> @hazard_level_t.ins +SQL> rem hazard_level_t.ins +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Add code values to hazard level +SQL> +SQL> insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 0, 'N', 'None' ); + +1 row created. + +SQL> insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 2, 'M', 'May Be Bad' ); + +1 row created. + +SQL> insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 4, 'B', 'Bad' ); + +1 row created. + +SQL> insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 6, 'U', 'Unknown' ); + +1 row created. + +SQL> insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 8, 'R', 'Really Bad' ); + +1 row created. + +SQL> insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 10, 'W', 'Wholly Crap (as not to offend anyone)' ); + +1 row created. + +SQL> commit; + +Commit complete. + +SQL> +SQL> analyze table HAZARD_LEVEL_T estimate statistics; + +Table analyzed. + +SQL> @substance_t.ins +SQL> rem substance_t.ins +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Add substances +SQL> +SQL> set define off; +SQL> +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-00-0', 'Formaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-00-0' and x.name = 'Formaldehyde' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-07-7', 'Mitomycin C', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-07-7' and x.name = 'Mitomycin C' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-18-0', 'Cyclophosphamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-18-0' and x.name = 'Cyclophosphamide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-27-1', 'Estriol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-27-1' and x.name = 'Estriol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-28-2', 'Estradiol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-28-2' and x.name = 'Estradiol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-29-3', 'DDT', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-29-3' and x.name = 'DDT' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-32-8', 'Benzo (alpha) Pyrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-32-8' and x.name = 'Benzo (alpha) Pyrene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-36-2', 'Cocaine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-36-2' and x.name = 'Cocaine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-78-2', 'Acetylsalicylic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-78-2' and x.name = 'Acetylsalicylic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-96-4', 'Bronkosol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-96-4' and x.name = 'Bronkosol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '51-03-6', 'Piperonyl Butoxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '51-03-6' and x.name = 'Piperonyl Butoxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '51-21-8', '5-Fluorouracil', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '51-21-8' and x.name = '5-Fluorouracil' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '51-48-9', 'L-thyroxine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '51-48-9' and x.name = 'L-thyroxine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '52-68-6', 'Trichlorfon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '52-68-6' and x.name = 'Trichlorfon' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '53-16-7', 'Estrone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '53-16-7' and x.name = 'Estrone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '53-43-0', 'Dehydroisoandrosterone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '53-43-0' and x.name = 'Dehydroisoandrosterone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '53-70-3', 'Dibenz(a,h)anthracene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '53-70-3' and x.name = 'Dibenz(a,h)anthracene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '53-96-3', '2-Acetylaminofluorene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '53-96-3' and x.name = '2-Acetylaminofluorene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '54-11-5', 'Nicotine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '54-11-5' and x.name = 'Nicotine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '55-18-5', 'N-Nitrosodiethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '55-18-5' and x.name = 'N-Nitrosodiethylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '55-38-9', 'Fenthion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '55-38-9' and x.name = 'Fenthion' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '55-63-0', 'Nitroglycerin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '55-63-0' and x.name = 'Nitroglycerin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-23-5', 'Carbon Tetrachloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-23-5' and x.name = 'Carbon Tetrachloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-35-9', 'Bis(Tributyltin) Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-35-9' and x.name = 'Bis(Tributyltin) Oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-38-2', 'Parathion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-38-2' and x.name = 'Parathion' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-49-5', '3-Methylcholanthrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-49-5' and x.name = '3-Methylcholanthrene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-55-3', 'Benz(a)Anthracene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-55-3' and x.name = 'Benz(a)Anthracene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-72-4', 'Co-Ral', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-72-4' and x.name = 'Co-Ral' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-75-7', 'Chloramphenicol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-75-7' and x.name = 'Chloramphenicol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-81-5', 'Glycerin Mist (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-81-5' and x.name = 'Glycerin Mist (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-81-5', 'Glycerin Mist (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-81-5' and x.name = 'Glycerin Mist (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-11-4', 'Stearic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-11-4' and x.name = 'Stearic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-12-5', 'Cyanide (as Cn)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-12-5' and x.name = 'Cyanide (as Cn)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-13-6', 'Urea', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-13-6' and x.name = 'Urea' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-14-7', '1,1-Dimethylhydrazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-14-7' and x.name = '1,1-Dimethylhydrazine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-24-9', 'Strychnine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-24-9' and x.name = 'Strychnine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-39-6', 'Tris(2-Methyl-1-aziridinyl)phosphine Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-39-6' and x.name = 'Tris(2-Methyl-1-aziridinyl)phosphine Oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-41-0', '5,5-Diphenylhydantoin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-41-0' and x.name = '5,5-Diphenylhydantoin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-50-1', 'Sucrose (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-50-1' and x.name = 'Sucrose (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-50-1', 'Sucrose (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-50-1' and x.name = 'Sucrose (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-55-6', 'Propylene Glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-55-6' and x.name = 'Propylene Glycol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-57-8', 'beta-Propiolactone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-57-8' and x.name = 'beta-Propiolactone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-68-1', 'Sulfamethazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-68-1' and x.name = 'Sulfamethazine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-74-9', 'Chlordane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-74-9' and x.name = 'Chlordane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-83-0', 'Progesterone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-83-0' and x.name = 'Progesterone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '58-14-0', 'Pyrimethamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '58-14-0' and x.name = 'Pyrimethamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '58-18-4', '17-alpha-Methyl Testosterone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '58-18-4' and x.name = '17-alpha-Methyl Testosterone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '58-22-0', 'Testosterone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '58-22-0' and x.name = 'Testosterone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '58-27-5', 'Menadione', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '58-27-5' and x.name = 'Menadione' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '58-89-9', 'Lindane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '58-89-9' and x.name = 'Lindane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '59-05-2', 'Methotrexate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '59-05-2' and x.name = 'Methotrexate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '59-50-7', '4-Chloro-3-methylphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '59-50-7' and x.name = '4-Chloro-3-methylphenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '59-87-0', '5-Nitro-2-furaldehyde Semicarbazone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '59-87-0' and x.name = '5-Nitro-2-furaldehyde Semicarbazone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '59-89-2', 'N-Nitrosomorpholine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '59-89-2' and x.name = 'N-Nitrosomorpholine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-09-3', 'p-Aminoazobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-09-3' and x.name = 'p-Aminoazobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-11-7', '4-Dimethylaminoazobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-11-7' and x.name = '4-Dimethylaminoazobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-12-8', 'Phenethyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-12-8' and x.name = 'Phenethyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-24-2', 'Mercaptoethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-24-2' and x.name = 'Mercaptoethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-29-7', 'Ethyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-29-7' and x.name = 'Ethyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-34-4', 'Monomethyl Hydrazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-34-4' and x.name = 'Monomethyl Hydrazine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-35-5', 'Acetamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-35-5' and x.name = 'Acetamide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-51-5', 'Dimethoate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-51-5' and x.name = 'Dimethoate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-57-1', 'Dieldrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-57-1' and x.name = 'Dieldrin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '61-82-5', 'Amitrole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '61-82-5' and x.name = 'Amitrole' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '62-53-3', 'Aniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '62-53-3' and x.name = 'Aniline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '62-56-6', 'Thiourea', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '62-56-6' and x.name = 'Thiourea' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '62-73-7', 'Dichlorvos (DDVP)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '62-73-7' and x.name = 'Dichlorvos (DDVP)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '62-74-8', 'Sodium Fluoroacetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '62-74-8' and x.name = 'Sodium Fluoroacetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '62-75-9', 'N-Nitrosodimethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '62-75-9' and x.name = 'N-Nitrosodimethylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '63-25-2', 'Carbaryl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '63-25-2' and x.name = 'Carbaryl' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '64-17-5', 'Ethyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '64-17-5' and x.name = 'Ethyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '64-18-6', 'Formic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '64-18-6' and x.name = 'Formic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '64-19-7', 'Acetic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '64-19-7' and x.name = 'Acetic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '64-67-5', 'Diethyl Sulfate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '64-67-5' and x.name = 'Diethyl Sulfate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '65-85-0', 'Benzoic acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '65-85-0' and x.name = 'Benzoic acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '66-75-1', 'Uracil Mustard', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '66-75-1' and x.name = 'Uracil Mustard' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '67-56-1', 'Methyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '67-56-1' and x.name = 'Methyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '67-63-0', 'Isopropyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '67-63-0' and x.name = 'Isopropyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '67-64-1', 'Acetone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '67-64-1' and x.name = 'Acetone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '67-66-3', 'Chloroform', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '67-66-3' and x.name = 'Chloroform' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '67-68-5', 'Dimethyl Sulfoxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '67-68-5' and x.name = 'Dimethyl Sulfoxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '67-72-1', 'Hexachloroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '67-72-1' and x.name = 'Hexachloroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68-11-1', 'Thioglycolic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68-11-1' and x.name = 'Thioglycolic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68-12-2', 'Dimethylformamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68-12-2' and x.name = 'Dimethylformamide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68-22-4', 'Norethindrone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68-22-4' and x.name = 'Norethindrone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68-35-9', 'Sulfadiazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68-35-9' and x.name = 'Sulfadiazine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '71-23-8', 'Propyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '71-23-8' and x.name = 'Propyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '71-36-3', 'n-Butyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '71-36-3' and x.name = 'n-Butyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '71-41-0', 'n-Amyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '71-41-0' and x.name = 'n-Amyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '71-43-2', 'Benzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '71-43-2' and x.name = 'Benzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '71-48-7', 'Cobalt Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '71-48-7' and x.name = 'Cobalt Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '71-55-6', 'Methyl Chloroform', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '71-55-6' and x.name = 'Methyl Chloroform' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '72-20-8', 'Endrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '72-20-8' and x.name = 'Endrin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '72-33-3', 'Mestranol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '72-33-3' and x.name = 'Mestranol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '72-43-5', 'Methoxychlor (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '72-43-5' and x.name = 'Methoxychlor (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '72-54-8', 'Dichlorodiphenyldichloroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '72-54-8' and x.name = 'Dichlorodiphenyldichloroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '72-55-9', 'p,p''-Dichlorodiphenyldichloroethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '72-55-9' and x.name = 'p,p''-Dichlorodiphenyldichloroethylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-82-8', 'Methane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-82-8' and x.name = 'Methane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-83-9', 'Methyl Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-83-9' and x.name = 'Methyl Bromide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-84-0', 'Ethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-84-0' and x.name = 'Ethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-85-1', 'Ethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-85-1' and x.name = 'Ethylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-86-2', 'Acetylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-86-2' and x.name = 'Acetylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-87-3', 'Methyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-87-3' and x.name = 'Methyl Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-88-4', 'Methyl Iodide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-88-4' and x.name = 'Methyl Iodide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-89-5', 'Methylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-89-5' and x.name = 'Methylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-90-8', 'Hydrogen Cyanide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-90-8' and x.name = 'Hydrogen Cyanide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-93-1', 'Methyl Mercaptan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-93-1' and x.name = 'Methyl Mercaptan' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-96-4', 'Ethyl Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-96-4' and x.name = 'Ethyl Bromide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-97-5', 'Chlorobromomethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-97-5' and x.name = 'Chlorobromomethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-98-6', 'Propane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-98-6' and x.name = 'Propane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-99-7', 'Methyl Acetylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-99-7' and x.name = 'Methyl Acetylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-00-3', 'Ethyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-00-3' and x.name = 'Ethyl Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-01-4', 'Vinyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-01-4' and x.name = 'Vinyl Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-02-5', 'Vinyl fluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-02-5' and x.name = 'Vinyl fluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-04-7', 'Ethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-04-7' and x.name = 'Ethylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-05-8', 'Acetonitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-05-8' and x.name = 'Acetonitrile' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-07-0', 'Acetaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-07-0' and x.name = 'Acetaldehyde' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-08-1', 'Ethyl Mercaptan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-08-1' and x.name = 'Ethyl Mercaptan' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-09-2', 'Methylene Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-09-2' and x.name = 'Methylene Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-12-7', 'Formamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-12-7' and x.name = 'Formamide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-15-0', 'Carbon Disulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-15-0' and x.name = 'Carbon Disulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-18-3', 'Dimethyl Sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-18-3' and x.name = 'Dimethyl Sulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-21-8', 'Ethylene Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-21-8' and x.name = 'Ethylene Oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-25-2', 'Bromoform', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-25-2' and x.name = 'Bromoform' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-26-3', '2-Bromopropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-26-3' and x.name = '2-Bromopropane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-28-5', 'Isobutane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-28-5' and x.name = 'Isobutane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-31-0', 'Isopropylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-31-0' and x.name = 'Isopropylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-33-2', 'Isopropyl Mercaptan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-33-2' and x.name = 'Isopropyl Mercaptan' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-34-3', '1,1-Dichloroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-34-3' and x.name = '1,1-Dichloroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-35-4', 'Vinylidene Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-35-4' and x.name = 'Vinylidene Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-36-5', 'Acetyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-36-5' and x.name = 'Acetyl Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-37-6', '1,1-Difluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-37-6' and x.name = '1,1-Difluoroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-38-7', 'Vinylidene Fluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-38-7' and x.name = 'Vinylidene Fluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-43-4', 'Dichloromonofluoromethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-43-4' and x.name = 'Dichloromonofluoromethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-44-5', 'Phosgene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-44-5' and x.name = 'Phosgene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-45-6', 'Chlorodifluoromethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-45-6' and x.name = 'Chlorodifluoromethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-47-8', 'Iodoform', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-47-8' and x.name = 'Iodoform' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-50-3', 'Trimethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-50-3' and x.name = 'Trimethylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-52-5', 'Nitromethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-52-5' and x.name = 'Nitromethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-55-8', 'Propylene Imine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-55-8' and x.name = 'Propylene Imine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-56-9', 'Propylene Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-56-9' and x.name = 'Propylene Oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-61-6', 'Difluorodibromomethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-61-6' and x.name = 'Difluorodibromomethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-63-8', 'Trifluoromonobromomethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-63-8' and x.name = 'Trifluoromonobromomethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-65-0', 'tert-Butyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-65-0' and x.name = 'tert-Butyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-66-1', 't-Butylmercaptan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-66-1' and x.name = 't-Butylmercaptan' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-69-4', 'Fluorotrichloromethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-69-4' and x.name = 'Fluorotrichloromethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-71-8', 'Dichlorodifluoromethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-71-8' and x.name = 'Dichlorodifluoromethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-73-0', 'Carbon Tetrafluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-73-0' and x.name = 'Carbon Tetrafluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-74-1', 'Tetramethyl Lead (as Pb)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-74-1' and x.name = 'Tetramethyl Lead (as Pb)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-75-2', 'Methanesulfonic acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-75-2' and x.name = 'Methanesulfonic acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-85-4', 't-Amyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-85-4' and x.name = 't-Amyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-89-8', '2,2,2-Trifluoroethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-89-8' and x.name = '2,2,2-Trifluoroethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-99-0', '2,2-Dichloropropionic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-99-0' and x.name = '2,2-Dichloropropionic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-01-7', 'Pentachloroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-01-7' and x.name = 'Pentachloroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-03-9', 'Trichloroacetic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-03-9' and x.name = 'Trichloroacetic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-06-2', 'Chloropicrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-06-2' and x.name = 'Chloropicrin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-11-9', '1,1,1,2-Tetrachloro-2,2-Difluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-11-9' and x.name = '1,1,1,2-Tetrachloro-2,2-Difluoroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-12-0', '1,1,2,2-Tetrachloro-1,2-Difluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-12-0' and x.name = '1,1,2,2-Tetrachloro-1,2-Difluoroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-13-1', '1,1,2-Trichloro-1,2,2-Trifluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-13-1' and x.name = '1,1,2-Trichloro-1,2,2-Trifluoroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-14-2', 'Dichlorotetrafluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-14-2' and x.name = 'Dichlorotetrafluoroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-15-3', 'Chloropentafluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-15-3' and x.name = 'Chloropentafluoroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-22-2', 'Camphor', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-22-2' and x.name = 'Camphor' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-25-5', 'Triamcinolone acetonide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-25-5' and x.name = 'Triamcinolone acetonide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-38-0', 'Methoxyflurane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-38-0' and x.name = 'Methoxyflurane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-44-8', 'Heptachlor', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-44-8' and x.name = 'Heptachlor' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-87-9', 'Triphenyltin Hydroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-87-9' and x.name = 'Triphenyltin Hydroxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '77-47-4', 'Hexachlorocyclopentadiene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '77-47-4' and x.name = 'Hexachlorocyclopentadiene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '77-58-7', 'Dibutyltin Dilaurate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '77-58-7' and x.name = 'Dibutyltin Dilaurate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '77-76-9', '2,2-Dimethoxypropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '77-76-9' and x.name = '2,2-Dimethoxypropane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '77-78-1', 'Dimethyl Sulfate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '77-78-1' and x.name = 'Dimethyl Sulfate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '77-92-9', 'Citric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '77-92-9' and x.name = 'Citric Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-00-2', 'Tetraethyl Lead (as Pb)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-00-2' and x.name = 'Tetraethyl Lead (as Pb)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-04-6', 'Dibutyltin Maleate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-04-6' and x.name = 'Dibutyltin Maleate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-10-4', 'Ethyl Silicate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-10-4' and x.name = 'Ethyl Silicate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-11-5', 'Pentaerythritol Tetranitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-11-5' and x.name = 'Pentaerythritol Tetranitrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-30-8', 'Triorthocresyl Phosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-30-8' and x.name = 'Triorthocresyl Phosphate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-34-2', 'Dioxathion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-34-2' and x.name = 'Dioxathion' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-40-0', 'Triethyl Phosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-40-0' and x.name = 'Triethyl Phosphate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-44-4', 'Carisoprodol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-44-4' and x.name = 'Carisoprodol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-48-8', 'Tributylphosphorotrithioate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-48-8' and x.name = 'Tributylphosphorotrithioate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-59-1', 'Isophorone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-59-1' and x.name = 'Isophorone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-78-4', '2-Methylbutane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-78-4' and x.name = '2-Methylbutane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-81-9', 'Isobutylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-81-9' and x.name = 'Isobutylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-82-0', 'Isobutyronitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-82-0' and x.name = 'Isobutyronitrile' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-83-1', 'Isobutyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-83-1' and x.name = 'Isobutyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-84-2', 'Isobutyraldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-84-2' and x.name = 'Isobutyraldehyde' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-87-5', 'Propylene Dichloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-87-5' and x.name = 'Propylene Dichloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-90-0', 'Propylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-90-0' and x.name = 'Propylenediamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-92-2', 'sec-Butyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-92-2' and x.name = 'sec-Butyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-93-3', '2-Butanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-93-3' and x.name = '2-Butanone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-94-4', 'Methyl vinyl ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-94-4' and x.name = 'Methyl vinyl ketone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-96-6', '1-Amino-2-Propanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-96-6' and x.name = '1-Amino-2-Propanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-00-5', '1,1,2-Trichloroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-00-5' and x.name = '1,1,2-Trichloroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-01-6', 'Trichloroethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-01-6' and x.name = 'Trichloroethylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-04-9', 'Chloroacetyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-04-9' and x.name = 'Chloroacetyl Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-06-1', 'Acrylamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-06-1' and x.name = 'Acrylamide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-08-3', 'Bromoacetic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-08-3' and x.name = 'Bromoacetic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-09-4', 'Propionic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-09-4' and x.name = 'Propionic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-10-7', 'Acrylic acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-10-7' and x.name = 'Acrylic acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-11-8', 'Monochloroacetic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-11-8' and x.name = 'Monochloroacetic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-14-1', 'Glycolic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-14-1' and x.name = 'Glycolic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-16-3', 'Methylacetamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-16-3' and x.name = 'Methylacetamide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-20-9', 'Methyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-20-9' and x.name = 'Methyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-24-3', 'Nitroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-24-3' and x.name = 'Nitroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-27-6', 'Acetylene Tetrabromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-27-6' and x.name = 'Acetylene Tetrabromide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-29-8', '2,3-Dimethylbutane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-29-8' and x.name = '2,3-Dimethylbutane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-34-5', '1,1,2,2-Tetrachloroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-34-5' and x.name = '1,1,2,2-Tetrachloroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-38-9', 'Chlorotrifluoroethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-38-9' and x.name = 'Chlorotrifluoroethylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-41-4', 'Methacrylic acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-41-4' and x.name = 'Methacrylic acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-46-9', '2-Nitropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-46-9' and x.name = '2-Nitropropane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-92-5', 'Camphene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-92-5' and x.name = 'Camphene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-94-7', 'Tetrabromobisphenol A', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-94-7' and x.name = 'Tetrabromobisphenol A' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-05-7', 'Bisphenol A', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-05-7' and x.name = 'Bisphenol A' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-08-0', '4,4''-Sulfonyldianiline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-08-0' and x.name = '4,4''-Sulfonyldianiline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-15-9', 'Cumene Hydroperoxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-15-9' and x.name = 'Cumene Hydroperoxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-43-3', 'Dicumyl Peroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-43-3' and x.name = 'Dicumyl Peroxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-55-7', 'Ethyl alpha-Hydroxy Isobutyrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-55-7' and x.name = 'Ethyl alpha-Hydroxy Isobutyrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-56-8', 'alpha-Pinene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-56-8' and x.name = 'alpha-Pinene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-62-6', 'Methyl Methacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-62-6' and x.name = 'Methyl Methacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-71-7', '3-Methyl-2-Cyclopentene-2-ol-one', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-71-7' and x.name = '3-Methyl-2-Cyclopentene-2-ol-one' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '81-07-2', 'Saccharin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '81-07-2' and x.name = 'Saccharin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '81-16-3', 'Tobias Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '81-16-3' and x.name = 'Tobias Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '81-81-2', 'Warfarin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '81-81-2' and x.name = 'Warfarin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '81-88-9', 'D & C Red #19', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '81-88-9' and x.name = 'D & C Red #19' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '82-66-6', '2-Diphenyl-1,3-Indandione', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '82-66-6' and x.name = '2-Diphenyl-1,3-Indandione' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '82-68-8', 'Pentachloronitrobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '82-68-8' and x.name = 'Pentachloronitrobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '83-26-1', 'Pindone (2-Pivalyl-1,3-indandione)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '83-26-1' and x.name = 'Pindone (2-Pivalyl-1,3-indandione)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '83-32-9', 'Acenaphthene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '83-32-9' and x.name = 'Acenaphthene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '83-79-4', 'Rotenone (Commercial)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '83-79-4' and x.name = 'Rotenone (Commercial)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '84-66-2', 'Diethyl Phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '84-66-2' and x.name = 'Diethyl Phthalate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '84-74-2', 'Dibutyl Phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '84-74-2' and x.name = 'Dibutyl Phthalate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '84-75-3', 'Di-n-hexyl phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '84-75-3' and x.name = 'Di-n-hexyl phthalate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '85-00-7', 'Diquat', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '85-00-7' and x.name = 'Diquat' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '85-01-8', 'Phenanthrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '85-01-8' and x.name = 'Phenanthrene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '85-42-7', 'Hexahydrophthalic Anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '85-42-7' and x.name = 'Hexahydrophthalic Anhydride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '85-44-9', 'Phthalic Anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '85-44-9' and x.name = 'Phthalic Anhydride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '85-68-7', 'Butyl Benzyl Phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '85-68-7' and x.name = 'Butyl Benzyl Phthalate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '85-86-9', 'Sudan III', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '85-86-9' and x.name = 'Sudan III' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '86-30-6', 'N-Nitrosodiphenylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '86-30-6' and x.name = 'N-Nitrosodiphenylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '86-50-0', 'Azinphos-Methyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '86-50-0' and x.name = 'Azinphos-Methyl' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '86-73-7', 'Fluorene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '86-73-7' and x.name = 'Fluorene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '86-74-8', 'Carbazole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '86-74-8' and x.name = 'Carbazole' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '86-88-4', 'ANTU', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '86-88-4' and x.name = 'ANTU' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '87-33-2', 'Isosorbide dinitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '87-33-2' and x.name = 'Isosorbide dinitrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '87-56-9', 'Mucochloric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '87-56-9' and x.name = 'Mucochloric Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '87-61-6', '1,2,3-Trichlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '87-61-6' and x.name = '1,2,3-Trichlorobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '87-68-3', 'Hexachlorobutadiene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '87-68-3' and x.name = 'Hexachlorobutadiene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '87-86-5', 'Pentachlorophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '87-86-5' and x.name = 'Pentachlorophenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88-12-0', 'N-Vinyl-2-Pyrrolidinone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88-12-0' and x.name = 'N-Vinyl-2-Pyrrolidinone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88-53-9', '6-Chloro-m-Toluidine-4-Sulfonic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88-53-9' and x.name = '6-Chloro-m-Toluidine-4-Sulfonic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88-73-3', '1-Chloro-2-nitrobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88-73-3' and x.name = '1-Chloro-2-nitrobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88-74-4', 'o-Nitroaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88-74-4' and x.name = 'o-Nitroaniline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88-85-7', '4,6-Dinitro-o-sec-butyl phenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88-85-7' and x.name = '4,6-Dinitro-o-sec-butyl phenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88-89-1', 'Picric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88-89-1' and x.name = 'Picric Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88-99-3', 'Phthalic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88-99-3' and x.name = 'Phthalic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '89-72-5', 'o-sec-Butylphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '89-72-5' and x.name = 'o-sec-Butylphenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-05-1', '2-Methoxyphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-05-1' and x.name = '2-Methoxyphenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-11-9', '1-Bromonaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-11-9' and x.name = '1-Bromonaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-12-0', '1-Methylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-12-0' and x.name = '1-Methylnaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-13-1', 'alpha-Chloronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-13-1' and x.name = 'alpha-Chloronaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-30-2', 'N-Phenyl-1-Naphthylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-30-2' and x.name = 'N-Phenyl-1-Naphthylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-43-7', 'o-Phenyl Phenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-43-7' and x.name = 'o-Phenyl Phenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-72-2', 'Tri(Dimethylaminomethyl)phenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-72-2' and x.name = 'Tri(Dimethylaminomethyl)phenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-94-8', 'Tetramethyldiaminobenzophenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-94-8' and x.name = 'Tetramethyldiaminobenzophenone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-08-7', 'Toluene-2,6-Diisocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-08-7' and x.name = 'Toluene-2,6-Diisocyanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-17-8', 'trans-Decahydronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-17-8' and x.name = 'trans-Decahydronaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-20-3', 'Naphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-20-3' and x.name = 'Naphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-57-6', '2-Methylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-57-6' and x.name = '2-Methylnaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-59-8', 'beta-Naphthylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-59-8' and x.name = 'beta-Naphthylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-64-5', 'Coumarin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-64-5' and x.name = 'Coumarin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-66-7', 'N,N-Diethylaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-66-7' and x.name = 'N,N-Diethylaniline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-94-1', '3,3''-Dichlorobenzidine and its salts', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-94-1' and x.name = '3,3''-Dichlorobenzidine and its salts' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-43-3', '1-Phenyl-3-pyrazolidinone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-43-3' and x.name = '1-Phenyl-3-pyrazolidinone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-48-8', '6-Methylcoumarin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-48-8' and x.name = '6-Methylcoumarin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-52-4', 'Diphenyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-52-4' and x.name = 'Diphenyl' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-67-1', '4-Aminodiphenyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-67-1' and x.name = '4-Aminodiphenyl' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-70-6', '3-Hydroxy-2-Naphthoic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-70-6' and x.name = '3-Hydroxy-2-Naphthoic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-84-2', 'Phenothiazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-84-2' and x.name = 'Phenothiazine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-87-5', 'Benzidine Based Dyes', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-87-5' and x.name = 'Benzidine Based Dyes' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-87-5', 'Benzidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-87-5' and x.name = 'Benzidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-93-3', '4-Nitrodiphenyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-93-3' and x.name = '4-Nitrodiphenyl' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-94-4', 'Terphenyls', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-94-4' and x.name = 'Terphenyls' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93-46-9', 'N,N''-Di-beta-naphthyl-p-phenylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93-46-9' and x.name = 'N,N''-Di-beta-naphthyl-p-phenylenediamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93-58-3', 'Methyl Benzoate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93-58-3' and x.name = 'Methyl Benzoate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93-65-2', 'MCPP', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93-65-2' and x.name = 'MCPP' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93-72-1', 'Silvex', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93-72-1' and x.name = 'Silvex' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93-76-5', '2,4,5-T', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93-76-5' and x.name = '2,4,5-T' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93-79-8', '2,4,5-T, Butyl Ester', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93-79-8' and x.name = '2,4,5-T, Butyl Ester' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '94-13-3', 'Propyl Paraben', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '94-13-3' and x.name = 'Propyl Paraben' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '94-36-0', 'Benzoyl Peroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '94-36-0' and x.name = 'Benzoyl Peroxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '94-74-6', 'MCPA', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '94-74-6' and x.name = 'MCPA' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '94-75-7', '2,4-D', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '94-75-7' and x.name = '2,4-D' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '94-80-4', '2,4-D Butyl Ester', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '94-80-4' and x.name = '2,4-D Butyl Ester' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '94-96-2', '2-Ethyl-1,2-Hexanediol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '94-96-2' and x.name = '2-Ethyl-1,2-Hexanediol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-13-6', 'Indene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-13-6' and x.name = 'Indene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-16-9', 'Benzothiazole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-16-9' and x.name = 'Benzothiazole' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-31-8', 'N-t-Butyl-2-Benzothiazolesulfenamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-31-8' and x.name = 'N-t-Butyl-2-Benzothiazolesulfenamide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-33-0', 'N-Cyclohexyl-2-benzothiazolesulfenamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-33-0' and x.name = 'N-Cyclohexyl-2-benzothiazolesulfenamide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-47-6', 'o-Xylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-47-6' and x.name = 'o-Xylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-49-8', 'o-Chlorotoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-49-8' and x.name = 'o-Chlorotoluene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-50-1', 'o-Dichlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-50-1' and x.name = 'o-Dichlorobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-51-2', 'o-Chloroaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-51-2' and x.name = 'o-Chloroaniline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-53-4', 'o-Toluidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-53-4' and x.name = 'o-Toluidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-54-5', 'o-Phenylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-54-5' and x.name = 'o-Phenylenediamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-57-8', 'o-Chlorophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-57-8' and x.name = 'o-Chlorophenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-76-1', '3,4-Dichloroaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-76-1' and x.name = '3,4-Dichloroaniline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-80-7', 'Toluene-2,4-Diamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-80-7' and x.name = 'Toluene-2,4-Diamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-93-2', '1,2,4,5-Tetramethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-93-2' and x.name = '1,2,4,5-Tetramethylbenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-94-3', '1,2,4,5-Tetrachlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-94-3' and x.name = '1,2,4,5-Tetrachlorobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-05-9', 'Allyl Methacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-05-9' and x.name = 'Allyl Methacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-09-3', '1,2-Epoxyethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-09-3' and x.name = '1,2-Epoxyethylbenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-12-8', '1,2-Dibromo-3-Chloropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-12-8' and x.name = '1,2-Dibromo-3-Chloropropane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-14-0', '3-Methylpentane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-14-0' and x.name = '3-Methylpentane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-18-4', '1,2,3-Trichloropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-18-4' and x.name = '1,2,3-Trichloropropane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-22-0', 'Diethyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-22-0' and x.name = 'Diethyl Ketone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-29-7', 'Methyl Ethyl Ketoxime', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-29-7' and x.name = 'Methyl Ethyl Ketoxime' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-33-3', 'Methyl Acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-33-3' and x.name = 'Methyl Acrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-37-7', 'Methylcyclopentane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-37-7' and x.name = 'Methylcyclopentane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-45-7', 'Ethylene Thiourea', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-45-7' and x.name = 'Ethylene Thiourea' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-48-0', 'gamma-Butyrolactone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-48-0' and x.name = 'gamma-Butyrolactone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-69-5', '4,4''-Thiobis(6-tert-Butyl-m-Cresol) (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-69-5' and x.name = '4,4''-Thiobis(6-tert-Butyl-m-Cresol) (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-69-5', '4,4''-Thiobis(6-tert-Butyl-m-Cresol) (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-69-5' and x.name = '4,4''-Thiobis(6-tert-Butyl-m-Cresol) (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-76-4', '2,4-Di-Tert-Butylphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-76-4' and x.name = '2,4-Di-Tert-Butylphenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-91-3', 'Picramic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-91-3' and x.name = 'Picramic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-00-7', '2,4-Dinitrochlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-00-7' and x.name = '2,4-Dinitrochlorobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-23-4', '2,2''-Methylene-bis(4-chlorophenol)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-23-4' and x.name = '2,2''-Methylene-bis(4-chlorophenol)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-63-2', 'Ethyl Methacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-63-2' and x.name = 'Ethyl Methacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-64-3', 'Ethyl Lactate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-64-3' and x.name = 'Ethyl Lactate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-77-8', 'Disulfiram', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-77-8' and x.name = 'Disulfiram' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-84-7', 'Tetramethyl Butanediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-84-7' and x.name = 'Tetramethyl Butanediamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-85-8', 'Isobutyl Isobutyrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-85-8' and x.name = 'Isobutyl Isobutyrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-86-9', 'Isobutyl Methacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-86-9' and x.name = 'Isobutyl Methacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-88-1', 'Butyl Methacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-88-1' and x.name = 'Butyl Methacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-90-5', 'Ethylene Dimethacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-90-5' and x.name = 'Ethylene Dimethacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-99-4', 'Tetrahydro-2-furanmethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-99-4' and x.name = 'Tetrahydro-2-furanmethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-00-0', 'Furfuryl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-00-0' and x.name = 'Furfuryl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-01-1', 'Furfural', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-01-1' and x.name = 'Furfural' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-07-7', 'Benzotrichloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-07-7' and x.name = 'Benzotrichloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-09-9', 'Benzenesulfonyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-09-9' and x.name = 'Benzenesulfonyl Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-11-3', 'Benzenesulfonic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-11-3' and x.name = 'Benzenesulfonic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-51-1', 'p-tert-Butyltoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-51-1' and x.name = 'p-tert-Butyltoluene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-54-4', 'p-(tert-Butyl)Phenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-54-4' and x.name = 'p-(tert-Butyl)Phenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-55-5', 'Terpineol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-55-5' and x.name = 'Terpineol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-56-6', '1-Chloro-4-trifluoromethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-56-6' and x.name = '1-Chloro-4-trifluoromethylbenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-59-9', 'Toluenesulfonyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-59-9' and x.name = 'Toluenesulfonyl Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-82-8', 'Cumene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-82-8' and x.name = 'Cumene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-83-9', 'alpha-Methyl Styrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-83-9' and x.name = 'alpha-Methyl Styrene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-86-2', 'Acetophenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-86-2' and x.name = 'Acetophenone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-87-3', '(Dichloromethyl)benzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-87-3' and x.name = '(Dichloromethyl)benzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-88-4', 'Benzoyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-88-4' and x.name = 'Benzoyl Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-94-2', 'N,N-Dimethylcyclohexylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-94-2' and x.name = 'N,N-Dimethylcyclohexylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-95-3', 'Nitrobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-95-3' and x.name = 'Nitrobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-06-9', 'm-Hydroxybenzoic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-06-9' and x.name = 'm-Hydroxybenzoic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-07-0', '(Dimethylamino)phenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-07-0' and x.name = '(Dimethylamino)phenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-08-1', 'Nitrotoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-08-1' and x.name = 'Nitrotoluene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-30-9', 'Botran', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-30-9' and x.name = 'Botran' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-76-3', 'Methylparaben', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-76-3' and x.name = 'Methylparaben' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-83-2', 'alpha-Phellandrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-83-2' and x.name = 'alpha-Phellandrene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-86-5', 'alpha-Terpinene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-86-5' and x.name = 'alpha-Terpinene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-87-6', 'Cymene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-87-6' and x.name = 'Cymene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-97-8', 'N,N-Dimethyl-p-Toluidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-97-8' and x.name = 'N,N-Dimethyl-p-Toluidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-00-5', 'p-Nitrochlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-00-5' and x.name = 'p-Nitrochlorobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-01-6', 'p-Nitroaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-01-6' and x.name = 'p-Nitroaniline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-02-7', 'p-Nitrophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-02-7' and x.name = 'p-Nitrophenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-11-8', 'para-Nitrobenzyl Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-11-8' and x.name = 'para-Nitrobenzyl Bromide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-37-8', 'Diethylamino ethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-37-8' and x.name = 'Diethylamino ethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-39-0', 'Benzyl Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-39-0' and x.name = 'Benzyl Bromide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-41-4', 'Ethyl Benzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-41-4' and x.name = 'Ethyl Benzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-42-5', 'Styrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-42-5' and x.name = 'Styrene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-44-7', 'Benzyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-44-7' and x.name = 'Benzyl Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-51-6', 'Benzyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-51-6' and x.name = 'Benzyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-52-7', 'Benzaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-52-7' and x.name = 'Benzaldehyde' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-61-8', 'Monomethyl Aniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-61-8' and x.name = 'Monomethyl Aniline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-63-0', 'Phenylhydrazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-63-0' and x.name = 'Phenylhydrazine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-66-3', 'Anisole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-66-3' and x.name = 'Anisole' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-74-3', 'N-Ethylmorpholine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-74-3' and x.name = 'N-Ethylmorpholine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-75-4', 'N-Nitrosopiperidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-75-4' and x.name = 'N-Nitrosopiperidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-97-0', 'Hexamethylenetetramine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-97-0' and x.name = 'Hexamethylenetetramine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '101-14-4', '4,4''-Methylene-bis(2-Chloroaniline)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '101-14-4' and x.name = '4,4''-Methylene-bis(2-Chloroaniline)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '101-21-3', 'Isopropyl m-Chlorocarbaniliate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '101-21-3' and x.name = 'Isopropyl m-Chlorocarbaniliate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '101-68-8', 'Methylene bisphenyl isocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '101-68-8' and x.name = 'Methylene bisphenyl isocyanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '101-77-9', '4,4''-Methylenedianiline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '101-77-9' and x.name = '4,4''-Methylenedianiline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '101-80-4', '4,4''-Oxydianiline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '101-80-4' and x.name = '4,4''-Oxydianiline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '101-83-7', 'Dicyclohexylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '101-83-7' and x.name = 'Dicyclohexylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '101-84-8', 'Phenyl Ether (Vapor)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '101-84-8' and x.name = 'Phenyl Ether (Vapor)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-01-2', 'Acetoacetanilide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-01-2' and x.name = 'Acetoacetanilide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-54-5', 'Dicyclopentadienyl Iron (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-54-5' and x.name = 'Dicyclopentadienyl Iron (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-54-5', 'Dicyclopentadienyl Iron (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-54-5' and x.name = 'Dicyclopentadienyl Iron (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-56-7', '2,5-Dimethoxyaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-56-7' and x.name = '2,5-Dimethoxyaniline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-60-3', 'Quadrol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-60-3' and x.name = 'Quadrol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-71-6', 'Triethanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-71-6' and x.name = 'Triethanolamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-81-8', '2-n-Dibutylaminoethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-81-8' and x.name = '2-n-Dibutylaminoethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-82-9', 'Tributylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-82-9' and x.name = 'Tributylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-09-3', 'Ethyl Hexyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-09-3' and x.name = 'Ethyl Hexyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-11-7', '2-Ethylhexyl acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-11-7' and x.name = '2-Ethylhexyl acrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-23-1', 'Di-(2-Ethylhexyl) Adipate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-23-1' and x.name = 'Di-(2-Ethylhexyl) Adipate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-34-4', '4,4''-Dithiodimorpholine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-34-4' and x.name = '4,4''-Dithiodimorpholine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-65-1', 'n-Propyl Benzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-65-1' and x.name = 'n-Propyl Benzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-71-9', 'Phenyl Isocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-71-9' and x.name = 'Phenyl Isocyanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-79-7', 'Phenyl-2-Propanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-79-7' and x.name = 'Phenyl-2-Propanone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-82-2', 'Phenyl Acetic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-82-2' and x.name = 'Phenyl Acetic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-83-3', 'N,N-Dimethylbenzylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-83-3' and x.name = 'N,N-Dimethylbenzylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-84-4', 'Acetanilide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-84-4' and x.name = 'Acetanilide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-90-2', 'Tylenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-90-2' and x.name = 'Tylenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '104-15-4', 'p-Toluenesulfonic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '104-15-4' and x.name = 'p-Toluenesulfonic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '104-55-2', 'Cinnamaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '104-55-2' and x.name = 'Cinnamaldehyde' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '104-75-6', '2-Ethylhexylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '104-75-6' and x.name = '2-Ethylhexylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '104-76-7', '2-Ethylhexanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '104-76-7' and x.name = '2-Ethylhexanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '104-78-9', 'Diethylaminopropylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '104-78-9' and x.name = 'Diethylaminopropylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '104-87-0', 'Tolualdehyde (o, m and p isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '104-87-0' and x.name = 'Tolualdehyde (o, m and p isomers)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-05-5', 'p-Diethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-05-5' and x.name = 'p-Diethylbenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-37-3', 'Ethyl Propionate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-37-3' and x.name = 'Ethyl Propionate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-46-4', 'sec-Butyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-46-4' and x.name = 'sec-Butyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-54-4', 'Ethyl Butyrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-54-4' and x.name = 'Ethyl Butyrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-58-8', 'Diethyl Carbonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-58-8' and x.name = 'Diethyl Carbonate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-59-9', 'N-Methyldiethanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-59-9' and x.name = 'N-Methyldiethanolamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-60-2', 'Caprolactam (Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-60-2' and x.name = 'Caprolactam (Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-60-2', 'Caprolactam (Vapor)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-60-2' and x.name = 'Caprolactam (Vapor)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-35-4', 'Ethyl Butyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-35-4' and x.name = 'Ethyl Butyl Ketone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-42-3', 'p-Xylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-42-3' and x.name = 'p-Xylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-43-4', 'p-Chlorotoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-43-4' and x.name = 'p-Chlorotoluene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-46-7', 'p-Dichlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-46-7' and x.name = 'p-Dichlorobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-47-8', 'p-Chloroaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-47-8' and x.name = 'p-Chloroaniline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-48-9', 'p-Chlorophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-48-9' and x.name = 'p-Chlorophenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-49-0', 'p-Toluidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-49-0' and x.name = 'p-Toluidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-50-3', 'p-Phenylene Diamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-50-3' and x.name = 'p-Phenylene Diamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-51-4', 'Quinone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-51-4' and x.name = 'Quinone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-63-8', 'Isobutyl Acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-63-8' and x.name = 'Isobutyl Acrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-65-0', 'Dimethyl Succinate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-65-0' and x.name = 'Dimethyl Succinate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-71-8', 'Cyanoethyl acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-71-8' and x.name = 'Cyanoethyl acrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-87-6', 'Vinyl Cyclohexene Dioxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-87-6' and x.name = 'Vinyl Cyclohexene Dioxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-88-7', '1,2-Epoxybutane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-88-7' and x.name = '1,2-Epoxybutane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-89-8', 'Epichlorohydrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-89-8' and x.name = 'Epichlorohydrin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-91-2', 'Glycidyl Methacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-91-2' and x.name = 'Glycidyl Methacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-92-3', 'Allyl Glycidyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-92-3' and x.name = 'Allyl Glycidyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-93-4', 'Ethylene Dibromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-93-4' and x.name = 'Ethylene Dibromide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-94-5', '1-Bromopropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-94-5' and x.name = '1-Bromopropane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-97-8', 'Butane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-97-8' and x.name = 'Butane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-99-0', 'Butadiene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-99-0' and x.name = 'Butadiene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-02-8', 'Acrolein', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-02-8' and x.name = 'Acrolein' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-05-1', 'Allyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-05-1' and x.name = 'Allyl Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-06-2', 'Ethylene Dichloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-06-2' and x.name = 'Ethylene Dichloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-07-3', 'Ethylene Chlorohydrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-07-3' and x.name = 'Ethylene Chlorohydrin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-10-8', 'Propylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-10-8' and x.name = 'Propylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-12-0', 'Propionitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-12-0' and x.name = 'Propionitrile' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-13-1', 'Acrylonitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-13-1' and x.name = 'Acrylonitrile' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-15-3', 'Ethylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-15-3' and x.name = 'Ethylenediamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-18-6', 'Allyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-18-6' and x.name = 'Allyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-19-7', 'Propargyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-19-7' and x.name = 'Propargyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-20-0', 'Chloroacetaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-20-0' and x.name = 'Chloroacetaldehyde' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-21-1', 'Ethylene Glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-21-1' and x.name = 'Ethylene Glycol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-22-2', 'Glyoxal', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-22-2' and x.name = 'Glyoxal' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-30-2', 'Chloromethyl Methyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-30-2' and x.name = 'Chloromethyl Methyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-31-3', 'Methyl Formate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-31-3' and x.name = 'Methyl Formate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-41-5', 'Hexylene Glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-41-5' and x.name = 'Hexylene Glycol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-44-8', 'Sarin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-44-8' and x.name = 'Sarin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-49-3', 'TEPP', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-49-3' and x.name = 'TEPP' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-66-4', 'Dibutyl Phosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-66-4' and x.name = 'Dibutyl Phosphate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-70-0', '4-Methoxy-4-Methyl-2-Pentanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-70-0' and x.name = '4-Methoxy-4-Methyl-2-Pentanone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-83-5', '2-Methylpentane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-83-5' and x.name = '2-Methylpentane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-87-9', '2-Pentanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-87-9' and x.name = '2-Pentanone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-88-0', '1,3-Butanediol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-88-0' and x.name = '1,3-Butanediol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-92-6', 'Butyric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-92-6' and x.name = 'Butyric Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-98-2', 'Propylene Glycol Monomethyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-98-2' and x.name = 'Propylene Glycol Monomethyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-01-0', 'N,N-Dimethylethanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-01-0' and x.name = 'N,N-Dimethylethanolamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-03-2', '1-Nitropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-03-2' and x.name = '1-Nitropropane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-05-4', 'Vinyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-05-4' and x.name = 'Vinyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-10-1', 'Hexone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-10-1' and x.name = 'Hexone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-11-2', 'Methyl Isobutyl Carbinol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-11-2' and x.name = 'Methyl Isobutyl Carbinol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-18-9', 'Diisopropylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-18-9' and x.name = 'Diisopropylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-20-3', 'Isopropyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-20-3' and x.name = 'Isopropyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-21-4', 'Isopropyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-21-4' and x.name = 'Isopropyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-24-7', 'Acetic Anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-24-7' and x.name = 'Acetic Anhydride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-31-6', 'Maleic Anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-31-6' and x.name = 'Maleic Anhydride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-32-7', 'Propylene Carbonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-32-7' and x.name = 'Propylene Carbonate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-38-3', 'm-Xylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-38-3' and x.name = 'm-Xylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-41-8', 'm-Chlorotoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-41-8' and x.name = 'm-Chlorotoluene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-44-1', 'm-Toluidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-44-1' and x.name = 'm-Toluidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-45-2', 'm-Phenylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-45-2' and x.name = 'm-Phenylenediamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-46-3', 'Resorcinol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-46-3' and x.name = 'Resorcinol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-48-5', '2,6-Dimethylpyridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-48-5' and x.name = '2,6-Dimethylpyridine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-65-6', 'Propylene Glycol Monomethyl Ether Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-65-6' and x.name = 'Propylene Glycol Monomethyl Ether Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-70-3', '1,3,5-Trichlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-70-3' and x.name = '1,3,5-Trichlorobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-77-0', 'Cyanuric Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-77-0' and x.name = 'Cyanuric Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-78-1', 'Melamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-78-1' and x.name = 'Melamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-80-5', 'Cyanuric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-80-5' and x.name = 'Cyanuric Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-83-8', 'Diisobutyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-83-8' and x.name = 'Diisobutyl Ketone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-84-9', 'sec-Hexyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-84-9' and x.name = 'sec-Hexyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-86-1', 'Bromobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-86-1' and x.name = 'Bromobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-87-2', 'Methylcyclohexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-87-2' and x.name = 'Methylcyclohexane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-88-3', 'Toluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-88-3' and x.name = 'Toluene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-90-7', 'Chlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-90-7' and x.name = 'Chlorobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-91-8', 'Cyclohexylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-91-8' and x.name = 'Cyclohexylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-93-0', 'Cyclohexanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-93-0' and x.name = 'Cyclohexanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-94-1', 'Cyclohexanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-94-1' and x.name = 'Cyclohexanone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-95-2', 'Phenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-95-2' and x.name = 'Phenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-98-5', 'Phenyl Mercaptan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-98-5' and x.name = 'Phenyl Mercaptan' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-02-4', '4-Methyl Morpholine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-02-4' and x.name = '4-Methyl Morpholine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-17-1', 'Tetraethyleneglycol Dimethacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-17-1' and x.name = 'Tetraethyleneglycol Dimethacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-21-7', 'Butyl Butryrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-21-7' and x.name = 'Butyl Butryrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-46-6', 'Dibutylthiourea', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-46-6' and x.name = 'Dibutylthiourea' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-52-4', 'Valeric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-52-4' and x.name = 'Valeric Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-55-7', 'N,N-Dimethyl-1,3-propanediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-55-7' and x.name = 'N,N-Dimethyl-1,3-propanediamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-59-1', 'Isopropyl Cellosolve', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-59-1' and x.name = 'Isopropyl Cellosolve' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-60-4', 'n-Propyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-60-4' and x.name = 'n-Propyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-66-0', 'Pentane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-66-0' and x.name = 'Pentane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-67-1', '1-Pentene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-67-1' and x.name = '1-Pentene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-73-9', 'Butylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-73-9' and x.name = 'Butylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-75-1', 'Allyl Cyanide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-75-1' and x.name = 'Allyl Cyanide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-79-5', 'Butyl Mercaptan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-79-5' and x.name = 'Butyl Mercaptan' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-83-1', '2-Methylaminoethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-83-1' and x.name = '2-Methylaminoethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-86-4', '2-Methoxyethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-86-4' and x.name = '2-Methoxyethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-87-5', 'Methylal', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-87-5' and x.name = 'Methylal' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-89-7', 'Diethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-89-7' and x.name = 'Diethylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-94-4', 'Ethyl Formate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-94-4' and x.name = 'Ethyl Formate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-99-9', 'Tetrahydrofuran', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-99-9' and x.name = 'Tetrahydrofuran' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-02-1', 'Thiophene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-02-1' and x.name = 'Thiophene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-05-4', 'tert-Butylperoxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-05-4' and x.name = 'tert-Butylperoxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-12-3', 'Methyl Isoamyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-12-3' and x.name = 'Methyl Isoamyl Ketone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-16-7', 'Maleic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-16-7' and x.name = 'Maleic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-17-8', 'Fumaric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-17-8' and x.name = 'Fumaric Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-18-9', 'N,N,N'',N''-Tetramethylethylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-18-9' and x.name = 'N,N,N'',N''-Tetramethylethylenediamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-19-0', 'Isobutyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-19-0' and x.name = 'Isobutyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-43-0', 'Methyl (n-amyl) ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-43-0' and x.name = 'Methyl (n-amyl) ketone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-46-3', 'Isoamyl Nitrite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-46-3' and x.name = 'Isoamyl Nitrite' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-49-6', '2-Methoxyethyl acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-49-6' and x.name = '2-Methoxyethyl acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-54-3', 'Hexane (n-Hexane)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-54-3' and x.name = 'Hexane (n-Hexane)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-62-3', 'n-Valeraldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-62-3' and x.name = 'n-Valeraldehyde' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-69-0', 'Butyraldehyde Oxime', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-69-0' and x.name = 'Butyraldehyde Oxime' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-71-4', 'Ethylene Glycol Dimethyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-71-4' and x.name = 'Ethylene Glycol Dimethyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-80-5', '2-Ethoxyethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-80-5' and x.name = '2-Ethoxyethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-82-7', 'Cyclohexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-82-7' and x.name = 'Cyclohexane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-83-8', 'Cyclohexene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-83-8' and x.name = 'Cyclohexene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-85-0', 'Piperazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-85-0' and x.name = 'Piperazine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-86-1', 'Pyridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-86-1' and x.name = 'Pyridine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-89-4', 'Piperidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-89-4' and x.name = 'Piperidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-91-8', 'Morpholine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-91-8' and x.name = 'Morpholine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-97-4', 'Diisopropanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-97-4' and x.name = 'Diisopropanolamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-98-5', 'Dipropylene Glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-98-5' and x.name = 'Dipropylene Glycol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-15-9', '2-Ethoxyethyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-15-9' and x.name = '2-Ethoxyethyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-26-2', 'Hexylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-26-2' and x.name = 'Hexylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-27-3', 'Hexyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-27-3' and x.name = 'Hexyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-30-8', 'Glutaraldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-30-8' and x.name = 'Glutaraldehyde' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-36-4', 'Butyl Isocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-36-4' and x.name = 'Butyl Isocyanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-40-0', 'Diethylenetriamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-40-0' and x.name = 'Diethylenetriamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-41-1', 'Aminoethylethanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-41-1' and x.name = 'Aminoethylethanolamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-42-2', 'Diethanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-42-2' and x.name = 'Diethanolamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-44-4', 'Dichloroethyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-44-4' and x.name = 'Dichloroethyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-46-6', 'Diethylene Glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-46-6' and x.name = 'Diethylene Glycol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-65-9', 'Octane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-65-9' and x.name = 'Octane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-66-0', '1-Octene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-66-0' and x.name = '1-Octene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-68-2', 'n-Heptylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-68-2' and x.name = 'n-Heptylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-69-3', 'Adiponitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-69-3' and x.name = 'Adiponitrile' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-76-2', '2-Butoxyethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-76-2' and x.name = '2-Butoxyethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-77-3', 'Diethylene Glycol Monomethyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-77-3' and x.name = 'Diethylene Glycol Monomethyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-84-2', 'Nonane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-84-2' and x.name = 'Nonane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-87-5', 'Octanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-87-5' and x.name = 'Octanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-88-6', '1-Octanethiol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-88-6' and x.name = '1-Octanethiol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-90-0', 'Diethylene Glycol Monoethyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-90-0' and x.name = 'Diethylene Glycol Monoethyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-92-2', 'Dibutylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-92-2' and x.name = 'Dibutylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-96-6', 'Diglyme', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-96-6' and x.name = 'Diglyme' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-07-2', 'Butyl Cellosolve Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-07-2' and x.name = 'Butyl Cellosolve Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-15-2', 'Carbitol Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-15-2' and x.name = 'Carbitol Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-24-3', 'Triethylenetetramine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-24-3' and x.name = 'Triethylenetetramine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-25-4', 'Ethylene Glycol Monohexyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-25-4' and x.name = 'Ethylene Glycol Monohexyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-27-6', 'Triethylene Glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-27-6' and x.name = 'Triethylene Glycol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-30-1', 'Decyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-30-1' and x.name = 'Decyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-34-5', 'Butyl Carbitol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-34-5' and x.name = 'Butyl Carbitol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-50-5', 'Triethylene glycol monoethyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-50-5' and x.name = 'Triethylene glycol monoethyl ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-57-2', 'Tetraethylenepentamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-57-2' and x.name = 'Tetraethylenepentamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-59-4', 'Hexyl Carbitol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-59-4' and x.name = 'Hexyl Carbitol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-60-7', 'Tetraethylene Glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-60-7' and x.name = 'Tetraethylene Glycol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-70-9', '1-Tridecanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-70-9' and x.name = '1-Tridecanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-92-5', 'Octadecanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-92-5' and x.name = 'Octadecanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '114-26-1', 'Propoxur', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '114-26-1' and x.name = 'Propoxur' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-07-1', 'Propylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-07-1' and x.name = 'Propylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-10-6', 'Methyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-10-6' and x.name = 'Methyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-11-7', 'Isobutylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-11-7' and x.name = 'Isobutylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-29-7', 'Endosulfan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-29-7' and x.name = 'Endosulfan' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-32-2', 'Dicofol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-32-2' and x.name = 'Dicofol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-77-5', 'Pentaerythritol (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-77-5' and x.name = 'Pentaerythritol (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-77-5', 'Pentaerythritol (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-77-5' and x.name = 'Pentaerythritol (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-86-6', 'Triphenyl Phosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-86-6' and x.name = 'Triphenyl Phosphate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-90-2', 'Fensulfothion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-90-2' and x.name = 'Fensulfothion' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '116-06-3', 'Aldicarb', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '116-06-3' and x.name = 'Aldicarb' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '116-14-3', 'Tetrafluoroethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '116-14-3' and x.name = 'Tetrafluoroethylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '117-08-8', 'Tetrachlorophthalic Anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '117-08-8' and x.name = 'Tetrachlorophthalic Anhydride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '117-52-2', 'Fumarin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '117-52-2' and x.name = 'Fumarin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '117-81-7', 'Di-(2-Ethylhexyl)phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '117-81-7' and x.name = 'Di-(2-Ethylhexyl)phthalate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '117-84-0', 'Di-n-Octyl Phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '117-84-0' and x.name = 'Di-n-Octyl Phthalate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '118-52-5', '1,3-Dichloro-5,5-dimethyl hydantoin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '118-52-5' and x.name = '1,3-Dichloro-5,5-dimethyl hydantoin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '118-74-1', 'Hexachlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '118-74-1' and x.name = 'Hexachlorobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '118-96-7', '2,4,6-Trinitrotoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '118-96-7' and x.name = '2,4,6-Trinitrotoluene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-26-6', '2,4-Dinitrophenyl Hydrazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-26-6' and x.name = '2,4-Dinitrophenyl Hydrazine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-36-8', 'Methyl Salicylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-36-8' and x.name = 'Methyl Salicylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-61-9', 'Benzophenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-61-9' and x.name = 'Benzophenone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-64-2', 'Tetrahydronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-64-2' and x.name = 'Tetrahydronaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-90-4', 'o-Dianisidine-Based Dyes', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-90-4' and x.name = 'o-Dianisidine-Based Dyes' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-90-4', 'o-Dianisidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-90-4' and x.name = 'o-Dianisidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-93-7', 'o-Tolidine Based Dyes', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-93-7' and x.name = 'o-Tolidine Based Dyes' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-93-7', 'o-Tolidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-93-7' and x.name = 'o-Tolidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '120-12-7', 'Anthracene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '120-12-7' and x.name = 'Anthracene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '120-32-1', 'Chlorophene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '120-32-1' and x.name = 'Chlorophene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '120-71-8', '5-Methyl-o-Anisidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '120-71-8' and x.name = '5-Methyl-o-Anisidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '120-78-5', '2,2''-Dithiobis[benzothiazole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '120-78-5' and x.name = '2,2''-Dithiobis[benzothiazole' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '120-80-9', 'Catechol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '120-80-9' and x.name = 'Catechol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '120-82-1', '1,2,4-Trichlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '120-82-1' and x.name = '1,2,4-Trichlorobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '120-83-2', '2,4-Dichlorophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '120-83-2' and x.name = '2,4-Dichlorophenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-44-8', 'Triethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-44-8' and x.name = 'Triethylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-45-9', 'Trimethyl Phosphite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-45-9' and x.name = 'Trimethyl Phosphite' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-53-9', 'm-Sulfobenzoic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-53-9' and x.name = 'm-Sulfobenzoic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-69-7', 'Dimethylaniline (N,N-Dimethylaniline)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-69-7' and x.name = 'Dimethylaniline (N,N-Dimethylaniline)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-71-1', 'm-Hydroxyacetophenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-71-1' and x.name = 'm-Hydroxyacetophenone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-75-5', 'Malathion (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-75-5' and x.name = 'Malathion (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-82-4', 'Cyclonite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-82-4' and x.name = 'Cyclonite' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-91-5', 'Isophthalic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-91-5' and x.name = 'Isophthalic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '122-14-5', 'Fenitrothion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '122-14-5' and x.name = 'Fenitrothion' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '122-34-9', 'Simazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '122-34-9' and x.name = 'Simazine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '122-39-4', 'Diphenylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '122-39-4' and x.name = 'Diphenylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '122-60-1', 'Phenyl Glycidyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '122-60-1' and x.name = 'Phenyl Glycidyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '122-62-3', 'Dioctyl Sebacate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '122-62-3' and x.name = 'Dioctyl Sebacate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '122-99-6', '2-Phenoxyethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '122-99-6' and x.name = '2-Phenoxyethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-01-3', 'Dodecyl Benzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-01-3' and x.name = 'Dodecyl Benzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-11-5', 'o-Anisaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-11-5' and x.name = 'o-Anisaldehyde' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-19-3', 'Dipropyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-19-3' and x.name = 'Dipropyl Ketone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-31-9', 'Hydroquinone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-31-9' and x.name = 'Hydroquinone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-38-6', 'Propionaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-38-6' and x.name = 'Propionaldehyde' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-39-7', 'Methyl Formamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-39-7' and x.name = 'Methyl Formamide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-42-2', 'Diacetone Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-42-2' and x.name = 'Diacetone Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-51-3', 'Isoamyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-51-3' and x.name = 'Isoamyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-54-6', 'Acetylacetone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-54-6' and x.name = 'Acetylacetone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-72-8', 'Butyraldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-72-8' and x.name = 'Butyraldehyde' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-73-9', 'Crotonaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-73-9' and x.name = 'Crotonaldehyde' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-77-3', '1,1''-Azobisformamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-77-3' and x.name = '1,1''-Azobisformamide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-86-4', 'n-Butyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-86-4' and x.name = 'n-Butyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-91-1', 'Dioxane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-91-1' and x.name = 'Dioxane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-92-2', 'Isoamyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-92-2' and x.name = 'Isoamyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-95-5', 'Butyl Stearate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-95-5' and x.name = 'Butyl Stearate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-04-9', 'Adipic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-04-9' and x.name = 'Adipic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-07-2', 'Octanoic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-07-2' and x.name = 'Octanoic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-09-4', 'Hexamethylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-09-4' and x.name = 'Hexamethylenediamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-17-4', 'Diethylene Glycol Monobutyl Ether Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-17-4' and x.name = 'Diethylene Glycol Monobutyl Ether Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-18-5', 'Decane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-18-5' and x.name = 'Decane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-38-9', 'Carbon Dioxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-38-9' and x.name = 'Carbon Dioxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-40-3', 'Dimethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-40-3' and x.name = 'Dimethylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-68-5', '2-Amino-2-Methylpropanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-68-5' and x.name = '2-Amino-2-Methylpropanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '125-69-9', 'Dextromethorphan hydrobromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '125-69-9' and x.name = 'Dextromethorphan hydrobromide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '126-73-8', 'Tributyl Phosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '126-73-8' and x.name = 'Tributyl Phosphate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '126-98-7', 'Methyl Acrylonitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '126-98-7' and x.name = 'Methyl Acrylonitrile' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '126-99-8', 'Chloroprene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '126-99-8' and x.name = 'Chloroprene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '127-18-4', 'Tetrachloroethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '127-18-4' and x.name = 'Tetrachloroethylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '127-19-5', 'Dimethyl Acetamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '127-19-5' and x.name = 'Dimethyl Acetamide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '127-65-1', 'Chloramine-T', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '127-65-1' and x.name = 'Chloramine-T' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '127-91-3', 'beta-Pinene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '127-91-3' and x.name = 'beta-Pinene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '128-37-0', '2,6-Di-tert-Butyl-p-Cresol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '128-37-0' and x.name = '2,6-Di-tert-Butyl-p-Cresol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '128-39-2', '2,6-Di-Tert-Butylphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '128-39-2' and x.name = '2,6-Di-Tert-Butylphenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '129-00-0', 'Pyrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '129-00-0' and x.name = 'Pyrene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '129-79-3', '2,4,7-Trinitro-9-fluorenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '129-79-3' and x.name = '2,4,7-Trinitro-9-fluorenone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '131-11-3', 'Dimethylphthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '131-11-3' and x.name = 'Dimethylphthalate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '131-17-9', 'Diallyl Phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '131-17-9' and x.name = 'Diallyl Phthalate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '131-52-2', 'Sodium Pentachlorophenate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '131-52-2' and x.name = 'Sodium Pentachlorophenate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '132-27-4', 'Sodium o-Phenyl Phenate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '132-27-4' and x.name = 'Sodium o-Phenyl Phenate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '132-33-2', 'Thoron', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '132-33-2' and x.name = 'Thoron' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '132-64-9', 'Dibenzofuran', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '132-64-9' and x.name = 'Dibenzofuran' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '133-06-2', 'Captan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '133-06-2' and x.name = 'Captan' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '133-07-3', 'N-(Trichloromethylthio)phthalimide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '133-07-3' and x.name = 'N-(Trichloromethylthio)phthalimide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '133-90-4', 'Amiben', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '133-90-4' and x.name = 'Amiben' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '134-32-7', 'alpha-Naphthylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '134-32-7' and x.name = 'alpha-Naphthylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '134-81-6', 'Benzil', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '134-81-6' and x.name = 'Benzil' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '135-01-3', 'o-Diethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '135-01-3' and x.name = 'o-Diethylbenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '135-19-3', 'beta-Naphthol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '135-19-3' and x.name = 'beta-Naphthol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '135-88-6', 'N-Phenyl-2-Naphthylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '135-88-6' and x.name = 'N-Phenyl-2-Naphthylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '135-98-8', 'sec-Butylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '135-98-8' and x.name = 'sec-Butylbenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '136-23-2', 'Zinc Dibutyldithiocarbamate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '136-23-2' and x.name = 'Zinc Dibutyldithiocarbamate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '136-78-7', 'Crag Herbicide (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '136-78-7' and x.name = 'Crag Herbicide (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '136-78-7', 'Crag Herbicide (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '136-78-7' and x.name = 'Crag Herbicide (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '137-05-3', 'Methyl 2-Cyanoacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '137-05-3' and x.name = 'Methyl 2-Cyanoacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '137-26-8', 'Thiram', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '137-26-8' and x.name = 'Thiram' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '137-30-4', 'Ziram', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '137-30-4' and x.name = 'Ziram' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '137-41-7', 'Wemcide CW 104', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '137-41-7' and x.name = 'Wemcide CW 104' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '137-42-8', 'Metham Sodium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '137-42-8' and x.name = 'Metham Sodium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '138-22-7', 'n-Butyl Lactate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '138-22-7' and x.name = 'n-Butyl Lactate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '138-86-3', 'Limonene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '138-86-3' and x.name = 'Limonene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '138-93-2', '2-(2,4-Dinitrophenoxy)ethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '138-93-2' and x.name = '2-(2,4-Dinitrophenoxy)ethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '139-89-9', 'N-Hydroxyethylethylenediaminetriacetate Trisodium salt', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '139-89-9' and x.name = 'N-Hydroxyethylethylenediaminetriacetate Trisodium salt' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '140-11-4', 'Benzyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '140-11-4' and x.name = 'Benzyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '140-31-8', 'N-Aminoethylpiperazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '140-31-8' and x.name = 'N-Aminoethylpiperazine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '140-64-7', 'Pentamine Isethionate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '140-64-7' and x.name = 'Pentamine Isethionate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '140-88-5', 'Ethyl Acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '140-88-5' and x.name = 'Ethyl Acrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '141-32-2', 'Butyl Acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '141-32-2' and x.name = 'Butyl Acrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '141-43-5', 'Ethanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '141-43-5' and x.name = 'Ethanolamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '141-66-2', 'Dicrotophos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '141-66-2' and x.name = 'Dicrotophos' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '141-78-6', 'Ethyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '141-78-6' and x.name = 'Ethyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '141-79-7', 'Mesityl Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '141-79-7' and x.name = 'Mesityl Oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '141-93-5', 'm-Diethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '141-93-5' and x.name = 'm-Diethylbenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '142-22-3', 'Allyl Diglycol Carbonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '142-22-3' and x.name = 'Allyl Diglycol Carbonate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '142-28-9', '1,3-Dichloropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '142-28-9' and x.name = '1,3-Dichloropropane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '142-64-3', 'Piperazine Dihydrochloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '142-64-3' and x.name = 'Piperazine Dihydrochloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '142-82-5', 'Heptane (n-Heptane)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '142-82-5' and x.name = 'Heptane (n-Heptane)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '142-84-7', 'Dipropylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '142-84-7' and x.name = 'Dipropylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '142-92-7', 'n-Hexyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '142-92-7' and x.name = 'n-Hexyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '142-96-1', 'Di-n-Butyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '142-96-1' and x.name = 'Di-n-Butyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '143-08-8', 'Nonyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '143-08-8' and x.name = 'Nonyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '143-22-6', 'Triethylene glycol monobutyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '143-22-6' and x.name = 'Triethylene glycol monobutyl ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '143-33-9', 'Sodium cyanide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '143-33-9' and x.name = 'Sodium cyanide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '143-50-0', 'Kepone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '143-50-0' and x.name = 'Kepone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '144-21-8', 'Disodium Acid Methane Arsenate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '144-21-8' and x.name = 'Disodium Acid Methane Arsenate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '144-62-7', 'Oxalic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '144-62-7' and x.name = 'Oxalic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '144-83-2', 'Sulfapyridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '144-83-2' and x.name = 'Sulfapyridine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '148-01-6', 'Dinitolmide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '148-01-6' and x.name = 'Dinitolmide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '148-79-8', 'Thiabendazole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '148-79-8' and x.name = 'Thiabendazole' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '149-30-4', '2-Benzothiazolethiol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '149-30-4' and x.name = '2-Benzothiazolethiol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '150-19-6', '3-Methoxyphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '150-19-6' and x.name = '3-Methoxyphenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '150-76-5', '4-Methoxyphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '150-76-5' and x.name = '4-Methoxyphenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '151-21-3', 'Sodium Lauryl Sulfate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '151-21-3' and x.name = 'Sodium Lauryl Sulfate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '151-50-8', 'Potassium cyanide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '151-50-8' and x.name = 'Potassium cyanide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '151-56-4', 'Ethyleneimine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '151-56-4' and x.name = 'Ethyleneimine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '151-67-7', 'Halothane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '151-67-7' and x.name = 'Halothane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '152-11-4', '(¦)-Verapamil hydrochloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '152-11-4' and x.name = '(¦)-Verapamil hydrochloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '156-62-7', 'Calcium Cyanamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '156-62-7' and x.name = 'Calcium Cyanamide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '156-87-6', '3-Amino-1-Propanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '156-87-6' and x.name = '3-Amino-1-Propanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '191-07-1', 'Coronene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '191-07-1' and x.name = 'Coronene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '191-24-2', 'Benzo(g,h,i)perylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '191-24-2' and x.name = 'Benzo(g,h,i)perylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '192-97-2', 'Benzo (e) Pyrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '192-97-2' and x.name = 'Benzo (e) Pyrene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '193-39-5', 'Ideneo(1,2,3-cd)pyrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '193-39-5' and x.name = 'Ideneo(1,2,3-cd)pyrene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '198-55-0', 'Perylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '198-55-0' and x.name = 'Perylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '205-99-2', 'Benzo(b)fluoranthene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '205-99-2' and x.name = 'Benzo(b)fluoranthene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '206-44-0', 'Fluoranthene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '206-44-0' and x.name = 'Fluoranthene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '207-08-9', 'Benzo(k)fluoranthene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '207-08-9' and x.name = 'Benzo(k)fluoranthene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '208-96-8', 'Acenaphthylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '208-96-8' and x.name = 'Acenaphthylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '218-01-9', 'Chrysene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '218-01-9' and x.name = 'Chrysene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '260-94-6', 'Acridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '260-94-6' and x.name = 'Acridine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '271-89-6', '2,3-Benzofuran', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '271-89-6' and x.name = '2,3-Benzofuran' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '280-57-9', 'Triethylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '280-57-9' and x.name = 'Triethylenediamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '287-92-3', 'Cyclopentane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '287-92-3' and x.name = 'Cyclopentane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '298-00-0', 'Methyl Parathion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '298-00-0' and x.name = 'Methyl Parathion' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '298-02-2', 'Phorate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '298-02-2' and x.name = 'Phorate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '298-04-4', 'Disulfoton', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '298-04-4' and x.name = 'Disulfoton' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '299-84-3', 'Ronnel', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '299-84-3' and x.name = 'Ronnel' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '299-86-5', 'Crufomate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '299-86-5' and x.name = 'Crufomate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '300-76-5', 'Dimethyl-1,2-dibromo-2,2-dichloroethyl phosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '300-76-5' and x.name = 'Dimethyl-1,2-dibromo-2,2-dichloroethyl phosphate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '301-10-0', 'Stannous-2-Ethyl Hexanoate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '301-10-0' and x.name = 'Stannous-2-Ethyl Hexanoate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '301-12-2', 'Oxydemeton-Methyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '301-12-2' and x.name = 'Oxydemeton-Methyl' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '302-01-2', 'Hydrazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '302-01-2' and x.name = 'Hydrazine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '306-83-2', '2,2-Dichloro-1,1,1-trifluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '306-83-2' and x.name = '2,2-Dichloro-1,1,1-trifluoroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '309-00-2', 'Aldrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '309-00-2' and x.name = 'Aldrin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '314-40-9', 'Bromacil', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '314-40-9' and x.name = 'Bromacil' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '315-18-4', 'Zectran', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '315-18-4' and x.name = 'Zectran' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '321-55-1', 'Haloxon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '321-55-1' and x.name = 'Haloxon' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '330-54-1', 'Diuron', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '330-54-1' and x.name = 'Diuron' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '330-55-2', 'Linuron', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '330-55-2' and x.name = 'Linuron' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '333-41-5', 'Diazinon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '333-41-5' and x.name = 'Diazinon' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '334-88-3', 'Diazomethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '334-88-3' and x.name = 'Diazomethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '352-93-2', 'Diethyl Sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '352-93-2' and x.name = 'Diethyl Sulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '353-50-4', 'Carbonyl Fluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '353-50-4' and x.name = 'Carbonyl Fluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '353-66-2', 'Difluorodimethylsilane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '353-66-2' and x.name = 'Difluorodimethylsilane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '354-23-4', '1,2-Dichloro-1,1,2-Trifluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '354-23-4' and x.name = '1,2-Dichloro-1,1,2-Trifluoroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '354-58-5', '1,1,1-Trichloro-2,2,2-Trifluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '354-58-5' and x.name = '1,1,1-Trichloro-2,2,2-Trifluoroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '357-57-3', 'Brucine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '357-57-3' and x.name = 'Brucine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '374-07-2', '1,1-Dichlorotetrafluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '374-07-2' and x.name = '1,1-Dichlorotetrafluoroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '382-21-8', 'Perfluoroisobutylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '382-21-8' and x.name = 'Perfluoroisobutylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '404-86-4', 'Capsaicin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '404-86-4' and x.name = 'Capsaicin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '407-25-0', 'Trifluoroacetic Anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '407-25-0' and x.name = 'Trifluoroacetic Anhydride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '409-21-2', 'Silicon Carbide (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '409-21-2' and x.name = 'Silicon Carbide (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '409-21-2', 'Silicon Carbide (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '409-21-2' and x.name = 'Silicon Carbide (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '420-04-2', 'Cyanamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '420-04-2' and x.name = 'Cyanamide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '420-46-2', '1,1,1-Trifluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '420-46-2' and x.name = '1,1,1-Trifluoroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '422-56-0', '3,3-Dichloro-1,1,1,2,2-pentafluoropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '422-56-0' and x.name = '3,3-Dichloro-1,1,1,2,2-pentafluoropropane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '431-03-8', 'Diacetyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '431-03-8' and x.name = 'Diacetyl' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '460-19-5', 'Cyanogen', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '460-19-5' and x.name = 'Cyanogen' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '461-58-5', 'Cyanoguanidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '461-58-5' and x.name = 'Cyanoguanidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '462-08-8', '3-Aminopyridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '462-08-8' and x.name = '3-Aminopyridine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '463-04-7', 'Amyl Nitrite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '463-04-7' and x.name = 'Amyl Nitrite' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '463-51-4', 'Ketene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '463-51-4' and x.name = 'Ketene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '463-58-1', 'Carbonyl Sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '463-58-1' and x.name = 'Carbonyl Sulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '471-34-1', 'Calcium Carbonate (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '471-34-1' and x.name = 'Calcium Carbonate (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '477-73-6', 'Basic Red 2', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '477-73-6' and x.name = 'Basic Red 2' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '479-45-8', 'Tetryl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '479-45-8' and x.name = 'Tetryl' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '485-47-2', '2,2-Dihydroxy-1,3-Indandione', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '485-47-2' and x.name = '2,2-Dihydroxy-1,3-Indandione' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '486-25-9', '9-Fluorenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '486-25-9' and x.name = '9-Fluorenone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '488-23-3', '1,2,3,4-Tetramethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '488-23-3' and x.name = '1,2,3,4-Tetramethylbenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '492-80-8', 'Benzenamine, 4,4'' Carbonimidoyl bis(N,N'' dimethyl-)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '492-80-8' and x.name = 'Benzenamine, 4,4'' Carbonimidoyl bis(N,N'' dimethyl-)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '497-19-8', 'Sodium Carbonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '497-19-8' and x.name = 'Sodium Carbonate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '497-23-4', '2(5H)-Furanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '497-23-4' and x.name = '2(5H)-Furanone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '503-30-0', '1,3-Epoxypropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '503-30-0' and x.name = '1,3-Epoxypropane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '504-24-5', '4-Aminopyridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '504-24-5' and x.name = '4-Aminopyridine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '504-29-0', '2-Aminopyridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '504-29-0' and x.name = '2-Aminopyridine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '504-60-9', '1,3-Pentadiene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '504-60-9' and x.name = '1,3-Pentadiene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '505-60-2', 'bis-(2-Chloroethyl)sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '505-60-2' and x.name = 'bis-(2-Chloroethyl)sulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '506-77-4', 'Cyanogen Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '506-77-4' and x.name = 'Cyanogen Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '507-55-1', '1,3-Dichloro-1,1,2,2,3-pentafluoropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '507-55-1' and x.name = '1,3-Dichloro-1,1,2,2,3-pentafluoropropane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '509-14-8', 'Tetranitromethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '509-14-8' and x.name = 'Tetranitromethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '510-15-6', 'Ethyl-4,4''-Dichlorobenzilate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '510-15-6' and x.name = 'Ethyl-4,4''-Dichlorobenzilate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '513-86-0', 'Acetyl Methyl Carbinol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '513-86-0' and x.name = 'Acetyl Methyl Carbinol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '514-10-3', 'Abietic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '514-10-3' and x.name = 'Abietic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '527-07-1', 'Sodium Gluconate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '527-07-1' and x.name = 'Sodium Gluconate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '527-53-7', '1,2,3,5-Tetramethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '527-53-7' and x.name = '1,2,3,5-Tetramethylbenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '528-44-9', 'Trimellitic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '528-44-9' and x.name = 'Trimellitic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '529-20-4', 'Tolualdehyde (o, m and p isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '529-20-4' and x.name = 'Tolualdehyde (o, m and p isomers)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '532-27-4', 'alpha-Chloroacetophenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '532-27-4' and x.name = 'alpha-Chloroacetophenone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '533-60-8', '2-Hydroxycyclohexanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '533-60-8' and x.name = '2-Hydroxycyclohexanone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '534-52-1', 'Dinitro-o-cresol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '534-52-1' and x.name = 'Dinitro-o-cresol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '538-93-2', 'Isobutylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '538-93-2' and x.name = 'Isobutylbenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '539-48-0', 'p-Xylene-alpha,alpha''-diamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '539-48-0' and x.name = 'p-Xylene-alpha,alpha''-diamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '540-59-0', '1,2-Dichloroethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '540-59-0' and x.name = '1,2-Dichloroethylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '540-67-0', 'Ethyl Methyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '540-67-0' and x.name = 'Ethyl Methyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '540-88-5', 'tert-Butyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '540-88-5' and x.name = 'tert-Butyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '541-02-6', 'Decamethylcyclopentasiloxane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '541-02-6' and x.name = 'Decamethylcyclopentasiloxane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '541-05-9', 'Hexamethylcyclotrisiloxane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '541-05-9' and x.name = 'Hexamethylcyclotrisiloxane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '541-73-1', 'm-Dichlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '541-73-1' and x.name = 'm-Dichlorobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '541-85-5', 'Ethyl Amyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '541-85-5' and x.name = 'Ethyl Amyl Ketone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '542-56-3', 'Isobutyl Nitrite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '542-56-3' and x.name = 'Isobutyl Nitrite' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '542-75-6', '1,3-Dichloropropene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '542-75-6' and x.name = '1,3-Dichloropropene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '542-88-1', 'Bis(Chloromethyl) Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '542-88-1' and x.name = 'Bis(Chloromethyl) Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '542-92-7', 'Cyclopentadiene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '542-92-7' and x.name = 'Cyclopentadiene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '543-49-7', 'Isoheptanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '543-49-7' and x.name = 'Isoheptanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '546-93-0', 'Magnesium carbonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '546-93-0' and x.name = 'Magnesium carbonate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '547-63-7', 'Methyl Isobutyrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '547-63-7' and x.name = 'Methyl Isobutyrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '548-62-9', 'Gentian Violet', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '548-62-9' and x.name = 'Gentian Violet' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '551-06-4', '1-Naphthylisothiocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '551-06-4' and x.name = '1-Naphthylisothiocyanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '552-30-7', 'Trimellitic Anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '552-30-7' and x.name = 'Trimellitic Anhydride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '554-14-3', '2-Methylthiophene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '554-14-3' and x.name = '2-Methylthiophene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '555-77-1', 'tris-(2-Chloroethyl)amine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '555-77-1' and x.name = 'tris-(2-Chloroethyl)amine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '556-52-5', 'Glycidol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '556-52-5' and x.name = 'Glycidol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '556-61-6', 'Methyl Isothiocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '556-61-6' and x.name = 'Methyl Isothiocyanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '556-64-9', 'Methyl Thiocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '556-64-9' and x.name = 'Methyl Thiocyanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '556-67-2', 'Octamethylcyclotetrasiloxane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '556-67-2' and x.name = 'Octamethylcyclotetrasiloxane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '557-05-1', 'Zinc Stearate (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '557-05-1' and x.name = 'Zinc Stearate (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '557-05-1', 'Zinc Stearate (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '557-05-1' and x.name = 'Zinc Stearate (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '557-75-5', 'Vinyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '557-75-5' and x.name = 'Vinyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '558-13-4', 'Carbon Tetrabromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '558-13-4' and x.name = 'Carbon Tetrabromide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '561-27-3', 'Heroin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '561-27-3' and x.name = 'Heroin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '563-12-2', 'Ethion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '563-12-2' and x.name = 'Ethion' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '563-16-6', '3,3-Dimethylhexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '563-16-6' and x.name = '3,3-Dimethylhexane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '563-80-4', 'Methyl Isopropyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '563-80-4' and x.name = 'Methyl Isopropyl Ketone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '571-58-4', '1,4-Dimethylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '571-58-4' and x.name = '1,4-Dimethylnaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '573-98-8', '1,2-Dimethylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '573-98-8' and x.name = '1,2-Dimethylnaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '575-41-7', '1,3-Dimethylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '575-41-7' and x.name = '1,3-Dimethylnaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '575-43-9', '1,6-Dimethylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '575-43-9' and x.name = '1,6-Dimethylnaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '583-48-2', '3,4-Dimethylhexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '583-48-2' and x.name = '3,4-Dimethylhexane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '583-60-8', 'o-Methylcyclohexanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '583-60-8' and x.name = 'o-Methylcyclohexanone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '584-79-2', 'Allethrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '584-79-2' and x.name = 'Allethrin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '584-84-9', 'Toluene-2,4-Diisocyanate (TDI)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '584-84-9' and x.name = 'Toluene-2,4-Diisocyanate (TDI)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '584-94-1', '2,3-Dimethylhexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '584-94-1' and x.name = '2,3-Dimethylhexane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '589-43-5', '2,4-Dimethylhexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '589-43-5' and x.name = '2,4-Dimethylhexane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '589-81-1', 'Methylheptane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '589-81-1' and x.name = 'Methylheptane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '590-73-8', '2,2-Dimethylhexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '590-73-8' and x.name = '2,2-Dimethylhexane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '590-86-3', 'Isovalderaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '590-86-3' and x.name = 'Isovalderaldehyde' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '591-78-6', '2-Hexanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '591-78-6' and x.name = '2-Hexanone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '591-87-7', 'Allyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '591-87-7' and x.name = 'Allyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '592-01-8', 'Calcium cyanide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '592-01-8' and x.name = 'Calcium cyanide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '592-13-2', '2,5-Dimethylhexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '592-13-2' and x.name = '2,5-Dimethylhexane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '592-41-6', '1-Hexene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '592-41-6' and x.name = '1-Hexene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '592-76-7', '1-Heptene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '592-76-7' and x.name = '1-Heptene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '593-60-2', 'Vinyl Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '593-60-2' and x.name = 'Vinyl Bromide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '594-27-4', 'Tetramethyl Tin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '594-27-4' and x.name = 'Tetramethyl Tin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '594-42-3', 'Perchloromethyl Mercaptan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '594-42-3' and x.name = 'Perchloromethyl Mercaptan' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '594-72-9', '1,1-Dichloro-1-Nitroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '594-72-9' and x.name = '1,1-Dichloro-1-Nitroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '597-64-8', 'Tetraethyl Tin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '597-64-8' and x.name = 'Tetraethyl Tin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '598-16-3', 'Tribromoethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '598-16-3' and x.name = 'Tribromoethylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '598-56-1', 'Dimethylethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '598-56-1' and x.name = 'Dimethylethylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '600-25-9', '1-Chloro-1-Nitropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '600-25-9' and x.name = '1-Chloro-1-Nitropropane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '601-77-4', 'N-Nitrosodiisopropylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '601-77-4' and x.name = 'N-Nitrosodiisopropylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '603-34-9', 'Triphenylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '603-34-9' and x.name = 'Triphenylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '605-02-7', '1-Phenylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '605-02-7' and x.name = '1-Phenylnaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '608-93-5', 'Pentachlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '608-93-5' and x.name = 'Pentachlorobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '611-14-3', 'Ethyl Toluene (all isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '611-14-3' and x.name = 'Ethyl Toluene (all isomers)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '612-94-2', '2-Phenylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '612-94-2' and x.name = '2-Phenylnaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '614-44-4', '3-Methylthiophene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '614-44-4' and x.name = '3-Methylthiophene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '614-68-6', 'o-Tolyl Isocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '614-68-6' and x.name = 'o-Tolyl Isocyanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '615-05-4', '2,4-Diaminoanisole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '615-05-4' and x.name = '2,4-Diaminoanisole' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '617-94-7', 'Phenyl Isopropanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '617-94-7' and x.name = 'Phenyl Isopropanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '620-23-5', 'Tolualdehyde (o, m and p isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '620-23-5' and x.name = 'Tolualdehyde (o, m and p isomers)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '621-64-7', 'N-Nitrosodipropylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '621-64-7' and x.name = 'N-Nitrosodipropylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '622-40-2', 'N-(2-Hydroxyethyl)Morpholine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '622-40-2' and x.name = 'N-(2-Hydroxyethyl)Morpholine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '623-56-3', 'Ethyl Isobutyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '623-56-3' and x.name = 'Ethyl Isobutyl Ketone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '624-78-2', 'Methylethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '624-78-2' and x.name = 'Methylethylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '624-83-9', 'Methyl Isocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '624-83-9' and x.name = 'Methyl Isocyanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '624-92-0', 'Dimethyl Disulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '624-92-0' and x.name = 'Dimethyl Disulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '626-17-5', 'm-Phthalodinitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '626-17-5' and x.name = 'm-Phthalodinitrile' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '626-38-0', 'sec-Amyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '626-38-0' and x.name = 'sec-Amyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '626-67-5', 'N-Methylpiperidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '626-67-5' and x.name = 'N-Methylpiperidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '627-13-4', 'n-Propyl Nitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '627-13-4' and x.name = 'n-Propyl Nitrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '627-51-0', 'Divinyl Sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '627-51-0' and x.name = 'Divinyl Sulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '627-93-0', 'Dimethyl Adipate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '627-93-0' and x.name = 'Dimethyl Adipate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '628-63-7', 'n-Amyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '628-63-7' and x.name = 'n-Amyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '628-96-6', 'Ethylene Glycol Dinitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '628-96-6' and x.name = 'Ethylene Glycol Dinitrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '629-11-8', '1,6-Hexanediol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '629-11-8' and x.name = '1,6-Hexanediol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '629-14-1', 'Ethylene Glycol Diethyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '629-14-1' and x.name = 'Ethylene Glycol Diethyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '629-19-6', 'Dipropyl Disulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '629-19-6' and x.name = 'Dipropyl Disulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '630-08-0', 'Carbon Monoxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '630-08-0' and x.name = 'Carbon Monoxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '630-08-0', 'Carbon Monoxide (by COHb)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '630-08-0' and x.name = 'Carbon Monoxide (by COHb)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '632-99-5', 'Rosaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '632-99-5' and x.name = 'Rosaniline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '634-90-2', '1,2,3,5-Tetrachlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '634-90-2' and x.name = '1,2,3,5-Tetrachlorobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '637-50-3', 'beta-Methyl Styrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '637-50-3' and x.name = 'beta-Methyl Styrene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '637-92-3', 'Ethyl tert-butyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '637-92-3' and x.name = 'Ethyl tert-butyl ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '638-21-1', 'Phenylphosphine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '638-21-1' and x.name = 'Phenylphosphine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '646-06-0', '1,3-Dioxalane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '646-06-0' and x.name = '1,3-Dioxalane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '680-31-9', 'Hexamethyl phosphoramide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '680-31-9' and x.name = 'Hexamethyl phosphoramide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '681-84-5', 'Methyl Silicate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '681-84-5' and x.name = 'Methyl Silicate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '684-16-2', 'Hexafluoroacetone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '684-16-2' and x.name = 'Hexafluoroacetone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '693-98-1', '2-Methylimidazole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '693-98-1' and x.name = '2-Methylimidazole' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '707-07-3', 'Trimethyl orthobenzoate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '707-07-3' and x.name = 'Trimethyl orthobenzoate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '709-98-8', '3,4-Dichloropropionanilide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '709-98-8' and x.name = '3,4-Dichloropropionanilide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '732-11-6', 'Phosmet', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '732-11-6' and x.name = 'Phosmet' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '741-58-2', 'Betasan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '741-58-2' and x.name = 'Betasan' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '759-94-4', 'Dipropylthiocarbamic Acid S-Ethyl Ester', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '759-94-4' and x.name = 'Dipropylthiocarbamic Acid S-Ethyl Ester' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '763-69-9', 'Ethyl-3-ethoxypropionate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '763-69-9' and x.name = 'Ethyl-3-ethoxypropionate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '766-97-2', 'p-Methylphenylacetylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '766-97-2' and x.name = 'p-Methylphenylacetylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '768-52-5', 'N-Isopropylaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '768-52-5' and x.name = 'N-Isopropylaniline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '786-19-6', 'Carbophenothion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '786-19-6' and x.name = 'Carbophenothion' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '811-97-2', '1,1,1,2-Tetrafluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '811-97-2' and x.name = '1,1,1,2-Tetrafluoroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '818-61-1', 'Hydroxyethyl Acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '818-61-1' and x.name = 'Hydroxyethyl Acrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '822-06-0', 'Hexamethylene Diisocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '822-06-0' and x.name = 'Hexamethylene Diisocyanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '823-40-5', 'Toluene-2,6-Diamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '823-40-5' and x.name = 'Toluene-2,6-Diamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '824-78-2', 'Sodium p-Nitrophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '824-78-2' and x.name = 'Sodium p-Nitrophenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '836-30-6', '4-Nitrodiphenylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '836-30-6' and x.name = '4-Nitrodiphenylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '842-07-9', 'Sudan I', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '842-07-9' and x.name = 'Sudan I' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '868-77-9', '2-Hydroxyethyl Methacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '868-77-9' and x.name = '2-Hydroxyethyl Methacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '872-50-4', '1-Methyl-2-Pyrrolidinone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '872-50-4' and x.name = '1-Methyl-2-Pyrrolidinone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '924-16-3', 'N-Nitrosodibutylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '924-16-3' and x.name = 'N-Nitrosodibutylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '929-06-6', 'Diglycolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '929-06-6' and x.name = 'Diglycolamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '930-55-2', 'N-Nitrosopyrrolidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '930-55-2' and x.name = 'N-Nitrosopyrrolidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '939-27-5', '2-Ethylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '939-27-5' and x.name = '2-Ethylnaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '944-22-9', 'Fonofos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '944-22-9' and x.name = 'Fonofos' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '947-92-2', 'Dicyclohexylnitrosamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '947-92-2' and x.name = 'Dicyclohexylnitrosamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '950-37-8', 'Methidathion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '950-37-8' and x.name = 'Methidathion' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '961-11-5', 'Rabon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '961-11-5' and x.name = 'Rabon' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '987-24-6', 'Betamethasone Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '987-24-6' and x.name = 'Betamethasone Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '992-59-6', 'Direct Red 2', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '992-59-6' and x.name = 'Direct Red 2' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '999-61-1', '2-Hydroxypropyl Acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '999-61-1' and x.name = '2-Hydroxypropyl Acrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '999-97-3', 'Hexamethyldisilazane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '999-97-3' and x.name = 'Hexamethyldisilazane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1025-15-6', 'Trially Isocyanurate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1025-15-6' and x.name = 'Trially Isocyanurate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1066-40-6', 'Trimethylsilanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1066-40-6' and x.name = 'Trimethylsilanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1076-38-6', '4-Hydroxycoumarin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1076-38-6' and x.name = '4-Hydroxycoumarin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1076-43-3', 'Hexadeutorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1076-43-3' and x.name = 'Hexadeutorobenzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1078-19-9', '6-Methoxytetralone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1078-19-9' and x.name = '6-Methoxytetralone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1111-78-0', 'Ammonium Carbamate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1111-78-0' and x.name = 'Ammonium Carbamate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1116-54-7', 'N-Nitrosodiethanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1116-54-7' and x.name = 'N-Nitrosodiethanolamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1118-46-3', 'Butyltin Trichloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1118-46-3' and x.name = 'Butyltin Trichloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1119-40-0', 'Dimethyl Glutarate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1119-40-0' and x.name = 'Dimethyl Glutarate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1120-21-4', 'Undecane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1120-21-4' and x.name = 'Undecane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1127-76-0', '1-Ethylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1127-76-0' and x.name = '1-Ethylnaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1138-52-9', '3,5-Di-Tert-Butylphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1138-52-9' and x.name = '3,5-Di-Tert-Butylphenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1141-16-5', 'Chlorodiphenyl (32% Cl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1141-16-5' and x.name = 'Chlorodiphenyl (32% Cl)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1162-65-8', 'Aflatoxin (B1)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1162-65-8' and x.name = 'Aflatoxin (B1)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1163-19-5', 'Decabromodiphenyl Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1163-19-5' and x.name = 'Decabromodiphenyl Oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1165-39-5', 'Aflatoxin (G1)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1165-39-5' and x.name = 'Aflatoxin (G1)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1189-85-1', 'tert-Butyl Chromate (as CrO3)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1189-85-1' and x.name = 'tert-Butyl Chromate (as CrO3)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1239-45-8', 'Ethidium Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1239-45-8' and x.name = 'Ethidium Bromide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1300-71-6', 'Xylenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1300-71-6' and x.name = 'Xylenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1300-73-8', 'Xylidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1300-73-8' and x.name = 'Xylidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1302-74-5', 'Corundum', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1302-74-5' and x.name = 'Corundum' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1303-43-4', 'Borates, Tetra, Sodium Salts, Anhydrous', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1303-43-4' and x.name = 'Borates, Tetra, Sodium Salts, Anhydrous' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1303-86-2', 'Boron Oxide (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1303-86-2' and x.name = 'Boron Oxide (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1303-96-4', 'Borates, Tetra, Sodium Salts, Decahydrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1303-96-4' and x.name = 'Borates, Tetra, Sodium Salts, Decahydrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1304-82-1', 'Bismuth Telluride, Se Doped', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1304-82-1' and x.name = 'Bismuth Telluride, Se Doped' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1304-82-1', 'Bismuth Telluride, Undoped (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1304-82-1' and x.name = 'Bismuth Telluride, Undoped (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1304-82-1', 'Bismuth Telluride, Undoped (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1304-82-1' and x.name = 'Bismuth Telluride, Undoped (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1305-62-0', 'Calcium Hydroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1305-62-0' and x.name = 'Calcium Hydroxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1305-78-8', 'Calcium Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1305-78-8' and x.name = 'Calcium Oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1306-19-0', 'Cadmium Fume (as Cd)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1306-19-0' and x.name = 'Cadmium Fume (as Cd)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1309-37-1', 'Iron Oxide Fume', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1309-37-1' and x.name = 'Iron Oxide Fume' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1309-37-1', 'Rouge (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1309-37-1' and x.name = 'Rouge (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1309-37-1', 'Rouge (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1309-37-1' and x.name = 'Rouge (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1309-48-4', 'Magnesium Oxide Fume (Total Particulate)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1309-48-4' and x.name = 'Magnesium Oxide Fume (Total Particulate)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1310-58-3', 'Potassium Hydroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1310-58-3' and x.name = 'Potassium Hydroxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1310-73-2', 'Sodium Hydroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1310-73-2' and x.name = 'Sodium Hydroxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-13-2', 'Zinc Oxide (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-13-2' and x.name = 'Zinc Oxide (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-13-2', 'Zinc Oxide (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-13-2' and x.name = 'Zinc Oxide (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-13-2', 'Zinc Oxide Fume', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-13-2' and x.name = 'Zinc Oxide Fume' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-20-1', 'Thorium Dioxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-20-1' and x.name = 'Thorium Dioxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-56-3', 'Phosphorus Pentoxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-56-3' and x.name = 'Phosphorus Pentoxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-62-1', 'Vanadium fume (as V2O5)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-62-1' and x.name = 'Vanadium fume (as V2O5)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-62-1', 'Vanadium, Respirable Dust (as V2O5)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-62-1' and x.name = 'Vanadium, Respirable Dust (as V2O5)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-62-1', 'Vanadium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-62-1' and x.name = 'Vanadium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-80-3', 'Phosphorus Pentasulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-80-3' and x.name = 'Phosphorus Pentasulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-35-7', 'Manganese Tetroxide (as Mn)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-35-7' and x.name = 'Manganese Tetroxide (as Mn)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-36-8', 'lead monoxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-36-8' and x.name = 'lead monoxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-65-3', 'Calcium Carbonate (Respirable Fraction), OSHA/NIOSH', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-65-3' and x.name = 'Calcium Carbonate (Respirable Fraction), OSHA/NIOSH' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-65-3', 'Calcium Carbonate (Total Dust), OSHA/NIOSH', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-65-3' and x.name = 'Calcium Carbonate (Total Dust), OSHA/NIOSH' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-65-3', 'Limestone (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-65-3' and x.name = 'Limestone (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-65-3', 'Limestone (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-65-3' and x.name = 'Limestone (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-65-3', 'Marble (Respirable Fraction), OSHA/NIOSH', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-65-3' and x.name = 'Marble (Respirable Fraction), OSHA/NIOSH' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-65-3', 'Marble (Total Dust), OSHA/NIOSH', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-65-3' and x.name = 'Marble (Total Dust), OSHA/NIOSH' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-95-9', 'Silica, Crystalline Tripoli (as Quartz), Respirable Dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-95-9' and x.name = 'Silica, Crystalline Tripoli (as Quartz), Respirable Dust' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1319-77-3', 'Cresol (All Isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1319-77-3' and x.name = 'Cresol (All Isomers)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1321-64-8', 'Pentachloronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1321-64-8' and x.name = 'Pentachloronaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1321-65-9', 'Trichloronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1321-65-9' and x.name = 'Trichloronaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1321-74-0', 'Divinyl Benzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1321-74-0' and x.name = 'Divinyl Benzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1321-94-4', 'Methyl Naphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1321-94-4' and x.name = 'Methyl Naphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1330-20-7', 'Xylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1330-20-7' and x.name = 'Xylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1332-21-4', 'Asbestos (Action Level, State of Oregon Only)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1332-21-4' and x.name = 'Asbestos (Action Level, State of Oregon Only)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1332-21-4', 'Asbestos (all forms)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1332-21-4' and x.name = 'Asbestos (all forms)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1332-29-2', 'Tin Oxide (as Sn) (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1332-29-2' and x.name = 'Tin Oxide (as Sn) (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1332-58-7', 'Kaolin (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1332-58-7' and x.name = 'Kaolin (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1332-58-7', 'Kaolin (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1332-58-7' and x.name = 'Kaolin (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1333-74-0', 'Hydrogen', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1333-74-0' and x.name = 'Hydrogen' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1333-82-0', 'chromium (VI) trioxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1333-82-0' and x.name = 'chromium (VI) trioxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1333-86-4', 'Carbon Black', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1333-86-4' and x.name = 'Carbon Black' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1335-87-1', 'Hexachloronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1335-87-1' and x.name = 'Hexachloronaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1335-88-2', 'Tetrachloronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1335-88-2' and x.name = 'Tetrachloronaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1338-23-4', 'Methyl Ethyl Ketone Peroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1338-23-4' and x.name = 'Methyl Ethyl Ketone Peroxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1344-28-1', 'alpha-Alumina (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1344-28-1' and x.name = 'alpha-Alumina (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1344-28-1', 'alpha-Alumina (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1344-28-1' and x.name = 'alpha-Alumina (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1344-38-3', 'basic lead chromate orange', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1344-38-3' and x.name = 'basic lead chromate orange' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1344-95-2', 'Calcium Silicate (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1344-95-2' and x.name = 'Calcium Silicate (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1344-95-2', 'Calcium Silicate (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1344-95-2' and x.name = 'Calcium Silicate (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1395-21-7', 'Subtilisins', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1395-21-7' and x.name = 'Subtilisins' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1401-55-4', 'Tannin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1401-55-4' and x.name = 'Tannin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1402-68-2', 'Aflatoxin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1402-68-2' and x.name = 'Aflatoxin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1477-55-0', 'm-Xylene-alpha,alpha''-diamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1477-55-0' and x.name = 'm-Xylene-alpha,alpha''-diamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1498-51-7', 'Ethyl dichlorophosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1498-51-7' and x.name = 'Ethyl dichlorophosphate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1499-10-1', '9,10-Diphenylanthracene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1499-10-1' and x.name = '9,10-Diphenylanthracene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1563-66-2', 'Carbofuran', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1563-66-2' and x.name = 'Carbofuran' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1569-02-4', '1-Ethoxy-2-propanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1569-02-4' and x.name = '1-Ethoxy-2-propanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1571-33-1', 'Benzenephosphonic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1571-33-1' and x.name = 'Benzenephosphonic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1582-09-8', 'Trifluralin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1582-09-8' and x.name = 'Trifluralin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1610-18-0', 'Pramitol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1610-18-0' and x.name = 'Pramitol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1634-04-4', 'tert-Butyl Methyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1634-04-4' and x.name = 'tert-Butyl Methyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1649-08-7', '1,2-Dichloro-1,1-Difluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1649-08-7' and x.name = '1,2-Dichloro-1,1-Difluoroethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1675-54-3', 'Diglycidyl Ether of Bisphenol A', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1675-54-3' and x.name = 'Diglycidyl Ether of Bisphenol A' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1704-62-7', 'Dimethylaminoethoxy ethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1704-62-7' and x.name = 'Dimethylaminoethoxy ethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1738-25-6', 'Dimethylaminopropionitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1738-25-6' and x.name = 'Dimethylaminopropionitrile' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1740-19-3', 'Dehydroabietic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1740-19-3' and x.name = 'Dehydroabietic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1746-01-6', '2,3,7,8-Tetrachlorodibenzo-p-Dioxin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1746-01-6' and x.name = '2,3,7,8-Tetrachlorodibenzo-p-Dioxin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1817-73-8', '2,4-Dinitro-6-Bromoaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1817-73-8' and x.name = '2,4-Dinitro-6-Bromoaniline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1825-21-4', 'Pentachloroanisole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1825-21-4' and x.name = 'Pentachloroanisole' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1861-32-1', 'Dimethyl 2,3,5,6-Tetrachloroterephthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1861-32-1' and x.name = 'Dimethyl 2,3,5,6-Tetrachloroterephthalate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1861-40-1', 'Benefin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1861-40-1' and x.name = 'Benefin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1897-45-6', 'Chlorothalonil', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1897-45-6' and x.name = 'Chlorothalonil' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1910-42-5', 'Paraquat dichloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1910-42-5' and x.name = 'Paraquat dichloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1912-24-9', 'Atrazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1912-24-9' and x.name = 'Atrazine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1918-00-9', 'Dicamba', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1918-00-9' and x.name = 'Dicamba' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1918-02-1', 'Picloram (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1918-02-1' and x.name = 'Picloram (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1918-02-1', 'Picloram (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1918-02-1' and x.name = 'Picloram (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1918-16-7', 'Ramrod', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1918-16-7' and x.name = 'Ramrod' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1929-82-4', '2-Chloro-6-(Trichloromethyl) Pyridine (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1929-82-4' and x.name = '2-Chloro-6-(Trichloromethyl) Pyridine (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1929-82-4', '2-Chloro-6-(Trichloromethyl) Pyridine (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1929-82-4' and x.name = '2-Chloro-6-(Trichloromethyl) Pyridine (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1937-37-7', 'Direct Black 38', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1937-37-7' and x.name = 'Direct Black 38' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1982-69-0', 'Dicamba, Sodium Salt', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1982-69-0' and x.name = 'Dicamba, Sodium Salt' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1983-10-4', 'Tributyltin Fluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1983-10-4' and x.name = 'Tributyltin Fluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2008-39-1', '2,4-D, Dimethylamine Salt', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2008-39-1' and x.name = '2,4-D, Dimethylamine Salt' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2039-87-4', 'o-Chlorostyrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2039-87-4' and x.name = 'o-Chlorostyrene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2074-50-2', 'Paraquat dimethyl sulfate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2074-50-2' and x.name = 'Paraquat dimethyl sulfate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2077-46-5', '2,3,6-Trichlorotoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2077-46-5' and x.name = '2,3,6-Trichlorotoluene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2104-64-5', 'EPN', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2104-64-5' and x.name = 'EPN' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2163-80-6', 'Monosodium Acid Methanearsonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2163-80-6' and x.name = 'Monosodium Acid Methanearsonate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2179-57-9', 'Diallyl Disulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2179-57-9' and x.name = 'Diallyl Disulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2179-59-1', 'Allyl Propyl Disulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2179-59-1' and x.name = 'Allyl Propyl Disulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2207-04-7', 'trans-1,4-Dimethylcyclohexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2207-04-7' and x.name = 'trans-1,4-Dimethylcyclohexane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2227-17-0', 'Pentac', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2227-17-0' and x.name = 'Pentac' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2234-13-1', 'Octachloronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2234-13-1' and x.name = 'Octachloronaphthalene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2238-07-5', 'Diglycidyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2238-07-5' and x.name = 'Diglycidyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2385-85-5', 'Mirex', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2385-85-5' and x.name = 'Mirex' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2399-48-6', 'tetrahydrofurfuryl acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2399-48-6' and x.name = 'tetrahydrofurfuryl acrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2421-28-5', 'Benzophenonetetracarboxylic Acid Dianhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2421-28-5' and x.name = 'Benzophenonetetracarboxylic Acid Dianhydride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2422-91-5', 'Triphenylmethane Triisocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2422-91-5' and x.name = 'Triphenylmethane Triisocyanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2425-06-1', 'Captafol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2425-06-1' and x.name = 'Captafol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2425-79-8', '1,4-Butanediol diglycidyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2425-79-8' and x.name = '1,4-Butanediol diglycidyl ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2426-08-6', 'n-Butyl Glycidyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2426-08-6' and x.name = 'n-Butyl Glycidyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2429-73-4', 'Direct Blue 2', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2429-73-4' and x.name = 'Direct Blue 2' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2429-81-4', 'Direct Brown 31', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2429-81-4' and x.name = 'Direct Brown 31' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2439-10-3', 'Dodine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2439-10-3' and x.name = 'Dodine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2451-62-9', '1,3,5-Triglycidyl Isocyanurate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2451-62-9' and x.name = '1,3,5-Triglycidyl Isocyanurate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2465-27-2', 'Aniline, 4,4'' - (imidocarbonyl) bis (N,N - dimethyl - , hydrochloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2465-27-2' and x.name = 'Aniline, 4,4'' - (imidocarbonyl) bis (N,N - dimethyl - , hydrochloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2524-04-1', 'Diethylphosphorochloridothioate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2524-04-1' and x.name = 'Diethylphosphorochloridothioate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2551-62-4', 'Sulfur Hexafluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2551-62-4' and x.name = 'Sulfur Hexafluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2568-91-4', 'Diisobutoxymethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2568-91-4' and x.name = 'Diisobutoxymethane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2602-46-2', 'Direct Blue 6', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2602-46-2' and x.name = 'Direct Blue 6' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2610-11-9', 'Direct Red 81', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2610-11-9' and x.name = 'Direct Red 81' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2642-71-9', 'Azinphos-Ethyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2642-71-9' and x.name = 'Azinphos-Ethyl' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2650-18-2', 'Acid Blue 9', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2650-18-2' and x.name = 'Acid Blue 9' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2675-77-6', 'Demosan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2675-77-6' and x.name = 'Demosan' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2682-20-4', '2-Methyl-4-Isothiazolin-3-one', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2682-20-4' and x.name = '2-Methyl-4-Isothiazolin-3-one' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2691-41-0', 'HMX', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2691-41-0' and x.name = 'HMX' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2698-41-1', 'o-Chlorobenzylidene Malononitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2698-41-1' and x.name = 'o-Chlorobenzylidene Malononitrile' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2699-79-8', 'Sulfuryl Fluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2699-79-8' and x.name = 'Sulfuryl Fluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2782-57-2', 'Dichloroisocyanuric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2782-57-2' and x.name = 'Dichloroisocyanuric Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2807-30-9', '2-Propoxyethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2807-30-9' and x.name = '2-Propoxyethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2825-82-3', 'Tetrahydrobicyclopentadiene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2825-82-3' and x.name = 'Tetrahydrobicyclopentadiene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2832-40-8', 'Disperse Yellow 3', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2832-40-8' and x.name = 'Disperse Yellow 3' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2855-13-2', 'Isophorone Diamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2855-13-2' and x.name = 'Isophorone Diamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2919-66-6', 'Melengestrol Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2919-66-6' and x.name = 'Melengestrol Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2921-88-2', 'Chlorpyrifos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2921-88-2' and x.name = 'Chlorpyrifos' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2971-90-6', 'Clopidol (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2971-90-6' and x.name = 'Clopidol (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2971-90-6', 'Clopidol (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2971-90-6' and x.name = 'Clopidol (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3030-47-5', 'Pentamethyldiethylenetriamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3030-47-5' and x.name = 'Pentamethyldiethylenetriamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3032-55-1', 'Trimethylolethane Trinitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3032-55-1' and x.name = 'Trimethylolethane Trinitrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3033-62-3', '2,2''-Oxybis-(N,N-Dimethylethylamine)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3033-62-3' and x.name = '2,2''-Oxybis-(N,N-Dimethylethylamine)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3068-88-0', 'beta-Butyrolactone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3068-88-0' and x.name = 'beta-Butyrolactone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3101-60-8', '4-tert-Butylphenyl glycidyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3101-60-8' and x.name = '4-tert-Butylphenyl glycidyl ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3173-72-6', '1,5-Naphthalene Diisocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3173-72-6' and x.name = '1,5-Naphthalene Diisocyanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3179-90-6', 'Disperse Blue 7', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3179-90-6' and x.name = 'Disperse Blue 7' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3268-87-9', '1,2,3,4,6,7,8,9-Octachlorodibenzodioxin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3268-87-9' and x.name = '1,2,3,4,6,7,8,9-Octachlorodibenzodioxin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3333-52-6', 'Tetramethyl Succinonitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3333-52-6' and x.name = 'Tetramethyl Succinonitrile' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3366-61-8', 'N-Acetylbenzidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3366-61-8' and x.name = 'N-Acetylbenzidine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3383-96-8', 'Temephos (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3383-96-8' and x.name = 'Temephos (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3383-96-8', 'Temephos (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3383-96-8' and x.name = 'Temephos (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3385-21-5', 'Diaminocyclohexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3385-21-5' and x.name = 'Diaminocyclohexane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3478-94-2', 'Pipron', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3478-94-2' and x.name = 'Pipron' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3524-68-3', 'Pentaerythritol Triacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3524-68-3' and x.name = 'Pentaerythritol Triacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3648-20-2', 'Diundecyl Phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3648-20-2' and x.name = 'Diundecyl Phthalate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3687-31-8', 'lead(II) arsenate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3687-31-8' and x.name = 'lead(II) arsenate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3689-24-5', 'TEDP', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3689-24-5' and x.name = 'TEDP' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3691-35-8', 'Rozol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3691-35-8' and x.name = 'Rozol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3734-33-6', 'Denatonium Benzoate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3734-33-6' and x.name = 'Denatonium Benzoate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3841-14-3', 'Direct Blue 1', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3841-14-3' and x.name = 'Direct Blue 1' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3855-32-1', 'N-[3-(Dimethylamino)propyl-N,N'',N''-trimethyl-1,3-Propanediami', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3855-32-1' and x.name = 'N-[3-(Dimethylamino)propyl-N,N'',N''-trimethyl-1,3-Propanediami' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4016-14-2', 'Isopropyl Glycidyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4016-14-2' and x.name = 'Isopropyl Glycidyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4035-89-6', 'Hexamethylene Diisocyanate Biuret', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4035-89-6' and x.name = 'Hexamethylene Diisocyanate Biuret' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4098-71-9', 'Isophorone Diisocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4098-71-9' and x.name = 'Isophorone Diisocyanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4110-50-3', 'Ethyl Propyl Sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4110-50-3' and x.name = 'Ethyl Propyl Sulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4164-28-7', 'N-Nitrodimethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4164-28-7' and x.name = 'N-Nitrodimethylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4342-36-3', 'Tributyltin Benzoate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4342-36-3' and x.name = 'Tributyltin Benzoate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4435-53-4', '3-Methoxy-n-butyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4435-53-4' and x.name = '3-Methoxy-n-butyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4549-44-4', 'N-Nitrosoethyl-n-butylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4549-44-4' and x.name = 'N-Nitrosoethyl-n-butylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4685-14-7', 'Paraquat, respirable dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4685-14-7' and x.name = 'Paraquat, respirable dust' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4719-04-4', 'Triazinetriethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4719-04-4' and x.name = 'Triazinetriethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4792-15-8', 'Pentaethylene glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4792-15-8' and x.name = 'Pentaethylene glycol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4994-16-5', '4-Phenylcyclohexene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4994-16-5' and x.name = '4-Phenylcyclohexene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5115-25-3', 'Difurfurylidene Pentaerythritol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5115-25-3' and x.name = 'Difurfurylidene Pentaerythritol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5124-30-1', 'Methylene-bis(4-Cyclohexylisocyanate)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5124-30-1' and x.name = 'Methylene-bis(4-Cyclohexylisocyanate)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5131-66-8', '1-Butoxy-2-propanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5131-66-8' and x.name = '1-Butoxy-2-propanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5160-02-1', 'Lake Red C', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5160-02-1' and x.name = 'Lake Red C' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5234-68-4', 'Carboxin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5234-68-4' and x.name = 'Carboxin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5329-14-6', 'Sulfamic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5329-14-6' and x.name = 'Sulfamic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5421-66-9', 'Bismark Brown', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5421-66-9' and x.name = 'Bismark Brown' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5522-43-0', '1-Nitropyrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5522-43-0' and x.name = '1-Nitropyrene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5534-09-8', 'Beclomethasone Dipropionate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5534-09-8' and x.name = 'Beclomethasone Dipropionate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5593-20-4', 'Betamethasone Dipropionate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5593-20-4' and x.name = 'Betamethasone Dipropionate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5714-22-7', 'Sulfur Pentafluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5714-22-7' and x.name = 'Sulfur Pentafluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5874-97-5', 'Alupent', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5874-97-5' and x.name = 'Alupent' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5989-27-5', 'd-Limonene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5989-27-5' and x.name = 'd-Limonene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6106-46-3', 'Scopolamine methyl nitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6106-46-3' and x.name = 'Scopolamine methyl nitrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6164-98-3', 'Chlordimeform', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6164-98-3' and x.name = 'Chlordimeform' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6211-15-0', 'Morphine sulfate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6211-15-0' and x.name = 'Morphine sulfate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6359-90-6', 'Acid Yellow 34', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6359-90-6' and x.name = 'Acid Yellow 34' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6375-55-9', 'Acid Yellow 42', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6375-55-9' and x.name = 'Acid Yellow 42' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6423-43-4', '1,2-Propylene Glycol Dinitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6423-43-4' and x.name = '1,2-Propylene Glycol Dinitrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6459-94-5', 'Acid Red 114', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6459-94-5' and x.name = 'Acid Red 114' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6484-52-2', 'Ammonium Nitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6484-52-2' and x.name = 'Ammonium Nitrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6533-73-9', 'thallium(I) carbonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6533-73-9' and x.name = 'thallium(I) carbonate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6627-34-5', '2,5-Dichloro-4-Nitroaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6627-34-5' and x.name = '2,5-Dichloro-4-Nitroaniline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6637-88-3', 'C.I. Direct Orange 6, disodium salt', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6637-88-3' and x.name = 'C.I. Direct Orange 6, disodium salt' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6656-03-7', 'Direct Blue 98', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6656-03-7' and x.name = 'Direct Blue 98' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6659-60-5', '1,2,4-Butanetriol, trinitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6659-60-5' and x.name = '1,2,4-Butanetriol, trinitrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6683-19-8', 'Tetrakis(methylene(3,5-di-t-butyl-4-hydroxyhydrocinnamte))methane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6683-19-8' and x.name = 'Tetrakis(methylene(3,5-di-t-butyl-4-hydroxyhydrocinnamte))methane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6795-23-9', 'Aflatoxin (M1)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6795-23-9' and x.name = 'Aflatoxin (M1)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6804-07-5', 'Carbadox', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6804-07-5' and x.name = 'Carbadox' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6834-92-0', 'Sodium Metasilicate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6834-92-0' and x.name = 'Sodium Metasilicate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6846-50-0', '2,2,4-Trimethyl-1,3-pentanediol diisobutyrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6846-50-0' and x.name = '2,2,4-Trimethyl-1,3-pentanediol diisobutyrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6885-57-0', 'Aflatoxin (M2)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6885-57-0' and x.name = 'Aflatoxin (M2)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6923-22-4', 'Monocrotophos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6923-22-4' and x.name = 'Monocrotophos' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7068-83-9', 'N-Nitrosomethyl-n-butylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7068-83-9' and x.name = 'N-Nitrosomethyl-n-butylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7085-85-0', 'Ethyl 2-Cyanoacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7085-85-0' and x.name = 'Ethyl 2-Cyanoacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7220-81-7', 'Aflatoxin (B2)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7220-81-7' and x.name = 'Aflatoxin (B2)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7241-98-7', 'Aflatoxin (G2)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7241-98-7' and x.name = 'Aflatoxin (G2)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7328-17-8', 'di(ethylene glycol)ethyl ether acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7328-17-8' and x.name = 'di(ethylene glycol)ethyl ether acrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7429-90-5', 'Aluminum (as Al), Alkyls', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7429-90-5' and x.name = 'Aluminum (as Al), Alkyls' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7429-90-5', 'Aluminum (as Al), Metal (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7429-90-5' and x.name = 'Aluminum (as Al), Metal (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7429-90-5', 'Aluminum (as Al), Metal (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7429-90-5' and x.name = 'Aluminum (as Al), Metal (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7429-90-5', 'Aluminum (as Al), Pyro Powder', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7429-90-5' and x.name = 'Aluminum (as Al), Pyro Powder' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7429-90-5', 'Aluminum (as Al), Soluble Salts', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7429-90-5' and x.name = 'Aluminum (as Al), Soluble Salts' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7429-90-5', 'Aluminum (as Al), Welding Fumes', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7429-90-5' and x.name = 'Aluminum (as Al), Welding Fumes' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-88-5', 'Iridium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-88-5' and x.name = 'Iridium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-89-6', 'Iron (Bulk)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-89-6' and x.name = 'Iron (Bulk)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-92-1', 'Lead, Inorganic (as Pb)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-92-1' and x.name = 'Lead, Inorganic (as Pb)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-93-2', 'Lithium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-93-2' and x.name = 'Lithium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-95-4', 'Magnesium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-95-4' and x.name = 'Magnesium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-96-5', 'Manganese Compounds (as Mn)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-96-5' and x.name = 'Manganese Compounds (as Mn)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-96-5', 'Manganese Fume (as Mn)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-96-5' and x.name = 'Manganese Fume (as Mn)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-97-6', 'Mercury (Aryl and Inorganic) (as Hg)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-97-6' and x.name = 'Mercury (Aryl and Inorganic) (as Hg)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-97-6', 'Mercury (Vapor) (as Hg)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-97-6' and x.name = 'Mercury (Vapor) (as Hg)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-98-7', 'Molybdenum (as Mo), Insoluble Compounds (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-98-7' and x.name = 'Molybdenum (as Mo), Insoluble Compounds (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-98-7', 'Molybdenum (as Mo), Soluble Compounds', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-98-7' and x.name = 'Molybdenum (as Mo), Soluble Compounds' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-00-8', 'Neodymium (as Nd)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-00-8' and x.name = 'Neodymium (as Nd)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-01-9', 'Neon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-01-9' and x.name = 'Neon' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-02-0', 'Nickel, Metal and Insoluble compounds (as Ni)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-02-0' and x.name = 'Nickel, Metal and Insoluble compounds (as Ni)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-02-0', 'Nickel, Soluble Compounds (as Ni)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-02-0' and x.name = 'Nickel, Soluble Compounds (as Ni)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-05-3', 'Palladium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-05-3' and x.name = 'Palladium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-06-4', 'Platinum (as Pt), metal', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-06-4' and x.name = 'Platinum (as Pt), metal' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-06-4', 'Platinum (as Pt), soluble salts', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-06-4' and x.name = 'Platinum (as Pt), soluble salts' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-16-6', 'Rhodium (as Rh), Metal Fume and Insoluble Compounds', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-16-6' and x.name = 'Rhodium (as Rh), Metal Fume and Insoluble Compounds' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-16-6', 'Rhodium (as Rh), Soluble Compounds', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-16-6' and x.name = 'Rhodium (as Rh), Soluble Compounds' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-17-7', 'Rubidium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-17-7' and x.name = 'Rubidium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-18-8', 'Ruthenium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-18-8' and x.name = 'Ruthenium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-21-3', 'Silicon (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-21-3' and x.name = 'Silicon (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-21-3', 'Silicon (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-21-3' and x.name = 'Silicon (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-22-4', 'Silver, Metal & Soluble Compounds (as Ag)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-22-4' and x.name = 'Silver, Metal & Soluble Compounds (as Ag)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-24-6', 'Strontium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-24-6' and x.name = 'Strontium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-25-7', 'Tantalum (metal, oxide dusts)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-25-7' and x.name = 'Tantalum (metal, oxide dusts)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-28-0', 'Thallium, soluble compounds (as Tl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-28-0' and x.name = 'Thallium, soluble compounds (as Tl)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-29-1', 'Thorium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-29-1' and x.name = 'Thorium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-31-5', 'Tin, inorganic compounds (except oxides) (as Sn)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-31-5' and x.name = 'Tin, inorganic compounds (except oxides) (as Sn)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-32-6', 'Titanium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-32-6' and x.name = 'Titanium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-33-7', 'Tungsten (as W) Insoluble Compounds', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-33-7' and x.name = 'Tungsten (as W) Insoluble Compounds' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-33-7', 'Tungsten (as W) Soluble Compounds', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-33-7' and x.name = 'Tungsten (as W) Soluble Compounds' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-36-0', 'Antimony & Compounds (as Sb)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-36-0' and x.name = 'Antimony & Compounds (as Sb)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-37-1', 'Argon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-37-1' and x.name = 'Argon' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-38-2', 'Arsenic, Inorganic', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-38-2' and x.name = 'Arsenic, Inorganic' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-38-2', 'Arsenic, Organic Compounds (as As)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-38-2' and x.name = 'Arsenic, Organic Compounds (as As)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-39-3', 'Barium (Insoluble Compounds)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-39-3' and x.name = 'Barium (Insoluble Compounds)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-39-3', 'Barium, Soluble Compounds (as Ba)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-39-3' and x.name = 'Barium, Soluble Compounds (as Ba)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-41-7', 'Beryllium and Beryllium Compounds (as Be)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-41-7' and x.name = 'Beryllium and Beryllium Compounds (as Be)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-42-8', 'Boron', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-42-8' and x.name = 'Boron' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-43-9', 'Cadmium Dust (as Cd)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-43-9' and x.name = 'Cadmium Dust (as Cd)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-43-9', 'Cadmium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-43-9' and x.name = 'Cadmium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-44-0', 'Carbon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-44-0' and x.name = 'Carbon' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-45-1', 'Cerium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-45-1' and x.name = 'Cerium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-47-3', 'chromium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-47-3' and x.name = 'chromium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-47-3', 'Chromium (II) Compounds (as Cr)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-47-3' and x.name = 'Chromium (II) Compounds (as Cr)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-47-3', 'Chromium (III) Compounds (as Cr)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-47-3' and x.name = 'Chromium (III) Compounds (as Cr)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-47-3', 'Chromium, Metal and Insoluble Salts', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-47-3' and x.name = 'Chromium, Metal and Insoluble Salts' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-47-3', 'Chromium, Soluble Chromic, Chromous Salts (as Cr)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-47-3' and x.name = 'Chromium, Soluble Chromic, Chromous Salts (as Cr)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-48-4', 'Cobalt, Metal, Dust & Fume (as Co)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-48-4' and x.name = 'Cobalt, Metal, Dust & Fume (as Co)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-50-8', 'Copper Dusts & Mists (as Cu)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-50-8' and x.name = 'Copper Dusts & Mists (as Cu)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-50-8', 'Copper Fume (as Cu)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-50-8' and x.name = 'Copper Fume (as Cu)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-55-3', 'Gallium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-55-3' and x.name = 'Gallium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-57-5', 'Gold', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-57-5' and x.name = 'Gold' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-58-6', 'Hafnium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-58-6' and x.name = 'Hafnium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-59-7', 'Helium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-59-7' and x.name = 'Helium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-61-1', 'Uranium (as U), Insoluble compounds', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-61-1' and x.name = 'Uranium (as U), Insoluble compounds' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-61-1', 'Uranium (as U), Soluble Compounds', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-61-1' and x.name = 'Uranium (as U), Soluble Compounds' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-65-5', 'Yttrium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-65-5' and x.name = 'Yttrium' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-66-6', 'Zinc', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-66-6' and x.name = 'Zinc' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-67-7', 'Zirconium Compounds (as Zr)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-67-7' and x.name = 'Zirconium Compounds (as Zr)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-69-6', 'Bismuth', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-69-6' and x.name = 'Bismuth' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-74-6', 'Indium & Compounds (as In)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-74-6' and x.name = 'Indium & Compounds (as In)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7446-09-5', 'Sulfur Dioxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7446-09-5' and x.name = 'Sulfur Dioxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7446-34-6', 'Selenium sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7446-34-6' and x.name = 'Selenium sulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7529-22-8', '4-Methyl Morpholine N-oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7529-22-8' and x.name = '4-Methyl Morpholine N-oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7553-56-2', 'Iodine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7553-56-2' and x.name = 'Iodine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7560-83-0', 'Methyl Dicyclohexylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7560-83-0' and x.name = 'Methyl Dicyclohexylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7572-29-4', 'Dichloroacetylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7572-29-4' and x.name = 'Dichloroacetylene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7580-67-8', 'Lithium Hydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7580-67-8' and x.name = 'Lithium Hydride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7601-90-3', 'Perchloric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7601-90-3' and x.name = 'Perchloric Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7616-94-6', 'Perchloryl Fluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7616-94-6' and x.name = 'Perchloryl Fluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7631-86-9', 'Silica, Amorphous', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7631-86-9' and x.name = 'Silica, Amorphous' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7631-90-5', 'Sodium Bisulfite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7631-90-5' and x.name = 'Sodium Bisulfite' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7631-99-4', 'Sodium Nitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7631-99-4' and x.name = 'Sodium Nitrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7632-00-0', 'Sodium Nitrite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7632-00-0' and x.name = 'Sodium Nitrite' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7632-10-2', 'Methamphetamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7632-10-2' and x.name = 'Methamphetamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7637-07-2', 'Boron Trifluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7637-07-2' and x.name = 'Boron Trifluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7645-25-2', 'lead arsenate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7645-25-2' and x.name = 'lead arsenate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7646-85-7', 'Zinc Chloride Fume', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7646-85-7' and x.name = 'Zinc Chloride Fume' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7647-01-0', 'Hydrogen Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7647-01-0' and x.name = 'Hydrogen Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7647-14-5', 'Sodium Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7647-14-5' and x.name = 'Sodium Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7664-38-2', 'Phosphoric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7664-38-2' and x.name = 'Phosphoric Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7664-39-3', 'Hydrogen Fluoride (as F)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7664-39-3' and x.name = 'Hydrogen Fluoride (as F)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7664-41-7', 'Ammonia', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7664-41-7' and x.name = 'Ammonia' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7664-93-9', 'Sulfuric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7664-93-9' and x.name = 'Sulfuric Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7665-72-2', 'tert-Butyl Glycidyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7665-72-2' and x.name = 'tert-Butyl Glycidyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7681-57-4', 'Sodium Metabisulfite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7681-57-4' and x.name = 'Sodium Metabisulfite' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7696-12-0', 'Tetramethrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7696-12-0' and x.name = 'Tetramethrin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7697-37-2', 'Nitric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7697-37-2' and x.name = 'Nitric Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7699-41-4', 'Silica, Gel', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7699-41-4' and x.name = 'Silica, Gel' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7699-45-8', 'Zinc Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7699-45-8' and x.name = 'Zinc Bromide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7704-34-9', 'Sulfur', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7704-34-9' and x.name = 'Sulfur' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7705-08-0', 'Ferric Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7705-08-0' and x.name = 'Ferric Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7719-09-7', 'Thionyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7719-09-7' and x.name = 'Thionyl Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7719-12-2', 'Phosphorus Trichloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7719-12-2' and x.name = 'Phosphorus Trichloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7722-84-1', 'Hydrogen Peroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7722-84-1' and x.name = 'Hydrogen Peroxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7722-88-5', 'Tetrasodium Pyrophosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7722-88-5' and x.name = 'Tetrasodium Pyrophosphate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7723-14-0', 'Phosphorus (yellow)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7723-14-0' and x.name = 'Phosphorus (yellow)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7726-95-6', 'Bromine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7726-95-6' and x.name = 'Bromine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7727-37-9', 'Nitrogen', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7727-37-9' and x.name = 'Nitrogen' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7727-43-7', 'Barium Sulfate (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7727-43-7' and x.name = 'Barium Sulfate (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7727-43-7', 'Barium Sulfate (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7727-43-7' and x.name = 'Barium Sulfate (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7758-29-4', 'Sodium Tripolyphosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7758-29-4' and x.name = 'Sodium Tripolyphosphate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7758-97-6', 'lead chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7758-97-6' and x.name = 'lead chromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7758-97-6', 'lead chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7758-97-6' and x.name = 'lead chromate' ); + +0 rows created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7773-06-0', 'Ammonium Sulfamate (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7773-06-0' and x.name = 'Ammonium Sulfamate (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7773-06-0', 'Ammonium Sulfamate (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7773-06-0' and x.name = 'Ammonium Sulfamate (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7775-11-3', 'sodium chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7775-11-3' and x.name = 'sodium chromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7775-14-6', 'Sodium Hydrosulfite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7775-14-6' and x.name = 'Sodium Hydrosulfite' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7775-27-1', 'Sodium Persulfate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7775-27-1' and x.name = 'Sodium Persulfate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7778-18-9', 'Calcium Sulfate (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7778-18-9' and x.name = 'Calcium Sulfate (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7778-18-9', 'Calcium Sulfate (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7778-18-9' and x.name = 'Calcium Sulfate (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7778-44-1', 'Calcium Arsenate (as As)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7778-44-1' and x.name = 'Calcium Arsenate (as As)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7778-50-9', 'potassium dichromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7778-50-9' and x.name = 'potassium dichromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7778-85-0', '1,2-Dimethoxypropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7778-85-0' and x.name = '1,2-Dimethoxypropane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-41-4', 'Fluorine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-41-4' and x.name = 'Fluorine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-42-5', 'Graphite, Synthetic (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-42-5' and x.name = 'Graphite, Synthetic (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-42-5', 'Graphite, Synthetic (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-42-5' and x.name = 'Graphite, Synthetic (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-42-5', 'Graphite, natural respirable dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-42-5' and x.name = 'Graphite, natural respirable dust' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-44-7', 'Oxygen', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-44-7' and x.name = 'Oxygen' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-49-2', 'Selenium Compounds (as Se)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-49-2' and x.name = 'Selenium Compounds (as Se)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-50-5', 'Chlorine (as Available Chlorine)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-50-5' and x.name = 'Chlorine (as Available Chlorine)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-50-5', 'Chlorine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-50-5' and x.name = 'Chlorine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-65-2', 'Germanium Tetrahydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-65-2' and x.name = 'Germanium Tetrahydride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-79-8', 'Hydrazoic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-79-8' and x.name = 'Hydrazoic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-06-4', 'Hydrogen Sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-06-4' and x.name = 'Hydrogen Sulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-07-5', 'Hydrogen Selenide (as Se)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-07-5' and x.name = 'Hydrogen Selenide (as Se)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-41-7', 'Oxygen Difluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-41-7' and x.name = 'Oxygen Difluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-54-2', 'Nitrogen Trifluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-54-2' and x.name = 'Nitrogen Trifluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-60-0', 'Sulfur Tetrafluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-60-0' and x.name = 'Sulfur Tetrafluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-61-1', 'Silicon Tetrafluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-61-1' and x.name = 'Silicon Tetrafluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-79-1', 'Selenium Hexafluoride (as Se)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-79-1' and x.name = 'Selenium Hexafluoride (as Se)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-80-4', 'Tellurium Hexafluoride (as Te)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-80-4' and x.name = 'Tellurium Hexafluoride (as Te)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7784-01-2', 'silver chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7784-01-2' and x.name = 'silver chromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7784-40-9', 'lead arsenate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7784-40-9' and x.name = 'lead arsenate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7784-42-1', 'Arsine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7784-42-1' and x.name = 'Arsine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7786-34-7', 'Phosdrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7786-34-7' and x.name = 'Phosdrin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-00-6', 'potassium chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-00-6' and x.name = 'potassium chromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-06-2', 'strontium chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-06-2' and x.name = 'strontium chromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-09-5', 'ammonium dichromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-09-5' and x.name = 'ammonium dichromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-12-0', 'sodium dichromate dehydrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-12-0' and x.name = 'sodium dichromate dehydrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-30-2', 'Bromine Pentafluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-30-2' and x.name = 'Bromine Pentafluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-38-0', 'Sodium Bromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-38-0' and x.name = 'Sodium Bromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-41-5', 'Calcium Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-41-5' and x.name = 'Calcium Bromide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-98-9', 'ammonium chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-98-9' and x.name = 'ammonium chromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7790-91-2', 'Chlorine Trifluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7790-91-2' and x.name = 'Chlorine Trifluoride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7803-49-8', 'Hydroxylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7803-49-8' and x.name = 'Hydroxylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7803-51-2', 'Phosphine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7803-51-2' and x.name = 'Phosphine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7803-52-3', 'Stibine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7803-52-3' and x.name = 'Stibine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7803-62-5', 'Silicon Tetrahydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7803-62-5' and x.name = 'Silicon Tetrahydride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8001-35-2', 'Chlorinated Camphene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8001-35-2' and x.name = 'Chlorinated Camphene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8001-58-9', 'Creosote', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8001-58-9' and x.name = 'Creosote' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8002-05-9', 'Petroleum Distillate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8002-05-9' and x.name = 'Petroleum Distillate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8002-74-2', 'Paraffin Wax Fume', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8002-74-2' and x.name = 'Paraffin Wax Fume' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8003-34-7', 'Pyrethrum', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8003-34-7' and x.name = 'Pyrethrum' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8004-13-5', 'Phenyl Ether-Biphenyl Mix (Vapor)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8004-13-5' and x.name = 'Phenyl Ether-Biphenyl Mix (Vapor)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8004-87-3', 'Methyl Violet', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8004-87-3' and x.name = 'Methyl Violet' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8006-61-9', 'Gasoline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8006-61-9' and x.name = 'Gasoline' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8006-64-2', 'Turpentine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8006-64-2' and x.name = 'Turpentine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8008-20-6', 'Kerosene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8008-20-6' and x.name = 'Kerosene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8012-95-1', 'Oil Mist, Mineral', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8012-95-1' and x.name = 'Oil Mist, Mineral' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8022-00-2', 'Methyl Demeton', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8022-00-2' and x.name = 'Methyl Demeton' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8030-30-6', 'Naphtha (Coal Tar)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8030-30-6' and x.name = 'Naphtha (Coal Tar)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8032-32-4', 'VM & P Naphtha', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8032-32-4' and x.name = 'VM & P Naphtha' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8049-47-6', 'Pancreatin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8049-47-6' and x.name = 'Pancreatin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8052-41-3', 'Stoddard Solvent', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8052-41-3' and x.name = 'Stoddard Solvent' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8052-42-4', 'Asphalt Fumes (Petroleum)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8052-42-4' and x.name = 'Asphalt Fumes (Petroleum)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8061-51-6', 'Sodium Ligninsulfonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8061-51-6' and x.name = 'Sodium Ligninsulfonate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8065-48-3', 'Demeton', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8065-48-3' and x.name = 'Demeton' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9001-00-7', 'Bromelain', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9001-00-7' and x.name = 'Bromelain' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9001-73-4', 'Papain', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9001-73-4' and x.name = 'Papain' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9001-92-7', 'Protease', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9001-92-7' and x.name = 'Protease' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9002-07-7', 'Trypsin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9002-07-7' and x.name = 'Trypsin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9002-84-0', 'Polytetrafluoroethylene Decomposition Products', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9002-84-0' and x.name = 'Polytetrafluoroethylene Decomposition Products' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9004-34-6', 'Cellulose (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9004-34-6' and x.name = 'Cellulose (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9004-34-6', 'Cellulose (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9004-34-6' and x.name = 'Cellulose (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9004-35-7', 'Cellulose Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9004-35-7' and x.name = 'Cellulose Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9004-57-3', 'Ethyl Cellulose', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9004-57-3' and x.name = 'Ethyl Cellulose' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9004-70-0', 'Nitrocellulose', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9004-70-0' and x.name = 'Nitrocellulose' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9005-25-8', 'Starch (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9005-25-8' and x.name = 'Starch (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9005-25-8', 'Starch (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9005-25-8' and x.name = 'Starch (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9016-45-9', 'Tergitol NP-33', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9016-45-9' and x.name = 'Tergitol NP-33' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9016-87-9', 'PAPI', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9016-87-9' and x.name = 'PAPI' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10024-97-2', 'Nitrous Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10024-97-2' and x.name = 'Nitrous Oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10025-67-9', 'Sulfur Monochloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10025-67-9' and x.name = 'Sulfur Monochloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10025-85-1', 'Nitrogen Trichloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10025-85-1' and x.name = 'Nitrogen Trichloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10025-87-3', 'Phosphorus Oxychloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10025-87-3' and x.name = 'Phosphorus Oxychloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10026-13-8', 'Phosphorus Pentachloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10026-13-8' and x.name = 'Phosphorus Pentachloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10028-15-6', 'Ozone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10028-15-6' and x.name = 'Ozone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10031-59-1', 'thallium sulfate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10031-59-1' and x.name = 'thallium sulfate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10035-10-6', 'Hydrogen Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10035-10-6' and x.name = 'Hydrogen Bromide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10043-35-3', 'Boric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10043-35-3' and x.name = 'Boric Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10049-04-4', 'Chlorine Dioxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10049-04-4' and x.name = 'Chlorine Dioxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10102-43-9', 'Nitric Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10102-43-9' and x.name = 'Nitric Oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10102-44-0', 'Nitrogen Dioxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10102-44-0' and x.name = 'Nitrogen Dioxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10127-27-2', 'Acid Orange 74', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10127-27-2' and x.name = 'Acid Orange 74' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10210-68-1', 'Cobalt Carbonyl (as Co)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10210-68-1' and x.name = 'Cobalt Carbonyl (as Co)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10265-92-6', 'Methamidophos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10265-92-6' and x.name = 'Methamidophos' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10294-33-4', 'Boron Tribromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10294-33-4' and x.name = 'Boron Tribromide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10294-40-3', 'barium chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10294-40-3' and x.name = 'barium chromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10311-84-9', 'Torak', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10311-84-9' and x.name = 'Torak' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10453-86-8', 'Resmethrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10453-86-8' and x.name = 'Resmethrin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10588-01-9', 'sodium dichromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10588-01-9' and x.name = 'sodium dichromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10595-95-6', 'N-Nitrosomethylethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10595-95-6' and x.name = 'N-Nitrosomethylethylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '11029-72-4', 'Holothurin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '11029-72-4' and x.name = 'Holothurin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '11096-82-5', 'Chlorodiphenyl (60% Cl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '11096-82-5' and x.name = 'Chlorodiphenyl (60% Cl)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '11097-69-1', 'Chlorodiphenyl (54% Cl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '11097-69-1' and x.name = 'Chlorodiphenyl (54% Cl)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '11104-28-2', 'Chlorodiphenyl (21% Cl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '11104-28-2' and x.name = 'Chlorodiphenyl (21% Cl)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12001-26-2', 'Mica', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12001-26-2' and x.name = 'Mica' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12035-72-2', 'Nickel subsulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12035-72-2' and x.name = 'Nickel subsulfide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12079-65-1', 'Manganese Cyclopentadienyl Tricarbonyl (as Mn)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12079-65-1' and x.name = 'Manganese Cyclopentadienyl Tricarbonyl (as Mn)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12108-13-3', 'Methylcyclopentadienyl Manganese Tricarbonyl (as Mn)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12108-13-3' and x.name = 'Methylcyclopentadienyl Manganese Tricarbonyl (as Mn)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12122-67-7', 'Zineb', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12122-67-7' and x.name = 'Zineb' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12125-02-9', 'Ammonium Chloride (Fume)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12125-02-9' and x.name = 'Ammonium Chloride (Fume)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12179-04-3', 'Borates, Tetra, Sodium Salts, Pentahydrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12179-04-3' and x.name = 'Borates, Tetra, Sodium Salts, Pentahydrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12407-86-2', 'Landrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12407-86-2' and x.name = 'Landrin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12415-34-8', 'Emery (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12415-34-8' and x.name = 'Emery (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12415-34-8', 'Emery (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12415-34-8' and x.name = 'Emery (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12427-38-2', 'Maneb', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12427-38-2' and x.name = 'Maneb' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12604-58-9', 'Ferrovanadium Dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12604-58-9' and x.name = 'Ferrovanadium Dust' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12656-85-8', 'molybdenum orange', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12656-85-8' and x.name = 'molybdenum orange' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12672-29-6', 'Chlorodiphenyl (48% Cl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12672-29-6' and x.name = 'Chlorodiphenyl (48% Cl)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12674-11-2', 'Chlorodiphenyl (1016)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12674-11-2' and x.name = 'Chlorodiphenyl (1016)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13048-33-4', '1,6-Hexanediol Diacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13048-33-4' and x.name = '1,6-Hexanediol Diacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13071-79-9', 'Terbufos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13071-79-9' and x.name = 'Terbufos' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13121-70-5', 'Cyhexatin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13121-70-5' and x.name = 'Cyhexatin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13194-48-4', 'MOCAP', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13194-48-4' and x.name = 'MOCAP' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13256-06-9', 'N-Nitrosodiamylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13256-06-9' and x.name = 'N-Nitrosodiamylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13389-42-9', 'trans-2-Octene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13389-42-9' and x.name = 'trans-2-Octene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13292-46-1', 'Rifampicin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13292-46-1' and x.name = 'Rifampicin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13397-24-5', 'Gypsum (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13397-24-5' and x.name = 'Gypsum (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13397-24-5', 'Gypsum (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13397-24-5' and x.name = 'Gypsum (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13463-39-3', 'Nickel Carbonyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13463-39-3' and x.name = 'Nickel Carbonyl' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13463-40-6', 'Iron Pentacarbonyl (as Fe)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13463-40-6' and x.name = 'Iron Pentacarbonyl (as Fe)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13463-67-7', 'Titanium Dioxide (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13463-67-7' and x.name = 'Titanium Dioxide (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13466-78-9', '3-Carene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13466-78-9' and x.name = '3-Carene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13494-80-9', 'Tellurium and compounds (as Te)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13494-80-9' and x.name = 'Tellurium and compounds (as Te)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13530-65-9', 'Zinc Chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13530-65-9' and x.name = 'Zinc Chromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13530-65-9', 'zinc chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13530-65-9' and x.name = 'zinc chromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13684-56-5', 'Desmedipham', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13684-56-5' and x.name = 'Desmedipham' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13684-63-4', 'Phenmedipham', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13684-63-4' and x.name = 'Phenmedipham' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13717-00-5', 'Magnesite (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13717-00-5' and x.name = 'Magnesite (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13717-00-5', 'Magnesite (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13717-00-5' and x.name = 'Magnesite (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13765-19-0', 'calcium chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13765-19-0' and x.name = 'calcium chromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13838-16-9', 'Enflurane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13838-16-9' and x.name = 'Enflurane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13983-17-0', 'Wollastonite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13983-17-0' and x.name = 'Wollastonite' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13991-37-2', 't-2-Pentenoic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13991-37-2' and x.name = 't-2-Pentenoic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14018-95-2', 'zinc chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14018-95-2' and x.name = 'zinc chromate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14464-46-1', 'Silica, Crystalline Cristobalite, Respirable Dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14464-46-1' and x.name = 'Silica, Crystalline Cristobalite, Respirable Dust' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14484-64-1', 'Ferbam, Total dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14484-64-1' and x.name = 'Ferbam, Total dust' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14807-96-6', 'Talc (Containing asbestos)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14807-96-6' and x.name = 'Talc (Containing asbestos)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14807-96-6', 'Talc (Containing no asbestos)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14807-96-6' and x.name = 'Talc (Containing no asbestos)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14808-60-7', 'Silica (Quartz, Total)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14808-60-7' and x.name = 'Silica (Quartz, Total)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14808-60-7', 'Silica, Crystalline Quartz, Respirable Dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14808-60-7' and x.name = 'Silica, Crystalline Quartz, Respirable Dust' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14850-23-8', 'trans-4-Octene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14850-23-8' and x.name = 'trans-4-Octene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14919-01-8', 'trans-3-Octene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14919-01-8' and x.name = 'trans-3-Octene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14986-48-2', 'chromium (VI) chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14986-48-2' and x.name = 'chromium (VI) chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '15442-64-5', 'Zinc Protoporphyrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '15442-64-5' and x.name = 'Zinc Protoporphyrin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '15468-32-3', 'Silica, Crystalline Tridymite, Respirable Dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '15468-32-3' and x.name = 'Silica, Crystalline Tridymite, Respirable Dust' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '15625-89-5', 'Trimethylolpropane Triacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '15625-89-5' and x.name = 'Trimethylolpropane Triacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '15972-60-8', 'Alachlor', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '15972-60-8' and x.name = 'Alachlor' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '16071-86-6', 'Direct Brown 95', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '16071-86-6' and x.name = 'Direct Brown 95' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '16219-75-3', 'Ethylidene Norbornene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '16219-75-3' and x.name = 'Ethylidene Norbornene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '16752-77-5', 'Methomyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '16752-77-5' and x.name = 'Methomyl' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '16842-03-8', 'Cobalt Hydrocarbonyl (as Co)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '16842-03-8' and x.name = 'Cobalt Hydrocarbonyl (as Co)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '16872-11-0', 'Fluoboric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '16872-11-0' and x.name = 'Fluoboric Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '16984-48-8', 'Fluorides (as F)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '16984-48-8' and x.name = 'Fluorides (as F)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '17090-79-8', 'Monensin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '17090-79-8' and x.name = 'Monensin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '17702-41-9', 'Decaborane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '17702-41-9' and x.name = 'Decaborane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '17804-35-2', 'Benomyl (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '17804-35-2' and x.name = 'Benomyl (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '17804-35-2', 'Benomyl (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '17804-35-2' and x.name = 'Benomyl (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '17831-71-9', 'Tetraethylene Glycol Diacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '17831-71-9' and x.name = 'Tetraethylene Glycol Diacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '17924-92-4', 'Zearalenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '17924-92-4' and x.name = 'Zearalenone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '18282-10-5', 'Stannic Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '18282-10-5' and x.name = 'Stannic Oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '18454-12-1', 'lead chromate oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '18454-12-1' and x.name = 'lead chromate oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '18454-12-1', 'lead chromate oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '18454-12-1' and x.name = 'lead chromate oxide' ); + +0 rows created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '18540-29-9', 'chromium (VI) ion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '18540-29-9' and x.name = 'chromium (VI) ion' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '18883-66-4', 'Streptozotocin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '18883-66-4' and x.name = 'Streptozotocin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '19044-88-3', 'Oryzalin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '19044-88-3' and x.name = 'Oryzalin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '19287-45-7', 'Diborane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '19287-45-7' and x.name = 'Diborane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '19408-84-5', 'Dihydrocapsaicin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '19408-84-5' and x.name = 'Dihydrocapsaicin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '19624-22-7', 'Pentaborane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '19624-22-7' and x.name = 'Pentaborane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '20619-16-3', 'Germanium Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '20619-16-3' and x.name = 'Germanium Oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '20816-12-0', 'Osmium Tetroxide (as Os)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '20816-12-0' and x.name = 'Osmium Tetroxide (as Os)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '20830-81-3', 'Daunamycin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '20830-81-3' and x.name = 'Daunamycin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '21087-64-9', 'Metribuzin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '21087-64-9' and x.name = 'Metribuzin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '21351-79-1', 'Cesium Hydroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '21351-79-1' and x.name = 'Cesium Hydroxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '21609-90-5', 'Phosvel', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '21609-90-5' and x.name = 'Phosvel' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '21651-19-4', 'Stannous Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '21651-19-4' and x.name = 'Stannous Oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '21725-46-2', 'Bladex', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '21725-46-2' and x.name = 'Bladex' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '22224-92-6', 'Fenamiphos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '22224-92-6' and x.name = 'Fenamiphos' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '22781-23-3', 'Ficam', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '22781-23-3' and x.name = 'Ficam' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '22839-47-0', 'Aspartame', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '22839-47-0' and x.name = 'Aspartame' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '23103-98-2', 'Pirimicarb', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '23103-98-2' and x.name = 'Pirimicarb' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '23135-22-0', 'Vydate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '23135-22-0' and x.name = 'Vydate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '23184-66-9', 'Machette', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '23184-66-9' and x.name = 'Machette' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '23564-05-8', 'Thiophanate-methyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '23564-05-8' and x.name = 'Thiophanate-methyl' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '23564-06-9', 'Thiophanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '23564-06-9' and x.name = 'Thiophanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '23950-58-5', 'Kerb', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '23950-58-5' and x.name = 'Kerb' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25013-15-4', 'Vinyl Toluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25013-15-4' and x.name = 'Vinyl Toluene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25134-21-8', 'Nadic methyl anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25134-21-8' and x.name = 'Nadic methyl anhydride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25154-52-3', 'Nonylphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25154-52-3' and x.name = 'Nonylphenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25154-54-5', 'Dinitrobenzene (All Isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25154-54-5' and x.name = 'Dinitrobenzene (All Isomers)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25157-70-8', '2,4,4-Trimethyl Pentene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25157-70-8' and x.name = '2,4,4-Trimethyl Pentene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25167-67-3', 'Butene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25167-67-3' and x.name = 'Butene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25167-82-2', 'Trichlorophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25167-82-2' and x.name = 'Trichlorophenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25167-83-3', 'Tetrachlorophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25167-83-3' and x.name = 'Tetrachlorophenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25168-26-7', '2,4-D, Isooctyl Ester', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25168-26-7' and x.name = '2,4-D, Isooctyl Ester' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25265-77-4', '2,2,4-Trimethyl-1,3-pentanediol monoisobutyrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25265-77-4' and x.name = '2,2,4-Trimethyl-1,3-pentanediol monoisobutyrate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25311-71-1', 'Isofenphos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25311-71-1' and x.name = 'Isofenphos' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25321-14-6', 'Dinitrotoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25321-14-6' and x.name = 'Dinitrotoluene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25340-18-5', 'Triethylbenzenes', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25340-18-5' and x.name = 'Triethylbenzenes' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25377-73-5', 'Dodecenylsuccinic anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25377-73-5' and x.name = 'Dodecenylsuccinic anhydride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25413-64-3', 'N-Nitroso-N-propyl-n-butylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25413-64-3' and x.name = 'N-Nitroso-N-propyl-n-butylamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25495-88-9', 'Methylhexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25495-88-9' and x.name = 'Methylhexane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25550-58-7', 'Dinitrophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25550-58-7' and x.name = 'Dinitrophenol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25551-13-7', 'Trimethylbenzene (mixed isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25551-13-7' and x.name = 'Trimethylbenzene (mixed isomers)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25639-42-3', 'Methylcyclohexanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25639-42-3' and x.name = 'Methylcyclohexanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '26172-55-4', '5-Chloro-2-Methyl-4-Isothiazolin-3-One', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '26172-55-4' and x.name = '5-Chloro-2-Methyl-4-Isothiazolin-3-One' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '26499-65-0', 'Plaster of Paris (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '26499-65-0' and x.name = 'Plaster of Paris (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '26499-65-0', 'Plaster of Paris (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '26499-65-0' and x.name = 'Plaster of Paris (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '26628-22-8', 'Sodium Azide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '26628-22-8' and x.name = 'Sodium Azide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '26635-64-3', 'Isooctane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '26635-64-3' and x.name = 'Isooctane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '26675-46-7', 'Isoflurane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '26675-46-7' and x.name = 'Isoflurane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '26952-21-6', 'Isooctyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '26952-21-6' and x.name = 'Isooctyl Alcohol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '27176-87-0', 'Dodecyl Benzenesulfonic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '27176-87-0' and x.name = 'Dodecyl Benzenesulfonic Acid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28106-30-1', 'Ethyl Vinyl Benzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28106-30-1' and x.name = 'Ethyl Vinyl Benzene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28178-42-9', '2,6-Diisopropylphenyl isocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28178-42-9' and x.name = '2,6-Diisopropylphenyl isocyanate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28182-81-2', '1,6-Hexamethylene Diisocyanate Homopolymer', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28182-81-2' and x.name = '1,6-Hexamethylene Diisocyanate Homopolymer' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28351-09-9', 'Dimethylbenzaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28351-09-9' and x.name = 'Dimethylbenzaldehyde' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28523-86-6', 'Sevoflurane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28523-86-6' and x.name = 'Sevoflurane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28553-12-0', 'Diisononyl Phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28553-12-0' and x.name = 'Diisononyl Phthalate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28768-32-3', '4,4''-Methylenebis (N,N-diglycidylaniline)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28768-32-3' and x.name = '4,4''-Methylenebis (N,N-diglycidylaniline)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28777-67-5', 'Dimethylhexane (all isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28777-67-5' and x.name = 'Dimethylhexane (all isomers)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '29191-52-4', 'Anisidine (o,p-Isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '29191-52-4' and x.name = 'Anisidine (o,p-Isomers)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '29232-93-7', 'Pirimiphos Methyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '29232-93-7' and x.name = 'Pirimiphos Methyl' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '29590-42-9', 'Isooctyl Acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '29590-42-9' and x.name = 'Isooctyl Acrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '29911-28-2', 'dipropylene glycol mono-n-butyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '29911-28-2' and x.name = 'dipropylene glycol mono-n-butyl ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '30136-13-1', 'n-Propoxypropanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '30136-13-1' and x.name = 'n-Propoxypropanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '30560-19-1', 'Orthene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '30560-19-1' and x.name = 'Orthene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '31017-40-0', '1-Phenyl-1-Cyclohexene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '31017-40-0' and x.name = '1-Phenyl-1-Cyclohexene' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '31218-83-4', 'Safrotin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '31218-83-4' and x.name = 'Safrotin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '32536-52-0', 'Octabromodiphenyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '32536-52-0' and x.name = 'Octabromodiphenyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '34464-38-5', 'Isodecane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '34464-38-5' and x.name = 'Isodecane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '34590-94-8', 'Dipropylene Glycol Methyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '34590-94-8' and x.name = 'Dipropylene Glycol Methyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '34803-66-2', '1-(2-Pyridyl)piperazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '34803-66-2' and x.name = '1-(2-Pyridyl)piperazine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '35400-43-2', 'Sulprofos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '35400-43-2' and x.name = 'Sulprofos' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '36791-04-5', 'Ribavirin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '36791-04-5' and x.name = 'Ribavirin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '37293-45-1', 'Acid Black 128', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '37293-45-1' and x.name = 'Acid Black 128' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '37324-23-5', 'Chlorodiphenyl (62% Cl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '37324-23-5' and x.name = 'Chlorodiphenyl (62% Cl)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '38641-94-0', 'Glyphosate isopropylamine salt', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '38641-94-0' and x.name = 'Glyphosate isopropylamine salt' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '38721-71-0', 'Dichlorobenzyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '38721-71-0' and x.name = 'Dichlorobenzyl Chloride' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '40487-42-1', 'Pendimethalin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '40487-42-1' and x.name = 'Pendimethalin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '42978-66-5', 'Tripropylene Glycol Diacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '42978-66-5' and x.name = 'Tripropylene Glycol Diacrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '48145-04-6', '2-Phenoxyethyl acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '48145-04-6' and x.name = '2-Phenoxyethyl acrylate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '51207-31-9', '2,3,7,8-Tetrachlorodibenzofuran', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '51207-31-9' and x.name = '2,3,7,8-Tetrachlorodibenzofuran' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '51218-45-2', 'Metolachlor', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '51218-45-2' and x.name = 'Metolachlor' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '51235-04-2', 'Hexazinone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '51235-04-2' and x.name = 'Hexazinone' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '52315-07-8', 'Cypermethrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '52315-07-8' and x.name = 'Cypermethrin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '52645-53-1', 'Permethrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '52645-53-1' and x.name = 'Permethrin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '53404-18-5', 'Potassium p-tert-amylphenate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '53404-18-5' and x.name = 'Potassium p-tert-amylphenate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '53469-21-9', 'Chlorodiphenyl (42% Cl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '53469-21-9' and x.name = 'Chlorodiphenyl (42% Cl)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '53609-64-6', 'N-Nitrosodiisopropanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '53609-64-6' and x.name = 'N-Nitrosodiisopropanolamine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '54446-78-5', '1-(2-Butoxyethoxy)ethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '54446-78-5' and x.name = '1-(2-Butoxyethoxy)ethanol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '55107-14-7', 'Methyl pivaloylacetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '55107-14-7' and x.name = 'Methyl pivaloylacetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '55406-53-6', 'Iodopropanyl Butyl Carbamate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '55406-53-6' and x.name = 'Iodopropanyl Butyl Carbamate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '55720-99-5', 'Chlorinated Diphenyl Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '55720-99-5' and x.name = 'Chlorinated Diphenyl Oxide' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57041-67-5', 'Desflurane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57041-67-5' and x.name = 'Desflurane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57837-19-1', 'Apron', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57837-19-1' and x.name = 'Apron' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '59355-75-8', 'Methyl Acetylene-Propadiene Mixture', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '59355-75-8' and x.name = 'Methyl Acetylene-Propadiene Mixture' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60168-88-9', 'Fenarimol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60168-88-9' and x.name = 'Fenarimol' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60676-86-0', 'Silica, Fused (Respirable Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60676-86-0' and x.name = 'Silica, Fused (Respirable Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '61788-32-7', 'Hydrogenated Terphenyls', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '61788-32-7' and x.name = 'Hydrogenated Terphenyls' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '61790-53-2', 'Silica, Amorphous, Diatomaceous Earth (<1% Crystalline Silica)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '61790-53-2' and x.name = 'Silica, Amorphous, Diatomaceous Earth (<1% Crystalline Silica)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '63428-83-1', 'Nylon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '63428-83-1' and x.name = 'Nylon' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '64265-57-2', 'Polyfunctional Aziridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '64265-57-2' and x.name = 'Polyfunctional Aziridine' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '65996-93-2', 'Coal Tar Pitch Volatiles (benzene soluble fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '65996-93-2' and x.name = 'Coal Tar Pitch Volatiles (benzene soluble fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '65997-15-1', 'Portland Cement (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '65997-15-1' and x.name = 'Portland Cement (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '65997-15-1', 'Portland Cement (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '65997-15-1' and x.name = 'Portland Cement (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '65997-17-3', 'Fibrous Glass', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '65997-17-3' and x.name = 'Fibrous Glass' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '67485-29-4', 'Hydramethylnon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '67485-29-4' and x.name = 'Hydramethylnon' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68131-74-8', 'Coal Dust (<5% Si02, Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68131-74-8' and x.name = 'Coal Dust (<5% Si02, Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68334-30-5', 'Diesel Fuel', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68334-30-5' and x.name = 'Diesel Fuel' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68359-37-5', 'Baythroid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68359-37-5' and x.name = 'Baythroid' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68476-85-7', 'L.P.G.', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68476-85-7' and x.name = 'L.P.G.' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68515-50-4', 'Dihexyl phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68515-50-4' and x.name = 'Dihexyl phthalate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68937-41-7', 'Triisopropylated Phenyl Phosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68937-41-7' and x.name = 'Triisopropylated Phenyl Phosphate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68956-68-3', 'Vegetable Oil Mist (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68956-68-3' and x.name = 'Vegetable Oil Mist (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68956-68-3', 'Vegetable Oil Mist (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68956-68-3' and x.name = 'Vegetable Oil Mist (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '69409-94-5', 'Mavrik', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '69409-94-5' and x.name = 'Mavrik' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '70657-70-4', '2-Methoxy-1-Propyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '70657-70-4' and x.name = '2-Methoxy-1-Propyl Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '71751-41-2', 'Abamectin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '71751-41-2' and x.name = 'Abamectin' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '72490-01-8', 'Fenoxycarb', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '72490-01-8' and x.name = 'Fenoxycarb' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '81777-89-1', 'Command', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '81777-89-1' and x.name = 'Command' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '83919-23-7', 'Mometasone Furoate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '83919-23-7' and x.name = 'Mometasone Furoate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88230-35-7', 'Acetic Acid, Hexyl Esters Mixture', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88230-35-7' and x.name = 'Acetic Acid, Hexyl Esters Mixture' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88917-22-0', 'Dipropylene Glycol Methyl Ether Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88917-22-0' and x.name = 'Dipropylene Glycol Methyl Ether Acetate' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93763-70-3', 'Perlite (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93763-70-3' and x.name = 'Perlite (Respirable Fraction)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93763-70-3', 'Perlite (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93763-70-3' and x.name = 'Perlite (Total Dust)' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112926-00-8', 'Precipitated silica; silica gel', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112926-00-8' and x.name = 'Precipitated silica; silica gel' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '138495-42-8', '1,1,1,2,3,4,4,5,5,5-Decafluoropentane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '138495-42-8' and x.name = '1,1,1,2,3,4,4,5,5,5-Decafluoropentane' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '163702-05-4', 'Ethyl Perfluorobutyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '163702-05-4' and x.name = 'Ethyl Perfluorobutyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '163702-06-5', 'Ethyl Perfluoroisobutyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '163702-06-5' and x.name = 'Ethyl Perfluoroisobutyl Ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '163702-07-8', 'Perfluoro-n-butyl methyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '163702-07-8' and x.name = 'Perfluoro-n-butyl methyl ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '163702-08-7', 'Perfluoroisobutyl methyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '163702-08-7' and x.name = 'Perfluoroisobutyl methyl ether' ); + +1 row created. + +SQL> insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '308068-21-5', 'Marble (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '308068-21-5' and x.name = 'Marble (Total Dust)' ); + +1 row created. + +SQL> commit; + +Commit complete. + +SQL> +SQL> set define on; +SQL> +SQL> analyze table SUBSTANCE_T estimate statistics; + +Table analyzed. + +SQL> @worker_type_t.ins +SQL> rem worker_type_t.ins +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem +SQL> +SQL> insert into WORKER_TYPE_T ( + 2 id, + 3 code, + 4 description ) + 5 values ( + 6 WORKER_TYPE_ID_SEQ.nextval, + 7 'C', + 8 'Contractor' ); + +1 row created. + +SQL> +SQL> insert into WORKER_TYPE_T ( + 2 id, + 3 code, + 4 description ) + 5 values ( + 6 WORKER_TYPE_ID_SEQ.nextval, + 7 'E', + 8 'Employee' ); + +1 row created. + +SQL> +SQL> insert into WORKER_TYPE_T ( + 2 id, + 3 code, + 4 description ) + 5 values ( + 6 WORKER_TYPE_ID_SEQ.nextval, + 7 'U', + 8 'Unknown' ); + +1 row created. + +SQL> +SQL> commit; + +Commit complete. + +SQL> @workplace_type_t.ins +SQL> rem workplace_type_t.ins +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Add workplace type code values +SQL> +SQL> insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'Y', 'N', 'B', 'Business Unit' ); + +1 row created. + +SQL> insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'Y', 'N', 'C', 'Company' ); + +1 row created. + +SQL> insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'Y', 'N', 'D', 'Department' ); + +1 row created. + +SQL> insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'N', 'Y', 'L', 'Line' ); + +1 row created. + +SQL> insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'N', 'Y', 'M', 'Machine' ); + +1 row created. + +SQL> insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'N', 'Y', 'S', 'Site' ); + +1 row created. + +SQL> insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'Y', 'Y', 'U', 'Unknown' ); + +1 row created. + +SQL> commit; + +Commit complete. + +SQL> +SQL> analyze table WORKPLACE_TYPE_T estimate statistics; + +Table analyzed. + +SQL> +SQL> -- package specs +SQL> @dates.pks +SQL> create or replace package DATES as + 2 /* + 3 dates.pks + 4 by Donald J. Bales on 12/15/2006 + 5 Additional DATE data type methods. + 6 */ + 7 + 8 -- The maximum and minimum dates values. + 9 + 10 d_MAX constant date := + 11 to_date('99991231235959', 'YYYYMMDDHH24MISS'); + 12 d_MIN constant date := + 13 to_date('-47120101', 'SYYYYMMDD'); + 14 + 15 + 16 -- Returns the specified date with the time set to 23:59:59, therefore, + 17 -- the end of the day. + 18 + 19 FUNCTION end_of_day( + 20 aid_date in date ) + 21 return date; + 22 + 23 + 24 -- Returns constant d_MAX. This is useful in SQL statements where the + 25 -- constant DATES.d_MAX is not accessible. + 26 + 27 FUNCTION get_max + 28 return date; + 29 + 30 + 31 -- Returns constant d_MIN. This is useful in SQL statements where the + 32 -- constant DATES.d_MIN is not accessible. + 33 + 34 FUNCTION get_min + 35 return date; + 36 + 37 + 38 -- Text-based help for this package. "set serveroutput on" in SQL*Plus. + 39 + 40 PROCEDURE help; + 41 + 42 + 43 -- Returns a randomly generated date that exists between the years specified. + 44 + 45 FUNCTION random( + 46 ain_starting_year in number, + 47 ain_ending_year in number ) + 48 return date; + 49 + 50 + 51 -- Returns the specified date with the time set to 00:00:00, therefore, the + 52 -- start of the day. + 53 + 54 FUNCTION start_of_day( + 55 aid_date in date ) + 56 return date; + 57 + 58 + 59 -- Test unit for this package. + 60 + 61 PROCEDURE test; + 62 + 63 + 64 end DATES; + 65 / + +Package created. + +SQL> @se.sql DATES +SQL> show errors +No errors. +SQL> @workplace_type_ts.pks +SQL> create or replace PACKAGE WORKPLACE_TYPE_TS as + 2 /* + 3 workplace_type_ts.pks + 4 by Donald J. Bales on 12/15/2006 + 5 Table WORKPLACE_TYPE_T's methods. + 6 */ + 7 + 8 /* + 9 Gets the code and decription values for the specified id. + 10 */ + 11 PROCEDURE get_code_descr( + 12 ain_id in WORKPLACE_TYPE_T.id%TYPE, + 13 aov_code out WORKPLACE_TYPE_T.code%TYPE, + 14 aov_description out WORKPLACE_TYPE_T.description%TYPE); + 15 + 16 /* + 17 Verifies that the passed code value is an exact or like match on the date specified. + 18 */ + 19 PROCEDURE get_code_id_descr( + 20 aiov_code in out WORKPLACE_TYPE_T.code%TYPE, + 21 aon_id out WORKPLACE_TYPE_T.id%TYPE, + 22 aov_description out WORKPLACE_TYPE_T.description%TYPE, + 23 aid_on in WORKPLACE_TYPE_T.active_date%TYPE); + 24 + 25 /* + 26 Verifies that the passed code value is currently an exact or like match. + 27 */ + 28 PROCEDURE get_code_id_descr( + 29 aiov_code in out WORKPLACE_TYPE_T.code%TYPE, + 30 aon_id out WORKPLACE_TYPE_T.id%TYPE, + 31 aov_description out WORKPLACE_TYPE_T.description%TYPE); + 32 + 33 /* + 34 Returns a new primary key id value for a row. + 35 */ + 36 FUNCTION get_id + 37 return WORKPLACE_TYPE_T.id%TYPE; + 38 + 39 /* + 40 Returns the id for the specified code value. + 41 */ + 42 FUNCTION get_id( + 43 aiv_code in WORKPLACE_TYPE_T.code%TYPE) + 44 return WORKPLACE_TYPE_T.id%TYPE; + 45 + 46 /* + 47 Test-based help for this package. "set serveroutput on" in SQL*Plus. + 48 */ + 49 PROCEDURE help; + 50 + 51 /* + 52 Test units for this package. + 53 */ + 54 PROCEDURE test; + 55 + 56 + 57 end WORKPLACE_TYPE_TS; + 58 / + +Package created. + +SQL> @se.sql WORKPLACE_TYPE_TS +SQL> show errors +No errors. +SQL> @logical_workplace_ts.pks +SQL> create or replace PACKAGE LOGICAL_WORKPLACE_TS as + 2 /* + 3 logical_workplace_ts.pks
+ 4 by Donald J. Bales on 12/15/2006
+ 5 Table LOGICAL_WORKPLACE_T's methods. Contains all the supporting service + 6 methods (functions and procedures) for table LOGICAL_WORKPLACE_T. + 7 */ + 8 + 9 -- GLOBAL VARIABLES + 10 + 11 -- Keep track of the number of inserts and updates to made by set_row( ). + 12 n_inserted number := 0; + 13 n_updated number := 0; + 14 + 15 + 16 /* + 17 Returns an id_context for the specified parent_id and id. + 18 Whatever creates a new row must also call this mehtod to create an appropriate + 19 id_context value. Method set_row( ) does this for you. + 20 */ + 21 FUNCTION create_id_context( + 22 ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, + 23 ain_id in LOGICAL_WORKPLACE_T.id%TYPE) + 24 return varchar2; + 25 + 26 + 27 /* + 28 Returns a new primary key id value for a row. + 29 */ + 30 FUNCTION get_id + 31 return LOGICAL_WORKPLACE_T.id%TYPE; + 32 + 33 + 34 /* + 35 Returns the value of a context for the code values in the logical workplace assignment. + 36 */ + 37 FUNCTION get_code_context( + 38 ain_id in LOGICAL_WORKPLACE_T.id%TYPE) + 39 return varchar2; + 40 + 41 + 42 /* + 43 Returns the value of a context for the name values in the logical workplace assignment. + 44 */ + 45 FUNCTION get_name_context( + 46 ain_id in LOGICAL_WORKPLACE_T.id%TYPE) + 47 return varchar2; + 48 + 49 + 50 /* + 51 Returns a LOGICAL_WORKPLACE row for the specified criteria. + 52 + 53 There are three sets of criteria. You can retrieve a row by specifying:
+ 54 1. the primary key: id
+ 55 2. the unique id_context
+ 56 3. the code, name, and active_date
+ 57 + 58 If a match is found the function returns the corresponding row, otherwise + 59 it returns NULL. It will raise any exceptions except NO_DATA_FOUND. + 60 */ + 61 FUNCTION get_row( + 62 air_logical_workplace in LOGICAL_WORKPLACE_T%ROWTYPE) + 63 return LOGICAL_WORKPLACE_T%ROWTYPE; + 64 + 65 + 66 /* + 67 Test-based help for this package. "set serveroutput on" in SQL*Plus. + 68 */ + 69 PROCEDURE help; + 70 + 71 + 72 /* + 73 Updates or inserts a row matching the passed parameters into table LOGICAL_WORKPLACE_T. + 74 See PROCEDURE set_row( ). + 75 */ + 76 FUNCTION set_row( + 77 ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, + 78 ain_workplace_type_id in LOGICAL_WORKPLACE_T.workplace_type_id%TYPE, + 79 aiv_code in LOGICAL_WORKPLACE_T.code%TYPE, + 80 aiv_name in LOGICAL_WORKPLACE_T.name%TYPE, + 81 aid_active_date in LOGICAL_WORKPLACE_T.active_date%TYPE) + 82 return LOGICAL_WORKPLACE_T.id%TYPE; + 83 + 84 + 85 /* + 86 Updates or inserts a row matching the passed row into table LOGICAL_WORKPLACE_T. + 87 + 88 First, set_row() calls get row to try to find a matching row that already + 89 exists in the database. So you need to set the id, id_context, + 90 and code, name and active_date appropriately in order to prperly detect an + 91 existing row. + 92 + 93 Next, if an existing row is found, any non-key data items are updated to match + 94 the passed row. Otherwise, and new row is inserted, including the allocation of + 95 a new primary key and id_context value. Upon inserting a new value, the + 96 id and id_context values are updated in the passed row. + 97 See PROCEDURE get_row( ); + 98 */ + 99 PROCEDURE set_row( +100 aior_logical_workplace in out LOGICAL_WORKPLACE_T%ROWTYPE); +101 +102 +103 /* +104 Performs unit tests for this package. +105 */ +106 PROCEDURE test; +107 +108 +109 end LOGICAL_WORKPLACE_TS; +110 / + +Package created. + +SQL> @se.sql LOGICAL_WORKPLACE_TS +SQL> show errors +No errors. +SQL> +SQL> +SQL> -- package bodies +SQL> @dates.pkb +SQL> create or replace package body DATES as + 2 /* + 3 dates.pkb + 4 by Donald J. Bales on 12/15/2006 + 5 Additional DATE data type methods + 6 */ + 7 + 8 + 9 FUNCTION end_of_day( + 10 aid_date in date ) + 11 return date is + 12 + 13 begin + 14 return to_date(to_char(aid_date, 'SYYYYMMDD')||'235959', + 15 'SYYYYMMDDHH24MISS'); + 16 end end_of_day; + 17 + 18 + 19 FUNCTION get_max + 20 return date is + 21 + 22 begin + 23 return d_MAX; + 24 end get_max; + 25 + 26 + 27 FUNCTION get_min + 28 return date is + 29 + 30 begin + 31 return d_MIN; + 32 end get_min; + 33 + 34 + 35 FUNCTION random( + 36 ain_starting_year in number, + 37 ain_ending_year in number ) + 38 return date is + 39 + 40 d_random date; + 41 n_day number; + 42 n_month number; + 43 n_year number; + 44 + 45 begin + 46 n_year := round(DBMS_RANDOM.value( + 47 ain_starting_year, ain_ending_year), 0); + 48 --pl('n_year='||n_year); + 49 loop + 50 n_month := round(DBMS_RANDOM.value(1, 12), 0); + 51 --pl('n_month='||n_month); + 52 n_day := round(DBMS_RANDOM.value(1, 31), 0); + 53 --pl('n_day='||n_day); + 54 begin + 55 d_random := to_date(lpad(to_char(n_year), 4, '0')|| + 56 lpad(to_char(n_month), 2, '0')|| + 57 lpad(to_char(n_day), 2, '0'), + 58 'YYYYMMDD'); + 59 exit; + 60 exception + 61 when OTHERS then + 62 if SQLCODE <> -1839 then + 63 pl(SQLERRM); + 64 --else + 65 -- pl('29-31'); + 66 end if; + 67 end; + 68 end loop; + 69 return d_random; + 70 end random; + 71 + 72 + 73 FUNCTION start_of_day( + 74 aid_date in date ) + 75 return date is + 76 + 77 begin + 78 return trunc(aid_date); + 79 end start_of_day; + 80 + 81 + 82 -- Write up the help text here in this help method + 83 PROCEDURE help is + 84 + 85 begin + 86 -- 1234567890123456789012345678901234567890123456789012345678901234567890 + 87 pl('============================== PACKAGE =============================='); + 88 pl(chr(9)); + 89 pl('DATES'); + 90 pl(chr(9)); + 91 pl('------------------------------ CONSTANTS ----------------------------'); + 92 pl(chr(9)); + 93 pl('d_MAX'); + 94 pl(chr(9)||'Represents the maximum value for the DATE data type.'); + 95 pl('d_MIN'); + 96 pl(chr(9)||'Represents the minimum value for the DATE data type.'); + 97 pl(chr(9)); + 98 pl('------------------------------ FUNCTIONS ----------------------------'); + 99 pl(chr(9)); +100 pl('DATES.end_of_day('); +101 pl('aid_date in date)'); +102 pl('return date;'); +103 pl(chr(9)||'Returns the passed date with the time portion set to the end '); +104 pl(chr(9)||'of the day:'); +105 pl(chr(9)||'23:59:59 (HH24:MI:SS).'); +106 pl(chr(9)); +107 pl('DATES.get_max( )'); +108 pl('return date;'); +109 pl(chr(9)||'Returns the constant DATES.d_MAX.'); +110 pl(chr(9)); +111 pl('DATES.get_mim( )'); +112 pl('return date;'); +113 pl(chr(9)||'Returns the constant DATES.d_MIN.'); +114 pl(chr(9)); +115 pl('DATES.random('); +116 pl('ain_starting_year in number,'); +117 pl('ain_ending_year in number)'); +118 pl('return date;'); +119 pl(chr(9)||'Returns a random date that exists between the specified years.'); +120 pl(chr(9)); +121 pl('DATES.start_of_day('); +122 pl('aid_date in date)'); +123 pl('return date;'); +124 pl(chr(9)||'Returns the passed date with the time portion set to the start'); +125 pl(chr(9)||'of the day:'); +126 pl(chr(9)||'00:00:00 (HH24:MI:SS).'); +127 pl(chr(9)); +128 pl('------------------------------ PROCEDURES ----------------------------'); +129 pl(chr(9)); +130 pl('DATES.help( );'); +131 pl(chr(9)||'Displays this help text if set serveroutput is on.'); +132 pl(chr(9)); +133 pl('DATES.test( );'); +134 pl(chr(9)||'Built-in test unit. It will report success or error for each'); +135 pl(chr(9)||'test if set'); +136 pl(chr(9)||'serveroutput is on.'); +137 pl(chr(9)); +138 end help; +139 +140 +141 PROCEDURE test is +142 +143 d_date date; +144 +145 begin +146 pl('============================== PACKAGE ==============================='); +147 pl(chr(9)); +148 pl('DATES'); +149 pl(chr(9)); +150 pl('1. Testing constants d_MIN and d_MAX'); +151 if d_MIN < d_MAX then +152 pl('SUCCESS'); +153 else +154 pl('ERROR: d_MIN is not less than d_MAX'); +155 end if; +156 +157 pl('2. Testing end_of_day()'); +158 if to_char(end_of_day(SYSDATE), 'HH24MISS') = '235959' then +159 pl('SUCCESS'); +160 else +161 pl('ERROR: end_of_day is not 23:59:59'); +162 end if; +163 +164 pl('3. Testing get_max()'); +165 if get_max() = d_MAX then +166 pl('SUCCESS'); +167 else +168 pl('ERROR: get_max() is not equal to d_MAX'); +169 end if; +170 +171 pl('4. Testing get_min()'); +172 if get_min() = d_MIN then +173 pl('SUCCESS'); +174 else +175 pl('ERROR: get_min() is not equal to d_MIN'); +176 end if; +177 +178 pl('5. Testing random() 1000 times'); +179 for i in 1..1000 loop +180 d_date := random(1, 9999); +181 --pl(to_char(d_date, 'YYYY-MM-DD HH24:MI:SS')); +182 end loop; +183 pl('SUCCESS'); +184 +185 pl('6. Testing start_of_day()'); +186 if to_char(start_of_day(SYSDATE), 'HH24MISS') = '000000' then +187 pl('SUCCESS'); +188 else +189 pl('ERROR: start_of_day is not 00:00:00'); +190 end if; +191 end test; +192 +193 +194 end DATES; +195 / + +Package body created. + +SQL> @be.sql DATES +SQL> show errors +No errors. +SQL> @workplace_type_ts.pkb +SQL> create or replace PACKAGE BODY WORKPLACE_TYPE_TS as + 2 /* + 3 workplace_type_ts.pkb + 4 by Donald J. Bales on 12/15/2006 + 5 Table WORKPLACE_TYPE_T's methods + 6 */ + 7 + 8 + 9 -- FUNCTIONS + 10 + 11 FUNCTION get_id + 12 return WORKPLACE_TYPE_T.id%TYPE is + 13 + 14 n_id WORKPLACE_TYPE_T.id%TYPE; + 15 + 16 begin + 17 select WORKPLACE_TYPE_ID_SEQ.nextval + 18 into n_id + 19 from SYS.DUAL; + 20 + 21 return n_id; + 22 end get_id; + 23 + 24 + 25 FUNCTION get_id( + 26 aiv_code in WORKPLACE_TYPE_T.code%TYPE ) + 27 return WORKPLACE_TYPE_T.id%TYPE is + 28 + 29 n_id WORKPLACE_TYPE_T.id%TYPE; + 30 + 31 begin + 32 select id + 33 into n_id + 34 from WORKPLACE_TYPE_T + 35 where code = aiv_code; + 36 + 37 return n_id; + 38 end get_id; + 39 + 40 + 41 -- PROCEDURES + 42 + 43 PROCEDURE get_code_descr( + 44 ain_id in WORKPLACE_TYPE_T.id%TYPE, + 45 aov_code out WORKPLACE_TYPE_T.code%TYPE, + 46 aov_description out WORKPLACE_TYPE_T.description%TYPE ) is + 47 + 48 begin + 49 select code, + 50 description + 51 into aov_code, + 52 aov_description + 53 from WORKPLACE_TYPE_T + 54 where id = ain_id; + 55 end get_code_descr; + 56 + 57 + 58 PROCEDURE get_code_id_descr( + 59 aiov_code in out WORKPLACE_TYPE_T.code%TYPE, + 60 aon_id out WORKPLACE_TYPE_T.id%TYPE, + 61 aov_description out WORKPLACE_TYPE_T.description%TYPE, + 62 aid_on in WORKPLACE_TYPE_T.active_date%TYPE ) is + 63 + 64 v_code WORKPLACE_TYPE_T.code%TYPE; + 65 + 66 begin + 67 select id, + 68 description + 69 into aon_id, + 70 aov_description + 71 from WORKPLACE_TYPE_T + 72 where code = aiov_code + 73 and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); + 74 exception + 75 when NO_DATA_FOUND then + 76 select id, + 77 code, + 78 description + 79 into aon_id, + 80 v_code, + 81 aov_description + 82 from WORKPLACE_TYPE_T + 83 where code like aiov_code||'%' + 84 and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); + 85 + 86 aiov_code := v_code; + 87 end get_code_id_descr; + 88 + 89 + 90 PROCEDURE get_code_id_descr( + 91 aiov_code in out WORKPLACE_TYPE_T.code%TYPE, + 92 aon_id out WORKPLACE_TYPE_T.id%TYPE, + 93 aov_description out WORKPLACE_TYPE_T.description%TYPE ) is + 94 + 95 begin + 96 get_code_id_descr( + 97 aiov_code, + 98 aon_id, + 99 aov_description, +100 SYSDATE ); +101 end get_code_id_descr; +102 +103 PROCEDURE help is +104 +105 begin +106 -- 12345678901234567890123456789012345678901234567890123456789012345678901234567890 +107 pl('=================================== PACKAGE ===================================='); +108 pl(chr(9)); +109 pl('WORKPLACE_TYPE_TS'); +110 pl(chr(9)); +111 pl('----------------------------------- FUNCTIONS ----------------------------------'); +112 pl(chr(9)); +113 pl('WORKPLACE_TYPE_TS.get_id'); +114 pl('return WORKPLACE_TYPE_T.id%TYPE;'); +115 pl(chr(9)||'Returns a newly allocated sequence value for id.'); +116 pl(chr(9)); +117 pl('WORKPLACE_TYPE_TS.get_id('); +118 pl('aiv_code in WORKPLACE_TYPE_T.code%TYPE )'); +119 pl('return WORKPLACE_TYPE_T.id%TYPE;'); +120 pl(chr(9)||'Returns the corresponding id for the specified code.'); +121 pl(chr(9)); +122 pl('----------------------------------- PROCEDURES ---------------------------------'); +123 pl(chr(9)); +124 pl('WORKPLACE_TYPE_TS.get_code_descr('); +125 pl('ain_id in WORKPLACE_TYPE_T.id%TYPE,'); +126 pl('aov_code out WORKPLACE_TYPE_T.code%TYPE,'); +127 pl('aov_description out WORKPLACE_TYPE_T.description%TYPE );'); +128 pl(chr(9)||'Gets the corresponding code and description for the specified'); +129 pl(chr(9)||'id.'); +130 pl(chr(9)); +131 pl('WORKPLACE_TYPE_TS.get_code_id_descr('); +132 pl('aiov_code in out WORKPLACE_TYPE_T.code%TYPE,'); +133 pl('aon_id out WORKPLACE_TYPE_T.id%TYPE,'); +134 pl('aov_description out WORKPLACE_TYPE_T.description%TYPE,'); +135 pl('aid_on in WORKPLACE_TYPE_T.active_date%TYPE );'); +136 pl(chr(9)||'Gets the corresponding code, id, and description for'); +137 pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); +138 pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); +139 pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); +140 pl(chr(9)||'found for the specified code and point in time.'); +141 pl(chr(9)); +142 pl('WORKPLACE_TYPE_TS.get_code_id_descr('); +143 pl('aiov_code in out WORKPLACE_TYPE_T.code%TYPE,'); +144 pl('aon_id out WORKPLACE_TYPE_T.id%TYPE,'); +145 pl('aov_description out WORKPLACE_TYPE_T.description%TYPE );'); +146 pl(chr(9)||'Gets the corresponding code, id, and description for'); +147 pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); +148 pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); +149 pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); +150 pl(chr(9)||'found for the specified code at the current point in time.'); +151 pl(chr(9)); +152 pl('WORKPLACE_TYPE_TS.help( );'); +153 pl(chr(9)||'Displays this help text if set serveroutput is on.'); +154 pl(chr(9)); +155 pl('WORKPLACE_TYPE_TS.test( );'); +156 pl(chr(9)||'Built-in test unit. It will report success or error for each test if set'); +157 pl(chr(9)||'serveroutput is on.'); +158 pl(chr(9)); +159 end help; +160 +161 +162 PROCEDURE test is +163 +164 begin +165 pl('=================================== PACKAGE ===================================='); +166 pl(chr(9)); +167 pl('DATES'); +168 pl(chr(9)); +169 -- pl('1. Testing constants d_MIN and d_MAX'); +170 -- if d_MIN < d_MAX then +171 -- pl('SUCCESS'); +172 -- else +173 -- pl('ERROR: d_MIN is not less than d_MAX'); +174 -- end if; +175 pl(chr(9)||'No tests coded at this time'); +176 end test; +177 +178 +179 end WORKPLACE_TYPE_TS; +180 / + +Package body created. + +SQL> @be.sql WORKPLACE_TYPE_TS +SQL> show errors +No errors. +SQL> +SQL> @logical_workplace_ts.pkb +SQL> create or replace PACKAGE BODY LOGICAL_WORKPLACE_TS as + 2 /* + 3 logical_workplace_ts.pkb + 4 by Donald J. Bales on 12/15/2006 + 5 Table LOGICAL_WORKPLACE_T's methods + 6 */ + 7 + 8 -- FORWARD DECLARATIONS + 9 + 10 FUNCTION get_parent_id_context( + 11 ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE) + 12 return varchar2; + 13 + 14 + 15 -- FUNCTIONS + 16 + 17 FUNCTION create_id_context( + 18 ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, + 19 ain_id in LOGICAL_WORKPLACE_T.id%TYPE) + 20 return varchar2 is + 21 + 22 v_id_context LOGICAL_WORKPLACE_T.id_context%TYPE; + 23 + 24 begin + 25 v_id_context := get_parent_id_context(ain_parent_id); + 26 + 27 if v_id_context is not NULL then + 28 return substr(v_id_context||'.'||to_char(ain_id), 1, 2000); + 29 else + 30 return to_char(ain_id); + 31 end if; + 32 end create_id_context; + 33 + 34 + 35 FUNCTION get_id + 36 return LOGICAL_WORKPLACE_T.id%TYPE is + 37 + 38 n_id LOGICAL_WORKPLACE_T.id%TYPE; + 39 + 40 begin + 41 select LOGICAL_WORKPLACE_ID_SEQ.nextval + 42 into n_id + 43 from SYS.DUAL; + 44 + 45 return n_id; + 46 end get_id; + 47 + 48 + 49 FUNCTION get_code_context( + 50 ain_id in LOGICAL_WORKPLACE_T.id%TYPE) + 51 return varchar2 is + 52 + 53 cursor c_code_context( + 54 ain_id in LOGICAL_WORKPLACE_T.id%TYPE) is + 55 select upper(code) code + 56 from LOGICAL_WORKPLACE_T + 57 connect by prior parent_id = id + 58 start with id = ain_id + 59 order by level desc; + 60 + 61 v_code_context varchar2(2000); + 62 + 63 begin + 64 for r_code_context in c_code_context(ain_id) loop + 65 v_code_context := substr(v_code_context||'.'||r_code_context.code, 1, 2000); + 66 end loop; + 67 return v_code_context; + 68 end get_code_context; + 69 + 70 + 71 FUNCTION get_name_context( + 72 ain_id in LOGICAL_WORKPLACE_T.id%TYPE) + 73 return varchar2 is + 74 + 75 cursor c_name_context( + 76 ain_id in LOGICAL_WORKPLACE_T.id%TYPE) is + 77 select initcap(name) name + 78 from LOGICAL_WORKPLACE_T + 79 connect by prior parent_id = id + 80 start with id = ain_id + 81 order by level desc; + 82 + 83 v_name_context varchar2(2000); + 84 + 85 begin + 86 for r_name_context in c_name_context(ain_id) loop + 87 v_name_context := substr(v_name_context||'.'||r_name_context.name, 1, 2000); + 88 end loop; + 89 return v_name_context; + 90 end get_name_context; + 91 + 92 + 93 FUNCTION get_parent_id_context( + 94 ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE) + 95 return varchar2 is + 96 + 97 v_id_context LOGICAL_WORKPLACE_T.id_context%TYPE; + 98 + 99 begin +100 if ain_parent_id is not NULL then +101 select id_context +102 into v_id_context +103 from LOGICAL_WORKPLACE_T +104 where id = ain_parent_id; +105 end if; +106 +107 return v_id_context; +108 end get_parent_id_context; +109 +110 +111 FUNCTION get_row( +112 air_logical_workplace in LOGICAL_WORKPLACE_T%ROWTYPE) +113 return LOGICAL_WORKPLACE_T%ROWTYPE is +114 +115 r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; +116 +117 begin +118 if air_logical_workplace.id is not NULL then +119 -- retrieve the row by the primary key +120 select * +121 into r_logical_workplace +122 from LOGICAL_WORKPLACE_T +123 where id = air_logical_workplace.id; +124 elsif air_logical_workplace.id_context is not NULL then +125 -- retrieve the row by the id_context unique key +126 select * +127 into r_logical_workplace +128 from LOGICAL_WORKPLACE_T +129 where id = air_logical_workplace.id_context; +130 else +131 -- retrieve the row by the code, name, and active_date +132 select * +133 into r_logical_workplace +134 from LOGICAL_WORKPLACE_T +135 where code = air_logical_workplace.code +136 and name = air_logical_workplace.name +137 and active_date = air_logical_workplace.active_date; +138 end if; +139 return r_logical_workplace; +140 exception +141 when NO_DATA_FOUND then +142 raise; +143 when OTHERS then +144 raise_application_error(-20001, SQLERRM|| +145 ' on select LOGICAL_WORKPLACE_T'|| +146 ' in LOGICAL_WORKPLACE_TS.get_row()'); +147 end get_row; +148 +149 +150 FUNCTION set_row( +151 ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +152 ain_workplace_type_id in LOGICAL_WORKPLACE_T.workplace_type_id%TYPE, +153 aiv_code in LOGICAL_WORKPLACE_T.code%TYPE, +154 aiv_name in LOGICAL_WORKPLACE_T.name%TYPE, +155 aid_active_date in LOGICAL_WORKPLACE_T.active_date%TYPE) +156 return LOGICAL_WORKPLACE_T.id%TYPE is +157 +158 r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; +159 +160 begin +161 r_logical_workplace.id := NULL; +162 r_logical_workplace.id_context := NULL; +163 r_logical_workplace.parent_id := ain_parent_id; +164 r_logical_workplace.workplace_type_id := ain_workplace_type_id; +165 r_logical_workplace.code := aiv_code; +166 r_logical_workplace.name := aiv_name; +167 r_logical_workplace.active_date := aid_active_date; +168 set_row(r_logical_workplace); +169 +170 return r_logical_workplace.id; +171 end set_row; +172 +173 +174 -- PROCEDURES +175 +176 PROCEDURE help is +177 +178 begin +179 -- 12345678901234567890123456789012345678901234567890123456789012345678901234567890 +180 pl(' +181 =================================== PACKAGE ==================================== +182 +183 LOGICAL_WORKPLACE_TS +184 +185 ----------------------------------- FUNCTIONS ---------------------------------- +186 +187 +188 This line should be indented. +189 +190 This line shouldn''t. '); +191 end help; +192 +193 +194 PROCEDURE set_row( +195 aior_logical_workplace in out LOGICAL_WORKPLACE_T%ROWTYPE) is +196 +197 d_null constant date := DATES.d_MIN; +198 n_null constant number := 0; +199 v_null constant varchar2(1) := ' '; +200 r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; +201 +202 begin +203 -- get the existing row +204 begin +205 r_logical_workplace := get_row(aior_logical_workplace); +206 exception +207 when NO_DATA_FOUND then +208 r_logical_workplace := NULL; +209 end; +210 -- if a row exists, update it if needed +211 if r_logical_workplace.id is not NULL then +212 aior_logical_workplace.id := r_logical_workplace.id; +213 aior_logical_workplace.parent_id := r_logical_workplace.parent_id; +214 aior_logical_workplace.id_context := r_logical_workplace.id_context; +215 if nvl(r_logical_workplace.workplace_type_id, n_null) <> nvl(aior_logical_workplace.workplace_type_id, n_null) or +216 nvl(r_logical_workplace.code, v_null) <> nvl(aior_logical_workplace.code, v_null) or +217 nvl(r_logical_workplace.name, v_null) <> nvl(aior_logical_workplace.name, v_null) or +218 nvl(r_logical_workplace.active_date, d_null) <> nvl(aior_logical_workplace.active_date, d_null) or +219 nvl(r_logical_workplace.inactive_date, d_null) <> nvl(aior_logical_workplace.inactive_date, d_null) then +220 begin +221 update LOGICAL_WORKPLACE_T +222 set workplace_type_id = aior_logical_workplace.workplace_type_id, +223 code = aior_logical_workplace.code, +224 name = aior_logical_workplace.name, +225 active_date = aior_logical_workplace.active_date, +226 inactive_date = aior_logical_workplace.inactive_date +227 where id = aior_logical_workplace.id; +228 +229 n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0); +230 exception +231 when OTHERS then +232 raise_application_error( -20002, SQLERRM|| +233 ' on update LOGICAL_WORKPLACE_T'|| +234 ' in LOGICAL_WORKPLACE_TS.set_row()' ); +235 end; +236 end if; +237 else +238 -- add the row if it does not exist +239 begin +240 aior_logical_workplace.id := get_id(); +241 aior_logical_workplace.id_context := create_id_context( +242 aior_logical_workplace.parent_id, +243 aior_logical_workplace.id ); +244 insert into LOGICAL_WORKPLACE_T ( +245 id, +246 parent_id, +247 id_context, +248 workplace_type_id, +249 code, +250 name, +251 active_date, +252 inactive_date ) +253 values ( +254 aior_logical_workplace.id, +255 aior_logical_workplace.parent_id, +256 aior_logical_workplace.id_context, +257 aior_logical_workplace.workplace_type_id, +258 aior_logical_workplace.code, +259 aior_logical_workplace.name, +260 aior_logical_workplace.active_date, +261 aior_logical_workplace.inactive_date ); +262 +263 n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0); +264 exception +265 when OTHERS then +266 raise_application_error( -20003, SQLERRM|| +267 ' on insert LOGICAL_WORKPLACE_T'|| +268 ' in LOGICAL_WORKPLACE_TS.set_row()' ); +269 end; +270 end if; +271 end set_row; +272 +273 +274 PROCEDURE test is +275 +276 begin +277 pl('=================================== PACKAGE ===================================='); +278 pl(chr(9)); +279 pl('LOGICAL_WORKPLACE_TS'); +280 pl(chr(9)); +281 -- pl('1. Testing constants d_MIN and d_MAX'); +282 -- if d_MIN < d_MAX then +283 -- pl('SUCCESS'); +284 -- else +285 -- pl('ERROR: d_MIN is not less than d_MAX'); +286 -- end if; +287 pl(chr(9)||'No tests for LOGICAL_WORKPLACE_TS at this time'); +288 end test; +289 +290 +291 end LOGICAL_WORKPLACE_TS; +292 / + +Package body created. + +SQL> @be.sql LOGICAL_WORKPLACE_TS +SQL> show errors +No errors. +SQL> +SQL> +SQL> -- content +SQL> @logical_workplace_t.ins +SQL> rem logical_workplace_t.ins +SQL> rem by Donald J. Bales on 12/15/2006 +SQL> rem Add logical workplaces +SQL> +SQL> insert into LOGICAL_WORKPLACE_T ( + 2 id, + 3 parent_id, + 4 id_context, + 5 workplace_type_id, + 6 code, + 7 name, + 8 active_date ) + 9 select LOGICAL_WORKPLACE_ID_SEQ.nextval, + 10 NULL, + 11 to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + 12 t.id, + 13 'VDMI', + 14 'VERY DIRTY MANUFACTURING, INC.', + 15 to_date('19800101', 'YYYYMMDD') + 16 from WORKPLACE_TYPE_T t + 17 where t.code = 'C'; + +1 row created. + +SQL> +SQL> +SQL> insert into LOGICAL_WORKPLACE_T ( + 2 id, + 3 parent_id, + 4 id_context, + 5 workplace_type_id, + 6 code, + 7 name, + 8 active_date ) + 9 select LOGICAL_WORKPLACE_ID_SEQ.nextval, + 10 p.id, + 11 p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + 12 t.id, + 13 'SALE', + 14 'SALES', + 15 to_date('19800101', 'YYYYMMDD') + 16 from WORKPLACE_TYPE_T t, + 17 LOGICAL_WORKPLACE_T p + 18 where t.code = 'B' + 19 and p.code = 'VDMI' + 20 and p.name = 'VERY DIRTY MANUFACTURING, INC.' + 21 and p.active_date = to_date('19800101', 'YYYYMMDD'); + +1 row created. + +SQL> +SQL> +SQL> insert into LOGICAL_WORKPLACE_T ( + 2 id, + 3 parent_id, + 4 id_context, + 5 workplace_type_id, + 6 code, + 7 name, + 8 active_date ) + 9 select LOGICAL_WORKPLACE_ID_SEQ.nextval, + 10 p.id, + 11 p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + 12 t.id, + 13 'MKTG', + 14 'MARKETING', + 15 to_date('19800101', 'YYYYMMDD') + 16 from WORKPLACE_TYPE_T t, + 17 LOGICAL_WORKPLACE_T p + 18 where t.code = 'B' + 19 and p.code = 'VDMI' + 20 and p.name = 'VERY DIRTY MANUFACTURING, INC.' + 21 and p.active_date = to_date('19800101', 'YYYYMMDD'); + +1 row created. + +SQL> +SQL> insert into LOGICAL_WORKPLACE_T ( + 2 id, + 3 parent_id, + 4 id_context, + 5 workplace_type_id, + 6 code, + 7 name, + 8 active_date ) + 9 select LOGICAL_WORKPLACE_ID_SEQ.nextval, + 10 p.id, + 11 p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + 12 t.id, + 13 'ACCT', + 14 'ACCOUNTING', + 15 to_date('19800101', 'YYYYMMDD') + 16 from WORKPLACE_TYPE_T t, + 17 LOGICAL_WORKPLACE_T p + 18 where t.code = 'B' + 19 and p.code = 'VDMI' + 20 and p.name = 'VERY DIRTY MANUFACTURING, INC.' + 21 and p.active_date = to_date('19800101', 'YYYYMMDD'); + +1 row created. + +SQL> +SQL> insert into LOGICAL_WORKPLACE_T ( + 2 id, + 3 parent_id, + 4 id_context, + 5 workplace_type_id, + 6 code, + 7 name, + 8 active_date ) + 9 select LOGICAL_WORKPLACE_ID_SEQ.nextval, + 10 p.id, + 11 p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + 12 t.id, + 13 'PDEV', + 14 'PRODUCT DEVELOPMENT', + 15 to_date('19800101', 'YYYYMMDD') + 16 from WORKPLACE_TYPE_T t, + 17 LOGICAL_WORKPLACE_T p + 18 where t.code = 'B' + 19 and p.code = 'VDMI' + 20 and p.name = 'VERY DIRTY MANUFACTURING, INC.' + 21 and p.active_date = to_date('19800101', 'YYYYMMDD'); + +1 row created. + +SQL> +SQL> +SQL> insert into LOGICAL_WORKPLACE_T ( + 2 id, + 3 parent_id, + 4 id_context, + 5 workplace_type_id, + 6 code, + 7 name, + 8 active_date ) + 9 select LOGICAL_WORKPLACE_ID_SEQ.nextval, + 10 p.id, + 11 p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + 12 t.id, + 13 'MFG', + 14 'MANUFACTURING', + 15 to_date('19800101', 'YYYYMMDD') + 16 from WORKPLACE_TYPE_T t, + 17 LOGICAL_WORKPLACE_T p + 18 where t.code = 'B' + 19 and p.code = 'VDMI' + 20 and p.name = 'VERY DIRTY MANUFACTURING, INC.' + 21 and p.active_date = to_date('19800101', 'YYYYMMDD'); + +1 row created. + +SQL> +SQL> insert into LOGICAL_WORKPLACE_T ( + 2 id, + 3 parent_id, + 4 id_context, + 5 workplace_type_id, + 6 code, + 7 name, + 8 active_date ) + 9 select LOGICAL_WORKPLACE_ID_SEQ.nextval, + 10 p.id, + 11 p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + 12 t.id, + 13 'CHEM', + 14 'CHEMICALS', + 15 to_date('19800101', 'YYYYMMDD') + 16 from WORKPLACE_TYPE_T t, + 17 LOGICAL_WORKPLACE_T p + 18 where t.code = 'D' + 19 and p.code = 'MFG' + 20 and p.name = 'MANUFACTURING' + 21 and p.active_date = to_date('19800101', 'YYYYMMDD'); + +1 row created. + +SQL> +SQL> insert into LOGICAL_WORKPLACE_T ( + 2 id, + 3 parent_id, + 4 id_context, + 5 workplace_type_id, + 6 code, + 7 name, + 8 active_date ) + 9 select LOGICAL_WORKPLACE_ID_SEQ.nextval, + 10 p.id, + 11 p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + 12 t.id, + 13 'BIO', + 14 'BIOLOGICALS', + 15 to_date('19800101', 'YYYYMMDD') + 16 from WORKPLACE_TYPE_T t, + 17 LOGICAL_WORKPLACE_T p + 18 where t.code = 'D' + 19 and p.code = 'MFG' + 20 and p.name = 'MANUFACTURING' + 21 and p.active_date = to_date('19800101', 'YYYYMMDD'); + +1 row created. + +SQL> +SQL> insert into LOGICAL_WORKPLACE_T ( + 2 id, + 3 parent_id, + 4 id_context, + 5 workplace_type_id, + 6 code, + 7 name, + 8 active_date ) + 9 select LOGICAL_WORKPLACE_ID_SEQ.nextval, + 10 p.id, + 11 p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + 12 t.id, + 13 'METL', + 14 'METALS', + 15 to_date('19800101', 'YYYYMMDD') + 16 from WORKPLACE_TYPE_T t, + 17 LOGICAL_WORKPLACE_T p + 18 where t.code = 'D' + 19 and p.code = 'MFG' + 20 and p.name = 'MANUFACTURING' + 21 and p.active_date = to_date('19800101', 'YYYYMMDD'); + +1 row created. + +SQL> +SQL> insert into LOGICAL_WORKPLACE_T ( + 2 id, + 3 parent_id, + 4 id_context, + 5 workplace_type_id, + 6 code, + 7 name, + 8 active_date ) + 9 select LOGICAL_WORKPLACE_ID_SEQ.nextval, + 10 p.id, + 11 p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + 12 t.id, + 13 'RUSE', + 14 'REUSABLES', + 15 to_date('19800101', 'YYYYMMDD') + 16 from WORKPLACE_TYPE_T t, + 17 LOGICAL_WORKPLACE_T p + 18 where t.code = 'D' + 19 and p.code = 'MFG' + 20 and p.name = 'MANUFACTURING' + 21 and p.active_date = to_date('19800101', 'YYYYMMDD'); + +1 row created. + +SQL> +SQL> insert into LOGICAL_WORKPLACE_T ( + 2 id, + 3 parent_id, + 4 id_context, + 5 workplace_type_id, + 6 code, + 7 name, + 8 active_date ) + 9 select LOGICAL_WORKPLACE_ID_SEQ.nextval, + 10 p.id, + 11 p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + 12 t.id, + 13 'DISP', + 14 'DISPOSABLES', + 15 to_date('19800101', 'YYYYMMDD') + 16 from WORKPLACE_TYPE_T t, + 17 LOGICAL_WORKPLACE_T p + 18 where t.code = 'D' + 19 and p.code = 'MFG' + 20 and p.name = 'MANUFACTURING' + 21 and p.active_date = to_date('19800101', 'YYYYMMDD'); + +1 row created. + +SQL> +SQL> +SQL> insert into LOGICAL_WORKPLACE_T ( + 2 id, + 3 parent_id, + 4 id_context, + 5 workplace_type_id, + 6 code, + 7 name, + 8 active_date ) + 9 select LOGICAL_WORKPLACE_ID_SEQ.nextval, + 10 p.id, + 11 p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + 12 t.id, + 13 'HR', + 14 'HUMAN RESOURCES', + 15 to_date('19800101', 'YYYYMMDD') + 16 from WORKPLACE_TYPE_T t, + 17 LOGICAL_WORKPLACE_T p + 18 where t.code = 'B' + 19 and p.code = 'VDMI' + 20 and p.name = 'VERY DIRTY MANUFACTURING, INC.' + 21 and p.active_date = to_date('19800101', 'YYYYMMDD'); + +1 row created. + +SQL> +SQL> commit; + +Commit complete. + +SQL> +SQL> -- but no IT? +SQL> declare + 2 + 3 r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; + 4 n_IT_id LOGICAL_WORKPLACE_T.id%TYPE; + 5 n_VDMI_id LOGICAL_WORKPLACE_T.id%TYPE; + 6 + 7 begin + 8 -- first, get the company's id + 9 -- set the record up to search by the code, name, and active_date + 10 r_logical_workplace.code := 'VDMI'; + 11 r_logical_workplace.name := 'VERY DIRTY MANUFACTURING, INC.'; + 12 r_logical_workplace.active_date := to_date('19800101', 'YYYYMMDD'); + 13 + 14 r_logical_workplace := LOGICAL_WORKPLACE_TS.get_row(r_logical_workplace); + 15 + 16 n_VDMI_id := r_logical_workplace.id; + 17 + 18 -- now that we have our company's id, let's add IT + 19 + 20 r_logical_workplace.id := NULL; + 21 r_logical_workplace.parent_id := n_VDMI_id; + 22 r_logical_workplace.id_context := NULL; + 23 r_logical_workplace.workplace_type_id := WORKPLACE_TYPE_TS.get_id('B'); + 24 r_logical_workplace.code := 'IT'; + 25 r_logical_workplace.name := 'IRRITATING TECHNOLOGY'; + 26 LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + 27 + 28 + 29 n_IT_id := r_logical_workplace.id; + 30 + 31 r_logical_workplace.id := NULL; + 32 r_logical_workplace.parent_id := n_IT_id; + 33 r_logical_workplace.id_context := NULL; + 34 r_logical_workplace.workplace_type_id := WORKPLACE_TYPE_TS.get_id('D'); + 35 r_logical_workplace.code := 'DP'; + 36 r_logical_workplace.name := 'DEPRESSED PROCESSING'; + 37 LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + 38 + 39 r_logical_workplace.id := NULL; + 40 r_logical_workplace.parent_id := n_IT_id; + 41 r_logical_workplace.id_context := NULL; + 42 r_logical_workplace.workplace_type_id := WORKPLACE_TYPE_TS.get_id('D'); + 43 r_logical_workplace.code := 'HSUP'; + 44 r_logical_workplace.name := 'HARDWEAR SUPPORT'; + 45 LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + 46 + 47 r_logical_workplace.id := NULL; + 48 r_logical_workplace.parent_id := n_IT_id; + 49 r_logical_workplace.id_context := NULL; + 50 r_logical_workplace.workplace_type_id := WORKPLACE_TYPE_TS.get_id('D'); + 51 r_logical_workplace.code := 'SDEV'; + 52 r_logical_workplace.name := 'SOFTWEAR DEVELOPMENT'; + 53 LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + 54 + 55 r_logical_workplace.id := NULL; + 56 r_logical_workplace.parent_id := n_IT_id; + 57 r_logical_workplace.id_context := NULL; + 58 r_logical_workplace.workplace_type_id := WORKPLACE_TYPE_TS.get_id('D'); + 59 r_logical_workplace.code := 'SINT'; + 60 r_logical_workplace.name := 'SILLINESS INTEGRATION'; + 61 LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + 62 + 63 r_logical_workplace.id := NULL; + 64 r_logical_workplace.parent_id := n_IT_id; + 65 r_logical_workplace.id_context := NULL; + 66 r_logical_workplace.workplace_type_id := WORKPLACE_TYPE_TS.get_id('D'); + 67 r_logical_workplace.code := 'SSUP'; + 68 r_logical_workplace.name := 'SOFTWEAR SUPPORT'; + 69 LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + 70 + 71 end; + 72 / + +PL/SQL procedure successfully completed. + +SQL> +SQL> commit; + +Commit complete. + +SQL> +SQL> spool off; diff --git a/Chapter02/dates.pkb b/Chapter02/dates.pkb new file mode 100644 index 0000000..c8094e1 --- /dev/null +++ b/Chapter02/dates.pkb @@ -0,0 +1,196 @@ +create or replace package body DATES as +/* +dates.pkb +by Donald J. Bales on 12/15/2006 +Additional DATE data type methods +*/ + + +FUNCTION end_of_day( +aid_date in date ) +return date is + +begin + return to_date(to_char(aid_date, 'SYYYYMMDD')||'235959', + 'SYYYYMMDDHH24MISS'); +end end_of_day; + + +FUNCTION get_max +return date is + +begin + return d_MAX; +end get_max; + + +FUNCTION get_min +return date is + +begin + return d_MIN; +end get_min; + + +FUNCTION random( +ain_starting_year in number, +ain_ending_year in number ) +return date is + +d_random date; +n_day number; +n_month number; +n_year number; + +begin + n_year := round(DBMS_RANDOM.value( + ain_starting_year, ain_ending_year), 0); + --pl('n_year='||n_year); + loop + n_month := round(DBMS_RANDOM.value(1, 12), 0); + --pl('n_month='||n_month); + n_day := round(DBMS_RANDOM.value(1, 31), 0); + --pl('n_day='||n_day); + begin + d_random := to_date(lpad(to_char(n_year), 4, '0')|| + lpad(to_char(n_month), 2, '0')|| + lpad(to_char(n_day), 2, '0'), + 'YYYYMMDD'); + exit; + exception + when OTHERS then + if SQLCODE <> -1839 then + pl(SQLERRM); + --else + -- pl('29-31'); + end if; + end; + end loop; + return d_random; +end random; + + +FUNCTION start_of_day( +aid_date in date ) +return date is + +begin + return trunc(aid_date); +end start_of_day; + + +-- Write up the help text here in this help method +PROCEDURE help is + +begin +-- 1234567890123456789012345678901234567890123456789012345678901234567890 + pl('============================== PACKAGE =============================='); + pl(chr(9)); + pl('DATES'); + pl(chr(9)); + pl('------------------------------ CONSTANTS ----------------------------'); + pl(chr(9)); + pl('d_MAX'); + pl(chr(9)||'Represents the maximum value for the DATE data type.'); + pl('d_MIN'); + pl(chr(9)||'Represents the minimum value for the DATE data type.'); + pl(chr(9)); + pl('------------------------------ FUNCTIONS ----------------------------'); + pl(chr(9)); + pl('DATES.end_of_day('); + pl('aid_date in date)'); + pl('return date;'); + pl(chr(9)||'Returns the passed date with the time portion set to the end '); + pl(chr(9)||'of the day:'); + pl(chr(9)||'23:59:59 (HH24:MI:SS).'); + pl(chr(9)); + pl('DATES.get_max( )'); + pl('return date;'); + pl(chr(9)||'Returns the constant DATES.d_MAX.'); + pl(chr(9)); + pl('DATES.get_mim( )'); + pl('return date;'); + pl(chr(9)||'Returns the constant DATES.d_MIN.'); + pl(chr(9)); + pl('DATES.random('); + pl('ain_starting_year in number,'); + pl('ain_ending_year in number)'); + pl('return date;'); + pl(chr(9)||'Returns a random date that exists between the specified years.'); + pl(chr(9)); + pl('DATES.start_of_day('); + pl('aid_date in date)'); + pl('return date;'); + pl(chr(9)||'Returns the passed date with the time portion set to the start'); + pl(chr(9)||'of the day:'); + pl(chr(9)||'00:00:00 (HH24:MI:SS).'); + pl(chr(9)); + pl('------------------------------ PROCEDURES ----------------------------'); + pl(chr(9)); + pl('DATES.help( );'); + pl(chr(9)||'Displays this help text if set serveroutput is on.'); + pl(chr(9)); + pl('DATES.test( );'); + pl(chr(9)||'Built-in test unit. It will report success or error for each'); + pl(chr(9)||'test if set'); + pl(chr(9)||'serveroutput is on.'); + pl(chr(9)); +end help; + + +PROCEDURE test is + +d_date date; + +begin + pl('============================== PACKAGE ==============================='); + pl(chr(9)); + pl('DATES'); + pl(chr(9)); + pl('1. Testing constants d_MIN and d_MAX'); + if d_MIN < d_MAX then + pl('SUCCESS'); + else + pl('ERROR: d_MIN is not less than d_MAX'); + end if; + + pl('2. Testing end_of_day()'); + if to_char(end_of_day(SYSDATE), 'HH24MISS') = '235959' then + pl('SUCCESS'); + else + pl('ERROR: end_of_day is not 23:59:59'); + end if; + + pl('3. Testing get_max()'); + if get_max() = d_MAX then + pl('SUCCESS'); + else + pl('ERROR: get_max() is not equal to d_MAX'); + end if; + + pl('4. Testing get_min()'); + if get_min() = d_MIN then + pl('SUCCESS'); + else + pl('ERROR: get_min() is not equal to d_MIN'); + end if; + + pl('5. Testing random() 1000 times'); + for i in 1..1000 loop + d_date := random(1, 9999); + --pl(to_char(d_date, 'YYYY-MM-DD HH24:MI:SS')); + end loop; + pl('SUCCESS'); + + pl('6. Testing start_of_day()'); + if to_char(start_of_day(SYSDATE), 'HH24MISS') = '000000' then + pl('SUCCESS'); + else + pl('ERROR: start_of_day is not 00:00:00'); + end if; +end test; + + +end DATES; +/ +@be.sql DATES diff --git a/Chapter02/dates.pks b/Chapter02/dates.pks new file mode 100644 index 0000000..ea53788 --- /dev/null +++ b/Chapter02/dates.pks @@ -0,0 +1,66 @@ +create or replace package DATES as +/* +dates.pks +by Donald J. Bales on 12/15/2006 +Additional DATE data type methods. +*/ + +-- The maximum and minimum dates values. + +d_MAX constant date := + to_date('99991231235959', 'YYYYMMDDHH24MISS'); +d_MIN constant date := + to_date('-47120101', 'SYYYYMMDD'); + + +-- Returns the specified date with the time set to 23:59:59, therefore, +-- the end of the day. + +FUNCTION end_of_day( +aid_date in date ) +return date; + + +-- Returns constant d_MAX. This is useful in SQL statements where the +-- constant DATES.d_MAX is not accessible. + +FUNCTION get_max +return date; + + +-- Returns constant d_MIN. This is useful in SQL statements where the +-- constant DATES.d_MIN is not accessible. + +FUNCTION get_min +return date; + + +-- Text-based help for this package. "set serveroutput on" in SQL*Plus. + +PROCEDURE help; + + +-- Returns a randomly generated date that exists between the years specified. + +FUNCTION random( +ain_starting_year in number, +ain_ending_year in number ) +return date; + + +-- Returns the specified date with the time set to 00:00:00, therefore, the +-- start of the day. + +FUNCTION start_of_day( +aid_date in date ) +return date; + + +-- Test unit for this package. + +PROCEDURE test; + + +end DATES; +/ +@se.sql DATES diff --git a/Chapter02/desc.sql b/Chapter02/desc.sql new file mode 100644 index 0000000..45206dc --- /dev/null +++ b/Chapter02/desc.sql @@ -0,0 +1,6 @@ +define table_name="&1"; +set linesize 78; +prompt &table_name +desc &table_name +set linesize 1000; +undefine table_name \ No newline at end of file diff --git a/Chapter02/drop_if_exists.prc b/Chapter02/drop_if_exists.prc new file mode 100644 index 0000000..f6e3017 --- /dev/null +++ b/Chapter02/drop_if_exists.prc @@ -0,0 +1,56 @@ +create or replace PROCEDURE drop_if_exists( +aiv_object_type in varchar2, +aiv_object_name in varchar2) is +/* +drop_if_exists.prc +by Donald J. Bales on 12/15/2006 +Drop the object if it exists +*/ + +cursor c_constraint( +aiv_table_name in varchar2) is +select f.table_name, + f.constraint_name +from SYS.USER_CONSTRAINTS f, + SYS.USER_CONSTRAINTS p +where f.constraint_type = 'R' +and f.r_owner = p.owner +and f.r_constraint_name = p.constraint_name +and p.table_name = aiv_table_name; + +n_count number; +v_sql varchar2(100); + +begin + select count(1) + into n_count + from SYS.USER_OBJECTS + where object_type = upper(aiv_object_type) + and object_name = upper(aiv_object_name); + + if n_count > 0 then + if upper(aiv_object_type) = 'TABLE' then + for r_constraint in c_constraint(upper(aiv_object_name)) loop + v_sql := 'alter table '|| + r_constraint.table_name|| + ' drop constraint '|| + r_constraint.constraint_name; + begin + execute immediate v_sql; + exception + when OTHERS then + pl(SQLERRM||': '||v_sql); + end; + end loop; + end if; + v_sql := 'drop '||aiv_object_type||' '||aiv_object_name; + begin + execute immediate v_sql; + exception + when OTHERS then + pl(SQLERRM||': '||v_sql); + end; + end if; +end drop_if_exists; +/ +@pe.sql diff --git a/Chapter02/drop_relational.sql b/Chapter02/drop_relational.sql new file mode 100644 index 0000000..4435658 --- /dev/null +++ b/Chapter02/drop_relational.sql @@ -0,0 +1,66 @@ +rem drop_relational.sql +rem by Donald J. Bales on 12/15/2006 +rem Drop the relational tables + +set feedback off; + +rem create the procedure drop_if_exists used in this script + +@drop_if_exists.prc + +rem drop package specs + +exec drop_if_exists('PACKAGE', 'TASK_SUBSTANCE_TS'); +exec drop_if_exists('PACKAGE', 'WORK_TASK_TS'); +exec drop_if_exists('PACKAGE', 'TASK_TS'); +exec drop_if_exists('PACKAGE', 'HAZARD_LEVEL_TS'); +exec drop_if_exists('PACKAGE', 'SUBSTANCE_TS'); +exec drop_if_exists('PACKAGE', 'WORK_ASSIGNMENT_TS'); +exec drop_if_exists('PACKAGE', 'WORK_TS'); +exec drop_if_exists('PACKAGE', 'PHYSICAL_ASSIGNMENT_TS'); +exec drop_if_exists('PACKAGE', 'PHYSICAL_WORKPLACE_TS'); +exec drop_if_exists('PACKAGE', 'LOGICAL_ASSIGNMENT_TS'); +exec drop_if_exists('PACKAGE', 'LOGICAL_WORKPLACE_TS'); +exec drop_if_exists('PACKAGE', 'WORKPLACE_TYPE_TS'); +exec drop_if_exists('PACKAGE', 'WORKER_TS'); +exec drop_if_exists('PACKAGE', 'GENDER_TS'); +exec drop_if_exists('PACKAGE', 'WORKER_TYPE_TS'); + +rem drop relational tables, indexes, and foreign keys + +exec drop_if_exists('TABLE', 'TASK_SUBSTANCE_T'); +exec drop_if_exists('TABLE', 'WORK_TASK_T'); +exec drop_if_exists('TABLE', 'TASK_T'); +exec drop_if_exists('TABLE', 'HAZARD_LEVEL_T'); +exec drop_if_exists('TABLE', 'SUBSTANCE_T'); +exec drop_if_exists('TABLE', 'WORK_ASSIGNMENT_T'); +exec drop_if_exists('TABLE', 'WORK_T'); +exec drop_if_exists('TABLE', 'PHYSICAL_ASSIGNMENT_T'); +exec drop_if_exists('TABLE', 'PHYSICAL_WORKPLACE_T'); +exec drop_if_exists('TABLE', 'LOGICAL_ASSIGNMENT_T'); +exec drop_if_exists('TABLE', 'LOGICAL_WORKPLACE_T'); +exec drop_if_exists('TABLE', 'WORKPLACE_TYPE_T'); +exec drop_if_exists('TABLE', 'WORKER_T'); +exec drop_if_exists('TABLE', 'GENDER_T'); +exec drop_if_exists('TABLE', 'WORKER_TYPE_T'); + +rem drop sequences + +exec drop_if_exists('SEQUENCE', 'TASK_SUBSTANCE_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'WORK_TASK_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'TASK_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'HAZARD_LEVEL_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'SUBSTANCE_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'WORK_ASSIGNMENT_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'WORK_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'PHYSICAL_ASSIGNMENT_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'PHYSICAL_WORKPLACE_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'LOGICAL_ASSIGNMENT_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'LOGICAL_WORKPLACE_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'WORKPLACE_TYPE_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'EXTERNAL_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'WORKER_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'GENDER_ID_SEQ'); +exec drop_if_exists('SEQUENCE', 'WORKER_TYPE_ID_SEQ'); + +set feedback on; diff --git a/Chapter02/fe.sql b/Chapter02/fe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter02/fe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter02/gender_t.ins b/Chapter02/gender_t.ins new file mode 100644 index 0000000..f4393d9 --- /dev/null +++ b/Chapter02/gender_t.ins @@ -0,0 +1,10 @@ +rem gender_t.ins +rem by Donald J. Bales on 12/15/2006 +rem Add code values to the gender table + +insert into GENDER_T ( id, code, description ) values ( GENDER_ID_SEQ.nextval, 'F', 'Female' ); +insert into GENDER_T ( id, code, description ) values ( GENDER_ID_SEQ.nextval, 'M', 'Male' ); +insert into GENDER_T ( id, code, description ) values ( GENDER_ID_SEQ.nextval, 'U', 'Unknown' ); +commit; + +SYS.DBMS_STATS.gather_table_stats(USER, 'GENDER_T'); \ No newline at end of file diff --git a/Chapter02/gender_t.tab b/Chapter02/gender_t.tab new file mode 100644 index 0000000..c0742a7 --- /dev/null +++ b/Chapter02/gender_t.tab @@ -0,0 +1,33 @@ +rem gender_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold gender code values + +--drop table GENDER_T; +create table GENDER_T ( +id number not null, +code varchar2(30) not null, +description varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence GENDER_ID_SEQ; +create sequence GENDER_ID_SEQ +start with 1; + +alter table GENDER_T add +constraint GENDER_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table GENDER_T add +constraint GENDER_UK +unique ( code ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +SYS.DBMS_STATS.gather_table_stats(USER, 'GENDER_T'); diff --git a/Chapter02/hazard_level_t.ins b/Chapter02/hazard_level_t.ins new file mode 100644 index 0000000..bc153e6 --- /dev/null +++ b/Chapter02/hazard_level_t.ins @@ -0,0 +1,13 @@ +rem hazard_level_t.ins +rem by Donald J. Bales on 12/15/2006 +rem Add code values to hazard level + +insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 0, 'N', 'None' ); +insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 2, 'M', 'May Be Bad' ); +insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 4, 'B', 'Bad' ); +insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 6, 'U', 'Unknown' ); +insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 8, 'R', 'Really Bad' ); +insert into HAZARD_LEVEL_T ( id, magnitude, code, description ) values ( HAZARD_LEVEL_ID_SEQ.nextval, 10, 'W', 'Wholly Crap (as not to offend anyone)' ); +commit; + +SYS.DBMS_STATS.gather_table_stats(USER, 'HAZARD_LEVEL_T'); \ No newline at end of file diff --git a/Chapter02/hazard_level_t.tab b/Chapter02/hazard_level_t.tab new file mode 100644 index 0000000..370cbd7 --- /dev/null +++ b/Chapter02/hazard_level_t.tab @@ -0,0 +1,34 @@ +rem hazard_level_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a hazard level code table + +--drop table HAZARD_LEVEL_T; +create table HAZARD_LEVEL_T ( +id number not null, +magnitude number not null, +code varchar2(30) not null, +description varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence HAZARD_LEVEL_ID_SEQ; +create sequence HAZARD_LEVEL_ID_SEQ +start with 1; + +alter table HAZARD_LEVEL_T add +constraint HAZARD_LEVEL_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table HAZARD_LEVEL_T add +constraint HAZARD_LEVEL_UK +unique ( code ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +SYS.DBMS_STATS.gather_table_stats(USER, 'HAZARD_LEVEL_T'); diff --git a/Chapter02/logical_assignment_t.tab b/Chapter02/logical_assignment_t.tab new file mode 100644 index 0000000..600f6fe --- /dev/null +++ b/Chapter02/logical_assignment_t.tab @@ -0,0 +1,45 @@ +rem logical_assignment_t.tab +rem copyright by Donald J. Bales on 12/15/2006 +rem + +--drop table LOGICAL_ASSIGNMENT_T; +create table LOGICAL_ASSIGNMENT_T ( +id number not null, +worker_id number not null, +logical_workplace_id number not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence LOGICAL_ASSIGNMENT_ID_SEQ; +create sequence LOGICAL_ASSIGNMENT_ID_SEQ +start with 1; + +alter table LOGICAL_ASSIGNMENT_T add +constraint LOGICAL_ASSIGNMENT_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table LOGICAL_ASSIGNMENT_T add +constraint LOGICAL_ASSIGNMENT_T_UK +unique ( +worker_id, +active_date ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table LOGICAL_ASSIGNMENT_T add +constraint LOGICAL_ASSIGNMENT_T_FK1 +foreign key ( worker_id ) +references WORKER_T ( id ); + +alter table LOGICAL_ASSIGNMENT_T add +constraint LOGICAL_ASSIGNMENT_T_FK2 +foreign key ( logical_workplace_id ) +references LOGICAL_WORKPLACE_T ( id ); + +SYS.DBMS_STATS.gather_table_stats(USER, 'LOGICAL_ASSIGNMENT_T'); diff --git a/Chapter02/logical_workplace_t.ins b/Chapter02/logical_workplace_t.ins new file mode 100644 index 0000000..75a349e --- /dev/null +++ b/Chapter02/logical_workplace_t.ins @@ -0,0 +1,271 @@ +rem logical_workplace_t.ins +rem by Donald J. Bales on 12/15/2006 +rem Add logical workplaces + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + NULL, + to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'VDMI', + 'VERY DIRTY MANUFACTURING, INC.', + to_date('19800101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t +where t.code = 'C'; + + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'SALE', + 'SALES', + to_date('19800101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'B' +and p.code = 'VDMI' +and p.name = 'VERY DIRTY MANUFACTURING, INC.' +and p.active_date = to_date('19800101', 'YYYYMMDD'); + + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'MKTG', + 'MARKETING', + to_date('19800101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'B' +and p.code = 'VDMI' +and p.name = 'VERY DIRTY MANUFACTURING, INC.' +and p.active_date = to_date('19800101', 'YYYYMMDD'); + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'ACCT', + 'ACCOUNTING', + to_date('19800101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'B' +and p.code = 'VDMI' +and p.name = 'VERY DIRTY MANUFACTURING, INC.' +and p.active_date = to_date('19800101', 'YYYYMMDD'); + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'PDEV', + 'PRODUCT DEVELOPMENT', + to_date('19800101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'B' +and p.code = 'VDMI' +and p.name = 'VERY DIRTY MANUFACTURING, INC.' +and p.active_date = to_date('19800101', 'YYYYMMDD'); + + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'MFG', + 'MANUFACTURING', + to_date('19800101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'B' +and p.code = 'VDMI' +and p.name = 'VERY DIRTY MANUFACTURING, INC.' +and p.active_date = to_date('19800101', 'YYYYMMDD'); + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'CHEM', + 'CHEMICALS', + to_date('19800101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'D' +and p.code = 'MFG' +and p.name = 'MANUFACTURING' +and p.active_date = to_date('19800101', 'YYYYMMDD'); + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'BIO', + 'BIOLOGICALS', + to_date('19800101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'D' +and p.code = 'MFG' +and p.name = 'MANUFACTURING' +and p.active_date = to_date('19800101', 'YYYYMMDD'); + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'METL', + 'METALS', + to_date('19800101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'D' +and p.code = 'MFG' +and p.name = 'MANUFACTURING' +and p.active_date = to_date('19800101', 'YYYYMMDD'); + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'RUSE', + 'REUSABLES', + to_date('19800101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'D' +and p.code = 'MFG' +and p.name = 'MANUFACTURING' +and p.active_date = to_date('19800101', 'YYYYMMDD'); + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'DISP', + 'DISPOSABLES', + to_date('19800101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'D' +and p.code = 'MFG' +and p.name = 'MANUFACTURING' +and p.active_date = to_date('19800101', 'YYYYMMDD'); + + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'HR', + 'HUMAN RESOURCES', + to_date('19800101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'B' +and p.code = 'VDMI' +and p.name = 'VERY DIRTY MANUFACTURING, INC.' +and p.active_date = to_date('19800101', 'YYYYMMDD'); + +commit; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'LOGICAL_WORKPLACE_T'); diff --git a/Chapter02/logical_workplace_t.tab b/Chapter02/logical_workplace_t.tab new file mode 100644 index 0000000..00958eb --- /dev/null +++ b/Chapter02/logical_workplace_t.tab @@ -0,0 +1,58 @@ +rem logical_workplace_t.tab +rem by Donald J. Bales on 12/15/2006 +rem + +--drop table LOGICAL_WORKPLACE_T; +create table LOGICAL_WORKPLACE_T ( +id number not null, +parent_id number, +id_context varchar2(100) not null, +workplace_type_id number not null, +code varchar2(30) not null, +name varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence LOGICAL_WORKPLACE_ID_SEQ; +create sequence LOGICAL_WORKPLACE_ID_SEQ +start with 1; + +alter table LOGICAL_WORKPLACE_T add +constraint LOGICAL_WORKPLACE_T_PK +primary key ( +id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table LOGICAL_WORKPLACE_T add +constraint LOGICAL_WORKPLACE_T_UK1 +unique ( +id_context ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table LOGICAL_WORKPLACE_T add +constraint LOGICAL_WORKPLACE_T_UK2 +unique ( +code, +name, +active_date ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table LOGICAL_WORKPLACE_T add +constraint LOGICAL_WORKPLACE_T_FK1 +foreign key ( parent_id ) +references LOGICAL_WORKPLACE_T ( id ); + +alter table LOGICAL_WORKPLACE_T add +constraint LOGICAL_WORKPLACE_T_FK2 +foreign key ( workplace_type_id ) +references WORKPLACE_TYPE_T ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'LOGICAL_WORKPLACE_T'); diff --git a/Chapter02/logical_workplace_ts.pkb b/Chapter02/logical_workplace_ts.pkb new file mode 100644 index 0000000..bb35bb1 --- /dev/null +++ b/Chapter02/logical_workplace_ts.pkb @@ -0,0 +1,294 @@ +create or replace PACKAGE BODY LOGICAL_WORKPLACE_TS as +/* +logical_workplace_ts.pkb +by Donald J. Bales on 12/15/2006 +Table LOGICAL_WORKPLACE_T's methods +*/ + +-- FORWARD DECLARATIONS + +FUNCTION get_parent_id_context( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE) +return varchar2; + + +-- FUNCTIONS + +FUNCTION create_id_context( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +v_id_context LOGICAL_WORKPLACE_T.id_context%TYPE; + +begin + v_id_context := get_parent_id_context(ain_parent_id); + + if v_id_context is not NULL then + return substr(v_id_context||'.'||to_char(ain_id), 1, 2000); + else + return to_char(ain_id); + end if; +end create_id_context; + + +FUNCTION get_id +return LOGICAL_WORKPLACE_T.id%TYPE is + +n_id LOGICAL_WORKPLACE_T.id%TYPE; + +begin + select LOGICAL_WORKPLACE_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_code_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +cursor c_code_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) is +select upper(code) code +from LOGICAL_WORKPLACE_T +connect by prior parent_id = id +start with id = ain_id +order by level desc; + +v_code_context varchar2(2000); + +begin + for r_code_context in c_code_context(ain_id) loop + v_code_context := substr(v_code_context||'.'||r_code_context.code, 1, 2000); + end loop; + return v_code_context; +end get_code_context; + + +FUNCTION get_name_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +cursor c_name_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) is +select initcap(name) name +from LOGICAL_WORKPLACE_T +connect by prior parent_id = id +start with id = ain_id +order by level desc; + +v_name_context varchar2(2000); + +begin + for r_name_context in c_name_context(ain_id) loop + v_name_context := substr(v_name_context||'.'||r_name_context.name, 1, 2000); + end loop; + return v_name_context; +end get_name_context; + + +FUNCTION get_parent_id_context( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE) +return varchar2 is + +v_id_context LOGICAL_WORKPLACE_T.id_context%TYPE; + +begin + if ain_parent_id is not NULL then + select id_context + into v_id_context + from LOGICAL_WORKPLACE_T + where id = ain_parent_id; + end if; + + return v_id_context; +end get_parent_id_context; + + +FUNCTION get_row( +air_logical_workplace in LOGICAL_WORKPLACE_T%ROWTYPE) +return LOGICAL_WORKPLACE_T%ROWTYPE is + +r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; + +begin + if air_logical_workplace.id is not NULL then + -- retrieve the row by the primary key + select * + into r_logical_workplace + from LOGICAL_WORKPLACE_T + where id = air_logical_workplace.id; + elsif air_logical_workplace.id_context is not NULL then + -- retrieve the row by the id_context unique key + select * + into r_logical_workplace + from LOGICAL_WORKPLACE_T + where id = air_logical_workplace.id_context; + else + -- retrieve the row by the code, name, and active_date + select * + into r_logical_workplace + from LOGICAL_WORKPLACE_T + where code = air_logical_workplace.code + and name = air_logical_workplace.name + and active_date = air_logical_workplace.active_date; + end if; + return r_logical_workplace; +exception + when NO_DATA_FOUND then + raise; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select LOGICAL_WORKPLACE_T'|| + ' in LOGICAL_WORKPLACE_TS.get_row()'); +end get_row; + + +FUNCTION set_row( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +ain_workplace_type_id in LOGICAL_WORKPLACE_T.workplace_type_id%TYPE, +aiv_code in LOGICAL_WORKPLACE_T.code%TYPE, +aiv_name in LOGICAL_WORKPLACE_T.name%TYPE, +aid_active_date in LOGICAL_WORKPLACE_T.active_date%TYPE) +return LOGICAL_WORKPLACE_T.id%TYPE is + +r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; + +begin + r_logical_workplace.id := NULL; + r_logical_workplace.id_context := NULL; + r_logical_workplace.parent_id := ain_parent_id; + r_logical_workplace.workplace_type_id := ain_workplace_type_id; + r_logical_workplace.code := aiv_code; + r_logical_workplace.name := aiv_name; + r_logical_workplace.active_date := aid_active_date; + set_row(r_logical_workplace); + + return r_logical_workplace.id; +end set_row; + + +-- PROCEDURES + +PROCEDURE help is + +begin +-- 12345678901234567890123456789012345678901234567890123456789012345678901234567890 +pl(' +=================================== PACKAGE ==================================== + +LOGICAL_WORKPLACE_TS + +----------------------------------- FUNCTIONS ---------------------------------- + + + This line should be indented. + +This line shouldn''t. '); +end help; + + +PROCEDURE set_row( +aior_logical_workplace in out LOGICAL_WORKPLACE_T%ROWTYPE) is + +d_null constant date := DATES.d_MIN; +n_null constant number := 0; +v_null constant varchar2(1) := ' '; +r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; + +begin + -- get the existing row + begin + r_logical_workplace := get_row(aior_logical_workplace); + exception + when NO_DATA_FOUND then + r_logical_workplace := NULL; + end; + -- if a row exists, update it if needed + if r_logical_workplace.id is not NULL then + aior_logical_workplace.id := r_logical_workplace.id; + aior_logical_workplace.parent_id := r_logical_workplace.parent_id; + aior_logical_workplace.id_context := r_logical_workplace.id_context; + if nvl(r_logical_workplace.workplace_type_id, n_null) <> nvl(aior_logical_workplace.workplace_type_id, n_null) or + nvl(r_logical_workplace.code, v_null) <> nvl(aior_logical_workplace.code, v_null) or + nvl(r_logical_workplace.name, v_null) <> nvl(aior_logical_workplace.name, v_null) or + nvl(r_logical_workplace.active_date, d_null) <> nvl(aior_logical_workplace.active_date, d_null) or + nvl(r_logical_workplace.inactive_date, d_null) <> nvl(aior_logical_workplace.inactive_date, d_null) then + begin + update LOGICAL_WORKPLACE_T + set workplace_type_id = aior_logical_workplace.workplace_type_id, + code = aior_logical_workplace.code, + name = aior_logical_workplace.name, + active_date = aior_logical_workplace.active_date, + inactive_date = aior_logical_workplace.inactive_date + where id = aior_logical_workplace.id; + + n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20002, SQLERRM|| + ' on update LOGICAL_WORKPLACE_T'|| + ' in LOGICAL_WORKPLACE_TS.set_row()' ); + end; + end if; + else + -- add the row if it does not exist + begin + aior_logical_workplace.id := get_id(); + aior_logical_workplace.id_context := create_id_context( + aior_logical_workplace.parent_id, + aior_logical_workplace.id ); + insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date, + inactive_date ) + values ( + aior_logical_workplace.id, + aior_logical_workplace.parent_id, + aior_logical_workplace.id_context, + aior_logical_workplace.workplace_type_id, + aior_logical_workplace.code, + aior_logical_workplace.name, + aior_logical_workplace.active_date, + aior_logical_workplace.inactive_date ); + + n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20003, SQLERRM|| + ' on insert LOGICAL_WORKPLACE_T'|| + ' in LOGICAL_WORKPLACE_TS.set_row()' ); + end; + end if; +end set_row; + + +PROCEDURE test is + +begin + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('LOGICAL_WORKPLACE_TS'); + pl(chr(9)); +-- pl('1. Testing constants d_MIN and d_MAX'); +-- if d_MIN < d_MAX then +-- pl('SUCCESS'); +-- else +-- pl('ERROR: d_MIN is not less than d_MAX'); +-- end if; + pl(chr(9)||'No tests for LOGICAL_WORKPLACE_TS at this time'); +end test; + + +end LOGICAL_WORKPLACE_TS; +/ +@be.sql LOGICAL_WORKPLACE_TS + diff --git a/Chapter02/logical_workplace_ts.pks b/Chapter02/logical_workplace_ts.pks new file mode 100644 index 0000000..4f63515 --- /dev/null +++ b/Chapter02/logical_workplace_ts.pks @@ -0,0 +1,112 @@ +create or replace PACKAGE LOGICAL_WORKPLACE_TS as +/* +logical_workplace_ts.pks
+by Donald J. Bales on 12/15/2006
+Table LOGICAL_WORKPLACE_T's methods. Contains all the supporting service +methods (functions and procedures) for table LOGICAL_WORKPLACE_T. +*/ + +-- GLOBAL VARIABLES + +-- Keep track of the number of inserts and updates to made by set_row( ). +n_inserted number := 0; +n_updated number := 0; + + +/* +Returns an id_context for the specified parent_id and id. +Whatever creates a new row must also call this mehtod to create an appropriate +id_context value. Method set_row( ) does this for you. +*/ +FUNCTION create_id_context( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2; + + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return LOGICAL_WORKPLACE_T.id%TYPE; + + +/* +Returns the value of a context for the code values in the logical workplace assignment. +*/ +FUNCTION get_code_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2; + + +/* +Returns the value of a context for the name values in the logical workplace assignment. +*/ +FUNCTION get_name_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2; + + +/* +Returns a LOGICAL_WORKPLACE row for the specified criteria. + +There are three sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the unique id_context
+3. the code, name, and active_date
+ +If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_logical_workplace in LOGICAL_WORKPLACE_T%ROWTYPE) +return LOGICAL_WORKPLACE_T%ROWTYPE; + + +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + + +/* +Updates or inserts a row matching the passed parameters into table LOGICAL_WORKPLACE_T. +See PROCEDURE set_row( ). +*/ +FUNCTION set_row( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +ain_workplace_type_id in LOGICAL_WORKPLACE_T.workplace_type_id%TYPE, +aiv_code in LOGICAL_WORKPLACE_T.code%TYPE, +aiv_name in LOGICAL_WORKPLACE_T.name%TYPE, +aid_active_date in LOGICAL_WORKPLACE_T.active_date%TYPE) +return LOGICAL_WORKPLACE_T.id%TYPE; + + +/* +Updates or inserts a row matching the passed row into table LOGICAL_WORKPLACE_T. + +First, set_row() calls get row to try to find a matching row that already +exists in the database. So you need to set the id, id_context, +and code, name and active_date appropriately in order to prperly detect an +existing row. + +Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise, and new row is inserted, including the allocation of +a new primary key and id_context value. Upon inserting a new value, the +id and id_context values are updated in the passed row. +See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_logical_workplace in out LOGICAL_WORKPLACE_T%ROWTYPE); + + +/* +Performs unit tests for this package. +*/ +PROCEDURE test; + + +end LOGICAL_WORKPLACE_TS; +/ +@se.sql LOGICAL_WORKPLACE_TS + diff --git a/Chapter02/login.sql b/Chapter02/login.sql new file mode 100644 index 0000000..dfde68b --- /dev/null +++ b/Chapter02/login.sql @@ -0,0 +1,10 @@ +rem login.sql +rem by Don Bales on 12/15/2006 +rem Set my default SQL*Plus environment +set linesize 1000; +set newpage 1; +set pagesize 32767; +set serveroutput on size 1000000; +set trimspool on; +alter session set nls_date_format = 'SYYYYMMDD HH24MISS'; +prompt BPS' default settings loaded successfully! diff --git a/Chapter02/pe.sql b/Chapter02/pe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter02/pe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter02/physical_assignment_t.tab b/Chapter02/physical_assignment_t.tab new file mode 100644 index 0000000..b100e07 --- /dev/null +++ b/Chapter02/physical_assignment_t.tab @@ -0,0 +1,45 @@ +rem physical_assignment_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold physical workplace assignments + +--drop table PHYSICAL_ASSIGNMENT_T; +create table PHYSICAL_ASSIGNMENT_T ( +id number not null, +worker_id number not null, +physical_workplace_id number not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence PHYSICAL_ASSIGNMENT_ID_SEQ; +create sequence PHYSICAL_ASSIGNMENT_ID_SEQ +start with 1; + +alter table PHYSICAL_ASSIGNMENT_T add +constraint PHYSICAL_ASSIGNMENT_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table PHYSICAL_ASSIGNMENT_T add +constraint PHYSICAL_ASSIGNMENT_T_UK +unique ( +worker_id, +active_date ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table PHYSICAL_ASSIGNMENT_T add +constraint PHYSICAL_ASSIGNMENT_T_FK1 +foreign key ( worker_id ) +references WORKER_T ( id ); + +alter table PHYSICAL_ASSIGNMENT_T add +constraint PHYSICAL_ASSIGNMENT_T_FK2 +foreign key ( physical_workplace_id ) +references PHYSICAL_WORKPLACE_T ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'PHYSICAL_ASSIGNMENT_T'); diff --git a/Chapter02/physical_workplace_t.tab b/Chapter02/physical_workplace_t.tab new file mode 100644 index 0000000..03afb13 --- /dev/null +++ b/Chapter02/physical_workplace_t.tab @@ -0,0 +1,46 @@ +rem physical_workplace_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold physical workplaces + +--drop table PHYSICAL_WORKPLACE_T; +create table PHYSICAL_WORKPLACE_T ( +id number not null, +workplace_type_id number not null, +id_context varchar2(100) not null, +parent_id number, +code varchar2(30) not null, +name varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence PHYSICAL_WORKPLACE_ID_SEQ; +create sequence PHYSICAL_WORKPLACE_ID_SEQ +start with 1; + +alter table PHYSICAL_WORKPLACE_T add +constraint PHYSICAL_WORKPLACE_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table PHYSICAL_WORKPLACE_T add +constraint PHYSICAL_WORKPLACE_T_UK +unique ( id_context ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table PHYSICAL_WORKPLACE_T add +constraint PHYSICAL_WORKPLACE_T_FK1 +foreign key ( parent_id ) +references PHYSICAL_WORKPLACE_T ( id ); + +alter table PHYSICAL_WORKPLACE_T add +constraint PHYSICAL_WORKPLACE_T_FK2 +foreign key ( workplace_type_id ) +references WORKPLACE_TYPE_T ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'PHYSICAL_WORKPLACE_T'); diff --git a/Chapter02/pl.prc b/Chapter02/pl.prc new file mode 100644 index 0000000..10b8e34 --- /dev/null +++ b/Chapter02/pl.prc @@ -0,0 +1,14 @@ +create or replace PROCEDURE pl( +aiv_text in varchar2 ) is +/* +pl.prc +by Donald J. Bales on 12/15/2006 +A wrapper procedure for SYS.DBMS_OUTPUT.put_line() +for the lazy typist. +*/ + +begin + SYS.DBMS_OUTPUT.put_line(aiv_text); +end pl; +/ +@pe.sql pl diff --git a/Chapter02/pl.sql b/Chapter02/pl.sql new file mode 100644 index 0000000..587dcf7 --- /dev/null +++ b/Chapter02/pl.sql @@ -0,0 +1,24 @@ +rem pl.sql +rem by Donald J. Bales on 12/15/2006 +rem pl's test unit + +prompt 'Test a line <= 255'; -- 20 21 22 23 24 25 +exec pl('12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '1234567890123456789012345678901234567890123456789012345'); +prompt 'Test a line > 255'; +exec pl('12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'); +prompt 'Test a multi-line'; +exec pl('12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'||chr(10)|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'||chr(10)|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'); diff --git a/Chapter02/pl2.sql b/Chapter02/pl2.sql new file mode 100644 index 0000000..f0647f7 --- /dev/null +++ b/Chapter02/pl2.sql @@ -0,0 +1,41 @@ +rem pl2.sql +rem by Donald J. Bales on 12/15/2006 +rem Test unit for procedure pl + +begin + pl('Test a line of text.'); + pl('Test a number, such as 1?'); + pl(1); + pl('Test a date, such as 01/01/1980?'); + pl(to_date('19800101', 'YYYYMMDD')); + pl('Test a line <= 255'); + pl('12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '1234567890123456789012345678901234567890123456789012345'); + pl('Test a line > 255'); + begin + pl('12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890123456'); + exception + when OTHERS then + pl(SQLERRM); + end; + pl('Test a multi-line'); + begin + pl('12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'||chr(10)|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'||chr(10)|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'); + exception + when OTHERS then + pl(SQLERRM); + end; +end; +/ diff --git a/Chapter02/se.sql b/Chapter02/se.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter02/se.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter02/solutions/numbers.pkb b/Chapter02/solutions/numbers.pkb new file mode 100644 index 0000000..1604562 --- /dev/null +++ b/Chapter02/solutions/numbers.pkb @@ -0,0 +1,20 @@ +create or replace package body NUMBERS as +/* +numbers.pkb +by Donald J. Bales on 12/15/2006 +A utility package for the data type NUMBER +*/ + +FUNCTION to_number_or_null ( +aiv_number in varchar2 ) +return number is +begin + return to_number(aiv_number); +exception + when OTHERS then + return NULL; +end to_number_or_null; + +end NUMBERS; +/ +@be.sql diff --git a/Chapter02/solutions/numbers.pks b/Chapter02/solutions/numbers.pks new file mode 100644 index 0000000..2f3b7fa --- /dev/null +++ b/Chapter02/solutions/numbers.pks @@ -0,0 +1,18 @@ +create or replace package NUMBERS as +/* +numbers.pks +by Donald J. Bales on 12/15/2006 +A utility package for the data type NUMBER +*/ + +/* +Returns the passed varchar2 as a number if it represents a number, +otherwise, it returns NULL +*/ +FUNCTION to_number_or_null ( +aiv_number in varchar2 ) +return number; + +end NUMBERS; +/ +@se.sql diff --git a/Chapter02/solutions/pl.prc b/Chapter02/solutions/pl.prc new file mode 100644 index 0000000..10b8e34 --- /dev/null +++ b/Chapter02/solutions/pl.prc @@ -0,0 +1,14 @@ +create or replace PROCEDURE pl( +aiv_text in varchar2 ) is +/* +pl.prc +by Donald J. Bales on 12/15/2006 +A wrapper procedure for SYS.DBMS_OUTPUT.put_line() +for the lazy typist. +*/ + +begin + SYS.DBMS_OUTPUT.put_line(aiv_text); +end pl; +/ +@pe.sql pl diff --git a/Chapter02/solutions/pl.sql b/Chapter02/solutions/pl.sql new file mode 100644 index 0000000..cf3de8a --- /dev/null +++ b/Chapter02/solutions/pl.sql @@ -0,0 +1,31 @@ +rem pl.sql +rem by Donald J. Bales on 12/15/2006 +rem Test unit for procedure pl + +begin + pl('Test a line of text.'); + pl('Test a number, such as 1?'); + pl(1); + pl('Test a date, such as 01/01/1980?'); + pl(to_date('19800101', 'YYYYMMDD')); + pl('Test a line <= 255'); + pl('12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '1234567890123456789012345678901234567890123456789012345'); + pl('Test a line > 255'); + pl('12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890123456'); + pl('Test a multi-line'); + pl('12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'||chr(10)|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'||chr(10)|| + '12345678901234567890123456789012345678901234567890'|| + '12345678901234567890123456789012345678901234567890'); +end; +/ diff --git a/Chapter02/solutions/to_mmsddsyyyy_or_null.fun b/Chapter02/solutions/to_mmsddsyyyy_or_null.fun new file mode 100644 index 0000000..2f576e9 --- /dev/null +++ b/Chapter02/solutions/to_mmsddsyyyy_or_null.fun @@ -0,0 +1,27 @@ +create or replace FUNCTION to_mmsddsyyyy_or_null ( +aiv_date in varchar2 ) +return date is +/* +to_mmsddsyyyy_or_null.fun +by Donald J. Bales on 12/15/2006 +An errorless to_date( ) method +*/ +begin + return to_date(aiv_date, 'MM/DD/YYYY'); +exception + /* + There are too many possible errors, for example: + ORA-01830: date format picture ends before + converting entire input string + ORA-01843: not a valid month + ORA-01847: day of month must be between 1 + and last day of month + ORA-01858: a non-numeric character was found + where a numeric was expected + so I used the exception OTHERS + */ + when OTHERS then + return NULL; +end to_mmsddsyyyy_or_null; +/ +@fe.sql to_mmsddsyyyy_or_null; diff --git a/Chapter02/solutions/to_mmsddsyyyy_or_null.sql b/Chapter02/solutions/to_mmsddsyyyy_or_null.sql new file mode 100644 index 0000000..bb11f33 --- /dev/null +++ b/Chapter02/solutions/to_mmsddsyyyy_or_null.sql @@ -0,0 +1,14 @@ +rem to_mmsddsyyyy_or_null.sql +rem by Donald J. Bales on 12/15/2006 +rem FUNCTION to_mmsddsyyyy_or_null() test unit + +alter session set nls_date_format = 'SYYYYMMDD HH24MISS'; +begin + sys.dbms_output.put_line(to_mmsddsyyyy_or_null('01/01/1980')); + sys.dbms_output.put_line(to_mmsddsyyyy_or_null('02/29/1980')); + sys.dbms_output.put_line(to_mmsddsyyyy_or_null('02/29/1981')); + sys.dbms_output.put_line(to_mmsddsyyyy_or_null('9/9/2006')); + sys.dbms_output.put_line(to_mmsddsyyyy_or_null('9/9/9999')); + sys.dbms_output.put_line(to_mmsddsyyyy_or_null('1/1/4712 BC')); +end; +/ diff --git a/Chapter02/sqlnet.log b/Chapter02/sqlnet.log new file mode 100644 index 0000000..7a8ecc7 --- /dev/null +++ b/Chapter02/sqlnet.log @@ -0,0 +1,18 @@ + + +*********************************************************************** +Fatal NI connect error 12514, connecting to: + (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xp1.donaldbales.com)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ora1020)(CID=(PROGRAM=C:\oracle\product\10.2.0\db_1\BIN\sqlplusw.exe)(HOST=XP1)(USER=balesd)))) + + VERSION INFORMATION: + TNS for 32-bit Windows: Version 10.2.0.1.0 - Production + Windows NT TCP/IP NT Protocol Adapter for 32-bit Windows: Version 10.2.0.1.0 - Production + Time: 07-JUN-2007 22:09:19 + Tracing not turned on. + Tns error struct: + ns main err code: 12564 + TNS-12564: TNS:connection refused + ns secondary err code: 0 + nt main err code: 0 + nt secondary err code: 0 + nt OS err code: 0 diff --git a/Chapter02/substance_t.ins b/Chapter02/substance_t.ins new file mode 100644 index 0000000..bc7f59a --- /dev/null +++ b/Chapter02/substance_t.ins @@ -0,0 +1,1584 @@ +rem substance_t.ins +rem by Donald J. Bales on 12/15/2006 +rem Add substances + +set define off; + +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-00-0', 'Formaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-00-0' and x.name = 'Formaldehyde' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-07-7', 'Mitomycin C', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-07-7' and x.name = 'Mitomycin C' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-18-0', 'Cyclophosphamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-18-0' and x.name = 'Cyclophosphamide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-27-1', 'Estriol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-27-1' and x.name = 'Estriol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-28-2', 'Estradiol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-28-2' and x.name = 'Estradiol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-29-3', 'DDT', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-29-3' and x.name = 'DDT' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-32-8', 'Benzo (alpha) Pyrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-32-8' and x.name = 'Benzo (alpha) Pyrene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-36-2', 'Cocaine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-36-2' and x.name = 'Cocaine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-78-2', 'Acetylsalicylic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-78-2' and x.name = 'Acetylsalicylic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '50-96-4', 'Bronkosol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '50-96-4' and x.name = 'Bronkosol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '51-03-6', 'Piperonyl Butoxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '51-03-6' and x.name = 'Piperonyl Butoxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '51-21-8', '5-Fluorouracil', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '51-21-8' and x.name = '5-Fluorouracil' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '51-48-9', 'L-thyroxine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '51-48-9' and x.name = 'L-thyroxine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '52-68-6', 'Trichlorfon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '52-68-6' and x.name = 'Trichlorfon' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '53-16-7', 'Estrone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '53-16-7' and x.name = 'Estrone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '53-43-0', 'Dehydroisoandrosterone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '53-43-0' and x.name = 'Dehydroisoandrosterone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '53-70-3', 'Dibenz(a,h)anthracene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '53-70-3' and x.name = 'Dibenz(a,h)anthracene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '53-96-3', '2-Acetylaminofluorene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '53-96-3' and x.name = '2-Acetylaminofluorene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '54-11-5', 'Nicotine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '54-11-5' and x.name = 'Nicotine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '55-18-5', 'N-Nitrosodiethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '55-18-5' and x.name = 'N-Nitrosodiethylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '55-38-9', 'Fenthion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '55-38-9' and x.name = 'Fenthion' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '55-63-0', 'Nitroglycerin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '55-63-0' and x.name = 'Nitroglycerin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-23-5', 'Carbon Tetrachloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-23-5' and x.name = 'Carbon Tetrachloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-35-9', 'Bis(Tributyltin) Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-35-9' and x.name = 'Bis(Tributyltin) Oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-38-2', 'Parathion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-38-2' and x.name = 'Parathion' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-49-5', '3-Methylcholanthrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-49-5' and x.name = '3-Methylcholanthrene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-55-3', 'Benz(a)Anthracene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-55-3' and x.name = 'Benz(a)Anthracene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-72-4', 'Co-Ral', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-72-4' and x.name = 'Co-Ral' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-75-7', 'Chloramphenicol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-75-7' and x.name = 'Chloramphenicol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-81-5', 'Glycerin Mist (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-81-5' and x.name = 'Glycerin Mist (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '56-81-5', 'Glycerin Mist (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '56-81-5' and x.name = 'Glycerin Mist (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-11-4', 'Stearic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-11-4' and x.name = 'Stearic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-12-5', 'Cyanide (as Cn)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-12-5' and x.name = 'Cyanide (as Cn)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-13-6', 'Urea', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-13-6' and x.name = 'Urea' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-14-7', '1,1-Dimethylhydrazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-14-7' and x.name = '1,1-Dimethylhydrazine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-24-9', 'Strychnine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-24-9' and x.name = 'Strychnine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-39-6', 'Tris(2-Methyl-1-aziridinyl)phosphine Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-39-6' and x.name = 'Tris(2-Methyl-1-aziridinyl)phosphine Oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-41-0', '5,5-Diphenylhydantoin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-41-0' and x.name = '5,5-Diphenylhydantoin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-50-1', 'Sucrose (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-50-1' and x.name = 'Sucrose (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-50-1', 'Sucrose (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-50-1' and x.name = 'Sucrose (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-55-6', 'Propylene Glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-55-6' and x.name = 'Propylene Glycol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-57-8', 'beta-Propiolactone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-57-8' and x.name = 'beta-Propiolactone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-68-1', 'Sulfamethazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-68-1' and x.name = 'Sulfamethazine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-74-9', 'Chlordane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-74-9' and x.name = 'Chlordane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57-83-0', 'Progesterone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57-83-0' and x.name = 'Progesterone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '58-14-0', 'Pyrimethamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '58-14-0' and x.name = 'Pyrimethamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '58-18-4', '17-alpha-Methyl Testosterone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '58-18-4' and x.name = '17-alpha-Methyl Testosterone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '58-22-0', 'Testosterone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '58-22-0' and x.name = 'Testosterone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '58-27-5', 'Menadione', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '58-27-5' and x.name = 'Menadione' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '58-89-9', 'Lindane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '58-89-9' and x.name = 'Lindane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '59-05-2', 'Methotrexate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '59-05-2' and x.name = 'Methotrexate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '59-50-7', '4-Chloro-3-methylphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '59-50-7' and x.name = '4-Chloro-3-methylphenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '59-87-0', '5-Nitro-2-furaldehyde Semicarbazone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '59-87-0' and x.name = '5-Nitro-2-furaldehyde Semicarbazone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '59-89-2', 'N-Nitrosomorpholine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '59-89-2' and x.name = 'N-Nitrosomorpholine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-09-3', 'p-Aminoazobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-09-3' and x.name = 'p-Aminoazobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-11-7', '4-Dimethylaminoazobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-11-7' and x.name = '4-Dimethylaminoazobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-12-8', 'Phenethyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-12-8' and x.name = 'Phenethyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-24-2', 'Mercaptoethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-24-2' and x.name = 'Mercaptoethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-29-7', 'Ethyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-29-7' and x.name = 'Ethyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-34-4', 'Monomethyl Hydrazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-34-4' and x.name = 'Monomethyl Hydrazine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-35-5', 'Acetamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-35-5' and x.name = 'Acetamide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-51-5', 'Dimethoate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-51-5' and x.name = 'Dimethoate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60-57-1', 'Dieldrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60-57-1' and x.name = 'Dieldrin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '61-82-5', 'Amitrole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '61-82-5' and x.name = 'Amitrole' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '62-53-3', 'Aniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '62-53-3' and x.name = 'Aniline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '62-56-6', 'Thiourea', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '62-56-6' and x.name = 'Thiourea' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '62-73-7', 'Dichlorvos (DDVP)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '62-73-7' and x.name = 'Dichlorvos (DDVP)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '62-74-8', 'Sodium Fluoroacetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '62-74-8' and x.name = 'Sodium Fluoroacetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '62-75-9', 'N-Nitrosodimethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '62-75-9' and x.name = 'N-Nitrosodimethylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '63-25-2', 'Carbaryl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '63-25-2' and x.name = 'Carbaryl' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '64-17-5', 'Ethyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '64-17-5' and x.name = 'Ethyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '64-18-6', 'Formic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '64-18-6' and x.name = 'Formic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '64-19-7', 'Acetic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '64-19-7' and x.name = 'Acetic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '64-67-5', 'Diethyl Sulfate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '64-67-5' and x.name = 'Diethyl Sulfate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '65-85-0', 'Benzoic acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '65-85-0' and x.name = 'Benzoic acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '66-75-1', 'Uracil Mustard', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '66-75-1' and x.name = 'Uracil Mustard' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '67-56-1', 'Methyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '67-56-1' and x.name = 'Methyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '67-63-0', 'Isopropyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '67-63-0' and x.name = 'Isopropyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '67-64-1', 'Acetone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '67-64-1' and x.name = 'Acetone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '67-66-3', 'Chloroform', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '67-66-3' and x.name = 'Chloroform' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '67-68-5', 'Dimethyl Sulfoxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '67-68-5' and x.name = 'Dimethyl Sulfoxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '67-72-1', 'Hexachloroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '67-72-1' and x.name = 'Hexachloroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68-11-1', 'Thioglycolic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68-11-1' and x.name = 'Thioglycolic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68-12-2', 'Dimethylformamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68-12-2' and x.name = 'Dimethylformamide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68-22-4', 'Norethindrone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68-22-4' and x.name = 'Norethindrone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68-35-9', 'Sulfadiazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68-35-9' and x.name = 'Sulfadiazine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '71-23-8', 'Propyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '71-23-8' and x.name = 'Propyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '71-36-3', 'n-Butyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '71-36-3' and x.name = 'n-Butyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '71-41-0', 'n-Amyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '71-41-0' and x.name = 'n-Amyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '71-43-2', 'Benzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '71-43-2' and x.name = 'Benzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '71-48-7', 'Cobalt Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '71-48-7' and x.name = 'Cobalt Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '71-55-6', 'Methyl Chloroform', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '71-55-6' and x.name = 'Methyl Chloroform' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '72-20-8', 'Endrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '72-20-8' and x.name = 'Endrin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '72-33-3', 'Mestranol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '72-33-3' and x.name = 'Mestranol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '72-43-5', 'Methoxychlor (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '72-43-5' and x.name = 'Methoxychlor (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '72-54-8', 'Dichlorodiphenyldichloroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '72-54-8' and x.name = 'Dichlorodiphenyldichloroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '72-55-9', 'p,p''-Dichlorodiphenyldichloroethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '72-55-9' and x.name = 'p,p''-Dichlorodiphenyldichloroethylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-82-8', 'Methane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-82-8' and x.name = 'Methane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-83-9', 'Methyl Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-83-9' and x.name = 'Methyl Bromide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-84-0', 'Ethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-84-0' and x.name = 'Ethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-85-1', 'Ethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-85-1' and x.name = 'Ethylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-86-2', 'Acetylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-86-2' and x.name = 'Acetylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-87-3', 'Methyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-87-3' and x.name = 'Methyl Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-88-4', 'Methyl Iodide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-88-4' and x.name = 'Methyl Iodide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-89-5', 'Methylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-89-5' and x.name = 'Methylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-90-8', 'Hydrogen Cyanide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-90-8' and x.name = 'Hydrogen Cyanide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-93-1', 'Methyl Mercaptan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-93-1' and x.name = 'Methyl Mercaptan' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-96-4', 'Ethyl Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-96-4' and x.name = 'Ethyl Bromide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-97-5', 'Chlorobromomethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-97-5' and x.name = 'Chlorobromomethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-98-6', 'Propane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-98-6' and x.name = 'Propane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '74-99-7', 'Methyl Acetylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '74-99-7' and x.name = 'Methyl Acetylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-00-3', 'Ethyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-00-3' and x.name = 'Ethyl Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-01-4', 'Vinyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-01-4' and x.name = 'Vinyl Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-02-5', 'Vinyl fluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-02-5' and x.name = 'Vinyl fluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-04-7', 'Ethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-04-7' and x.name = 'Ethylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-05-8', 'Acetonitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-05-8' and x.name = 'Acetonitrile' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-07-0', 'Acetaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-07-0' and x.name = 'Acetaldehyde' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-08-1', 'Ethyl Mercaptan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-08-1' and x.name = 'Ethyl Mercaptan' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-09-2', 'Methylene Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-09-2' and x.name = 'Methylene Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-12-7', 'Formamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-12-7' and x.name = 'Formamide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-15-0', 'Carbon Disulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-15-0' and x.name = 'Carbon Disulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-18-3', 'Dimethyl Sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-18-3' and x.name = 'Dimethyl Sulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-21-8', 'Ethylene Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-21-8' and x.name = 'Ethylene Oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-25-2', 'Bromoform', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-25-2' and x.name = 'Bromoform' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-26-3', '2-Bromopropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-26-3' and x.name = '2-Bromopropane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-28-5', 'Isobutane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-28-5' and x.name = 'Isobutane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-31-0', 'Isopropylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-31-0' and x.name = 'Isopropylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-33-2', 'Isopropyl Mercaptan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-33-2' and x.name = 'Isopropyl Mercaptan' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-34-3', '1,1-Dichloroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-34-3' and x.name = '1,1-Dichloroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-35-4', 'Vinylidene Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-35-4' and x.name = 'Vinylidene Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-36-5', 'Acetyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-36-5' and x.name = 'Acetyl Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-37-6', '1,1-Difluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-37-6' and x.name = '1,1-Difluoroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-38-7', 'Vinylidene Fluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-38-7' and x.name = 'Vinylidene Fluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-43-4', 'Dichloromonofluoromethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-43-4' and x.name = 'Dichloromonofluoromethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-44-5', 'Phosgene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-44-5' and x.name = 'Phosgene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-45-6', 'Chlorodifluoromethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-45-6' and x.name = 'Chlorodifluoromethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-47-8', 'Iodoform', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-47-8' and x.name = 'Iodoform' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-50-3', 'Trimethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-50-3' and x.name = 'Trimethylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-52-5', 'Nitromethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-52-5' and x.name = 'Nitromethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-55-8', 'Propylene Imine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-55-8' and x.name = 'Propylene Imine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-56-9', 'Propylene Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-56-9' and x.name = 'Propylene Oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-61-6', 'Difluorodibromomethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-61-6' and x.name = 'Difluorodibromomethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-63-8', 'Trifluoromonobromomethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-63-8' and x.name = 'Trifluoromonobromomethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-65-0', 'tert-Butyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-65-0' and x.name = 'tert-Butyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-66-1', 't-Butylmercaptan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-66-1' and x.name = 't-Butylmercaptan' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-69-4', 'Fluorotrichloromethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-69-4' and x.name = 'Fluorotrichloromethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-71-8', 'Dichlorodifluoromethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-71-8' and x.name = 'Dichlorodifluoromethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-73-0', 'Carbon Tetrafluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-73-0' and x.name = 'Carbon Tetrafluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-74-1', 'Tetramethyl Lead (as Pb)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-74-1' and x.name = 'Tetramethyl Lead (as Pb)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-75-2', 'Methanesulfonic acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-75-2' and x.name = 'Methanesulfonic acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-85-4', 't-Amyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-85-4' and x.name = 't-Amyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-89-8', '2,2,2-Trifluoroethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-89-8' and x.name = '2,2,2-Trifluoroethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '75-99-0', '2,2-Dichloropropionic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '75-99-0' and x.name = '2,2-Dichloropropionic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-01-7', 'Pentachloroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-01-7' and x.name = 'Pentachloroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-03-9', 'Trichloroacetic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-03-9' and x.name = 'Trichloroacetic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-06-2', 'Chloropicrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-06-2' and x.name = 'Chloropicrin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-11-9', '1,1,1,2-Tetrachloro-2,2-Difluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-11-9' and x.name = '1,1,1,2-Tetrachloro-2,2-Difluoroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-12-0', '1,1,2,2-Tetrachloro-1,2-Difluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-12-0' and x.name = '1,1,2,2-Tetrachloro-1,2-Difluoroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-13-1', '1,1,2-Trichloro-1,2,2-Trifluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-13-1' and x.name = '1,1,2-Trichloro-1,2,2-Trifluoroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-14-2', 'Dichlorotetrafluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-14-2' and x.name = 'Dichlorotetrafluoroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-15-3', 'Chloropentafluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-15-3' and x.name = 'Chloropentafluoroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-22-2', 'Camphor', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-22-2' and x.name = 'Camphor' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-25-5', 'Triamcinolone acetonide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-25-5' and x.name = 'Triamcinolone acetonide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-38-0', 'Methoxyflurane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-38-0' and x.name = 'Methoxyflurane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-44-8', 'Heptachlor', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-44-8' and x.name = 'Heptachlor' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '76-87-9', 'Triphenyltin Hydroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '76-87-9' and x.name = 'Triphenyltin Hydroxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '77-47-4', 'Hexachlorocyclopentadiene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '77-47-4' and x.name = 'Hexachlorocyclopentadiene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '77-58-7', 'Dibutyltin Dilaurate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '77-58-7' and x.name = 'Dibutyltin Dilaurate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '77-76-9', '2,2-Dimethoxypropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '77-76-9' and x.name = '2,2-Dimethoxypropane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '77-78-1', 'Dimethyl Sulfate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '77-78-1' and x.name = 'Dimethyl Sulfate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '77-92-9', 'Citric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '77-92-9' and x.name = 'Citric Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-00-2', 'Tetraethyl Lead (as Pb)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-00-2' and x.name = 'Tetraethyl Lead (as Pb)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-04-6', 'Dibutyltin Maleate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-04-6' and x.name = 'Dibutyltin Maleate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-10-4', 'Ethyl Silicate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-10-4' and x.name = 'Ethyl Silicate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-11-5', 'Pentaerythritol Tetranitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-11-5' and x.name = 'Pentaerythritol Tetranitrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-30-8', 'Triorthocresyl Phosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-30-8' and x.name = 'Triorthocresyl Phosphate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-34-2', 'Dioxathion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-34-2' and x.name = 'Dioxathion' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-40-0', 'Triethyl Phosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-40-0' and x.name = 'Triethyl Phosphate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-44-4', 'Carisoprodol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-44-4' and x.name = 'Carisoprodol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-48-8', 'Tributylphosphorotrithioate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-48-8' and x.name = 'Tributylphosphorotrithioate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-59-1', 'Isophorone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-59-1' and x.name = 'Isophorone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-78-4', '2-Methylbutane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-78-4' and x.name = '2-Methylbutane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-81-9', 'Isobutylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-81-9' and x.name = 'Isobutylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-82-0', 'Isobutyronitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-82-0' and x.name = 'Isobutyronitrile' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-83-1', 'Isobutyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-83-1' and x.name = 'Isobutyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-84-2', 'Isobutyraldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-84-2' and x.name = 'Isobutyraldehyde' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-87-5', 'Propylene Dichloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-87-5' and x.name = 'Propylene Dichloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-90-0', 'Propylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-90-0' and x.name = 'Propylenediamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-92-2', 'sec-Butyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-92-2' and x.name = 'sec-Butyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-93-3', '2-Butanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-93-3' and x.name = '2-Butanone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-94-4', 'Methyl vinyl ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-94-4' and x.name = 'Methyl vinyl ketone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '78-96-6', '1-Amino-2-Propanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '78-96-6' and x.name = '1-Amino-2-Propanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-00-5', '1,1,2-Trichloroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-00-5' and x.name = '1,1,2-Trichloroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-01-6', 'Trichloroethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-01-6' and x.name = 'Trichloroethylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-04-9', 'Chloroacetyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-04-9' and x.name = 'Chloroacetyl Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-06-1', 'Acrylamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-06-1' and x.name = 'Acrylamide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-08-3', 'Bromoacetic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-08-3' and x.name = 'Bromoacetic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-09-4', 'Propionic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-09-4' and x.name = 'Propionic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-10-7', 'Acrylic acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-10-7' and x.name = 'Acrylic acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-11-8', 'Monochloroacetic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-11-8' and x.name = 'Monochloroacetic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-14-1', 'Glycolic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-14-1' and x.name = 'Glycolic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-16-3', 'Methylacetamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-16-3' and x.name = 'Methylacetamide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-20-9', 'Methyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-20-9' and x.name = 'Methyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-24-3', 'Nitroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-24-3' and x.name = 'Nitroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-27-6', 'Acetylene Tetrabromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-27-6' and x.name = 'Acetylene Tetrabromide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-29-8', '2,3-Dimethylbutane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-29-8' and x.name = '2,3-Dimethylbutane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-34-5', '1,1,2,2-Tetrachloroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-34-5' and x.name = '1,1,2,2-Tetrachloroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-38-9', 'Chlorotrifluoroethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-38-9' and x.name = 'Chlorotrifluoroethylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-41-4', 'Methacrylic acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-41-4' and x.name = 'Methacrylic acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-46-9', '2-Nitropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-46-9' and x.name = '2-Nitropropane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-92-5', 'Camphene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-92-5' and x.name = 'Camphene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '79-94-7', 'Tetrabromobisphenol A', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '79-94-7' and x.name = 'Tetrabromobisphenol A' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-05-7', 'Bisphenol A', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-05-7' and x.name = 'Bisphenol A' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-08-0', '4,4''-Sulfonyldianiline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-08-0' and x.name = '4,4''-Sulfonyldianiline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-15-9', 'Cumene Hydroperoxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-15-9' and x.name = 'Cumene Hydroperoxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-43-3', 'Dicumyl Peroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-43-3' and x.name = 'Dicumyl Peroxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-55-7', 'Ethyl alpha-Hydroxy Isobutyrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-55-7' and x.name = 'Ethyl alpha-Hydroxy Isobutyrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-56-8', 'alpha-Pinene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-56-8' and x.name = 'alpha-Pinene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-62-6', 'Methyl Methacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-62-6' and x.name = 'Methyl Methacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '80-71-7', '3-Methyl-2-Cyclopentene-2-ol-one', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '80-71-7' and x.name = '3-Methyl-2-Cyclopentene-2-ol-one' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '81-07-2', 'Saccharin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '81-07-2' and x.name = 'Saccharin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '81-16-3', 'Tobias Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '81-16-3' and x.name = 'Tobias Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '81-81-2', 'Warfarin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '81-81-2' and x.name = 'Warfarin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '81-88-9', 'D & C Red #19', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '81-88-9' and x.name = 'D & C Red #19' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '82-66-6', '2-Diphenyl-1,3-Indandione', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '82-66-6' and x.name = '2-Diphenyl-1,3-Indandione' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '82-68-8', 'Pentachloronitrobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '82-68-8' and x.name = 'Pentachloronitrobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '83-26-1', 'Pindone (2-Pivalyl-1,3-indandione)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '83-26-1' and x.name = 'Pindone (2-Pivalyl-1,3-indandione)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '83-32-9', 'Acenaphthene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '83-32-9' and x.name = 'Acenaphthene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '83-79-4', 'Rotenone (Commercial)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '83-79-4' and x.name = 'Rotenone (Commercial)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '84-66-2', 'Diethyl Phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '84-66-2' and x.name = 'Diethyl Phthalate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '84-74-2', 'Dibutyl Phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '84-74-2' and x.name = 'Dibutyl Phthalate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '84-75-3', 'Di-n-hexyl phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '84-75-3' and x.name = 'Di-n-hexyl phthalate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '85-00-7', 'Diquat', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '85-00-7' and x.name = 'Diquat' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '85-01-8', 'Phenanthrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '85-01-8' and x.name = 'Phenanthrene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '85-42-7', 'Hexahydrophthalic Anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '85-42-7' and x.name = 'Hexahydrophthalic Anhydride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '85-44-9', 'Phthalic Anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '85-44-9' and x.name = 'Phthalic Anhydride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '85-68-7', 'Butyl Benzyl Phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '85-68-7' and x.name = 'Butyl Benzyl Phthalate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '85-86-9', 'Sudan III', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '85-86-9' and x.name = 'Sudan III' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '86-30-6', 'N-Nitrosodiphenylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '86-30-6' and x.name = 'N-Nitrosodiphenylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '86-50-0', 'Azinphos-Methyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '86-50-0' and x.name = 'Azinphos-Methyl' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '86-73-7', 'Fluorene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '86-73-7' and x.name = 'Fluorene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '86-74-8', 'Carbazole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '86-74-8' and x.name = 'Carbazole' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '86-88-4', 'ANTU', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '86-88-4' and x.name = 'ANTU' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '87-33-2', 'Isosorbide dinitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '87-33-2' and x.name = 'Isosorbide dinitrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '87-56-9', 'Mucochloric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '87-56-9' and x.name = 'Mucochloric Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '87-61-6', '1,2,3-Trichlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '87-61-6' and x.name = '1,2,3-Trichlorobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '87-68-3', 'Hexachlorobutadiene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '87-68-3' and x.name = 'Hexachlorobutadiene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '87-86-5', 'Pentachlorophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '87-86-5' and x.name = 'Pentachlorophenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88-12-0', 'N-Vinyl-2-Pyrrolidinone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88-12-0' and x.name = 'N-Vinyl-2-Pyrrolidinone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88-53-9', '6-Chloro-m-Toluidine-4-Sulfonic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88-53-9' and x.name = '6-Chloro-m-Toluidine-4-Sulfonic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88-73-3', '1-Chloro-2-nitrobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88-73-3' and x.name = '1-Chloro-2-nitrobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88-74-4', 'o-Nitroaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88-74-4' and x.name = 'o-Nitroaniline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88-85-7', '4,6-Dinitro-o-sec-butyl phenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88-85-7' and x.name = '4,6-Dinitro-o-sec-butyl phenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88-89-1', 'Picric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88-89-1' and x.name = 'Picric Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88-99-3', 'Phthalic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88-99-3' and x.name = 'Phthalic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '89-72-5', 'o-sec-Butylphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '89-72-5' and x.name = 'o-sec-Butylphenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-05-1', '2-Methoxyphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-05-1' and x.name = '2-Methoxyphenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-11-9', '1-Bromonaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-11-9' and x.name = '1-Bromonaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-12-0', '1-Methylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-12-0' and x.name = '1-Methylnaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-13-1', 'alpha-Chloronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-13-1' and x.name = 'alpha-Chloronaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-30-2', 'N-Phenyl-1-Naphthylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-30-2' and x.name = 'N-Phenyl-1-Naphthylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-43-7', 'o-Phenyl Phenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-43-7' and x.name = 'o-Phenyl Phenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-72-2', 'Tri(Dimethylaminomethyl)phenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-72-2' and x.name = 'Tri(Dimethylaminomethyl)phenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '90-94-8', 'Tetramethyldiaminobenzophenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '90-94-8' and x.name = 'Tetramethyldiaminobenzophenone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-08-7', 'Toluene-2,6-Diisocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-08-7' and x.name = 'Toluene-2,6-Diisocyanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-17-8', 'trans-Decahydronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-17-8' and x.name = 'trans-Decahydronaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-20-3', 'Naphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-20-3' and x.name = 'Naphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-57-6', '2-Methylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-57-6' and x.name = '2-Methylnaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-59-8', 'beta-Naphthylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-59-8' and x.name = 'beta-Naphthylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-64-5', 'Coumarin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-64-5' and x.name = 'Coumarin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-66-7', 'N,N-Diethylaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-66-7' and x.name = 'N,N-Diethylaniline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '91-94-1', '3,3''-Dichlorobenzidine and its salts', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '91-94-1' and x.name = '3,3''-Dichlorobenzidine and its salts' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-43-3', '1-Phenyl-3-pyrazolidinone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-43-3' and x.name = '1-Phenyl-3-pyrazolidinone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-48-8', '6-Methylcoumarin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-48-8' and x.name = '6-Methylcoumarin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-52-4', 'Diphenyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-52-4' and x.name = 'Diphenyl' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-67-1', '4-Aminodiphenyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-67-1' and x.name = '4-Aminodiphenyl' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-70-6', '3-Hydroxy-2-Naphthoic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-70-6' and x.name = '3-Hydroxy-2-Naphthoic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-84-2', 'Phenothiazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-84-2' and x.name = 'Phenothiazine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-87-5', 'Benzidine Based Dyes', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-87-5' and x.name = 'Benzidine Based Dyes' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-87-5', 'Benzidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-87-5' and x.name = 'Benzidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-93-3', '4-Nitrodiphenyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-93-3' and x.name = '4-Nitrodiphenyl' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '92-94-4', 'Terphenyls', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '92-94-4' and x.name = 'Terphenyls' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93-46-9', 'N,N''-Di-beta-naphthyl-p-phenylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93-46-9' and x.name = 'N,N''-Di-beta-naphthyl-p-phenylenediamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93-58-3', 'Methyl Benzoate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93-58-3' and x.name = 'Methyl Benzoate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93-65-2', 'MCPP', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93-65-2' and x.name = 'MCPP' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93-72-1', 'Silvex', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93-72-1' and x.name = 'Silvex' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93-76-5', '2,4,5-T', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93-76-5' and x.name = '2,4,5-T' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93-79-8', '2,4,5-T, Butyl Ester', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93-79-8' and x.name = '2,4,5-T, Butyl Ester' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '94-13-3', 'Propyl Paraben', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '94-13-3' and x.name = 'Propyl Paraben' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '94-36-0', 'Benzoyl Peroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '94-36-0' and x.name = 'Benzoyl Peroxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '94-74-6', 'MCPA', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '94-74-6' and x.name = 'MCPA' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '94-75-7', '2,4-D', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '94-75-7' and x.name = '2,4-D' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '94-80-4', '2,4-D Butyl Ester', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '94-80-4' and x.name = '2,4-D Butyl Ester' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '94-96-2', '2-Ethyl-1,2-Hexanediol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '94-96-2' and x.name = '2-Ethyl-1,2-Hexanediol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-13-6', 'Indene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-13-6' and x.name = 'Indene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-16-9', 'Benzothiazole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-16-9' and x.name = 'Benzothiazole' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-31-8', 'N-t-Butyl-2-Benzothiazolesulfenamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-31-8' and x.name = 'N-t-Butyl-2-Benzothiazolesulfenamide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-33-0', 'N-Cyclohexyl-2-benzothiazolesulfenamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-33-0' and x.name = 'N-Cyclohexyl-2-benzothiazolesulfenamide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-47-6', 'o-Xylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-47-6' and x.name = 'o-Xylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-49-8', 'o-Chlorotoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-49-8' and x.name = 'o-Chlorotoluene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-50-1', 'o-Dichlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-50-1' and x.name = 'o-Dichlorobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-51-2', 'o-Chloroaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-51-2' and x.name = 'o-Chloroaniline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-53-4', 'o-Toluidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-53-4' and x.name = 'o-Toluidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-54-5', 'o-Phenylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-54-5' and x.name = 'o-Phenylenediamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-57-8', 'o-Chlorophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-57-8' and x.name = 'o-Chlorophenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-76-1', '3,4-Dichloroaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-76-1' and x.name = '3,4-Dichloroaniline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-80-7', 'Toluene-2,4-Diamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-80-7' and x.name = 'Toluene-2,4-Diamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-93-2', '1,2,4,5-Tetramethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-93-2' and x.name = '1,2,4,5-Tetramethylbenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '95-94-3', '1,2,4,5-Tetrachlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '95-94-3' and x.name = '1,2,4,5-Tetrachlorobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-05-9', 'Allyl Methacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-05-9' and x.name = 'Allyl Methacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-09-3', '1,2-Epoxyethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-09-3' and x.name = '1,2-Epoxyethylbenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-12-8', '1,2-Dibromo-3-Chloropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-12-8' and x.name = '1,2-Dibromo-3-Chloropropane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-14-0', '3-Methylpentane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-14-0' and x.name = '3-Methylpentane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-18-4', '1,2,3-Trichloropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-18-4' and x.name = '1,2,3-Trichloropropane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-22-0', 'Diethyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-22-0' and x.name = 'Diethyl Ketone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-29-7', 'Methyl Ethyl Ketoxime', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-29-7' and x.name = 'Methyl Ethyl Ketoxime' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-33-3', 'Methyl Acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-33-3' and x.name = 'Methyl Acrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-37-7', 'Methylcyclopentane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-37-7' and x.name = 'Methylcyclopentane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-45-7', 'Ethylene Thiourea', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-45-7' and x.name = 'Ethylene Thiourea' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-48-0', 'gamma-Butyrolactone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-48-0' and x.name = 'gamma-Butyrolactone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-69-5', '4,4''-Thiobis(6-tert-Butyl-m-Cresol) (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-69-5' and x.name = '4,4''-Thiobis(6-tert-Butyl-m-Cresol) (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-69-5', '4,4''-Thiobis(6-tert-Butyl-m-Cresol) (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-69-5' and x.name = '4,4''-Thiobis(6-tert-Butyl-m-Cresol) (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-76-4', '2,4-Di-Tert-Butylphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-76-4' and x.name = '2,4-Di-Tert-Butylphenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '96-91-3', 'Picramic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '96-91-3' and x.name = 'Picramic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-00-7', '2,4-Dinitrochlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-00-7' and x.name = '2,4-Dinitrochlorobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-23-4', '2,2''-Methylene-bis(4-chlorophenol)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-23-4' and x.name = '2,2''-Methylene-bis(4-chlorophenol)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-63-2', 'Ethyl Methacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-63-2' and x.name = 'Ethyl Methacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-64-3', 'Ethyl Lactate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-64-3' and x.name = 'Ethyl Lactate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-77-8', 'Disulfiram', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-77-8' and x.name = 'Disulfiram' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-84-7', 'Tetramethyl Butanediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-84-7' and x.name = 'Tetramethyl Butanediamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-85-8', 'Isobutyl Isobutyrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-85-8' and x.name = 'Isobutyl Isobutyrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-86-9', 'Isobutyl Methacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-86-9' and x.name = 'Isobutyl Methacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-88-1', 'Butyl Methacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-88-1' and x.name = 'Butyl Methacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-90-5', 'Ethylene Dimethacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-90-5' and x.name = 'Ethylene Dimethacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '97-99-4', 'Tetrahydro-2-furanmethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '97-99-4' and x.name = 'Tetrahydro-2-furanmethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-00-0', 'Furfuryl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-00-0' and x.name = 'Furfuryl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-01-1', 'Furfural', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-01-1' and x.name = 'Furfural' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-07-7', 'Benzotrichloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-07-7' and x.name = 'Benzotrichloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-09-9', 'Benzenesulfonyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-09-9' and x.name = 'Benzenesulfonyl Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-11-3', 'Benzenesulfonic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-11-3' and x.name = 'Benzenesulfonic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-51-1', 'p-tert-Butyltoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-51-1' and x.name = 'p-tert-Butyltoluene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-54-4', 'p-(tert-Butyl)Phenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-54-4' and x.name = 'p-(tert-Butyl)Phenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-55-5', 'Terpineol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-55-5' and x.name = 'Terpineol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-56-6', '1-Chloro-4-trifluoromethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-56-6' and x.name = '1-Chloro-4-trifluoromethylbenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-59-9', 'Toluenesulfonyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-59-9' and x.name = 'Toluenesulfonyl Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-82-8', 'Cumene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-82-8' and x.name = 'Cumene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-83-9', 'alpha-Methyl Styrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-83-9' and x.name = 'alpha-Methyl Styrene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-86-2', 'Acetophenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-86-2' and x.name = 'Acetophenone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-87-3', '(Dichloromethyl)benzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-87-3' and x.name = '(Dichloromethyl)benzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-88-4', 'Benzoyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-88-4' and x.name = 'Benzoyl Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-94-2', 'N,N-Dimethylcyclohexylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-94-2' and x.name = 'N,N-Dimethylcyclohexylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '98-95-3', 'Nitrobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '98-95-3' and x.name = 'Nitrobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-06-9', 'm-Hydroxybenzoic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-06-9' and x.name = 'm-Hydroxybenzoic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-07-0', '(Dimethylamino)phenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-07-0' and x.name = '(Dimethylamino)phenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-08-1', 'Nitrotoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-08-1' and x.name = 'Nitrotoluene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-30-9', 'Botran', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-30-9' and x.name = 'Botran' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-76-3', 'Methylparaben', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-76-3' and x.name = 'Methylparaben' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-83-2', 'alpha-Phellandrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-83-2' and x.name = 'alpha-Phellandrene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-86-5', 'alpha-Terpinene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-86-5' and x.name = 'alpha-Terpinene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-87-6', 'Cymene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-87-6' and x.name = 'Cymene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '99-97-8', 'N,N-Dimethyl-p-Toluidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '99-97-8' and x.name = 'N,N-Dimethyl-p-Toluidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-00-5', 'p-Nitrochlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-00-5' and x.name = 'p-Nitrochlorobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-01-6', 'p-Nitroaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-01-6' and x.name = 'p-Nitroaniline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-02-7', 'p-Nitrophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-02-7' and x.name = 'p-Nitrophenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-11-8', 'para-Nitrobenzyl Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-11-8' and x.name = 'para-Nitrobenzyl Bromide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-37-8', 'Diethylamino ethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-37-8' and x.name = 'Diethylamino ethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-39-0', 'Benzyl Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-39-0' and x.name = 'Benzyl Bromide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-41-4', 'Ethyl Benzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-41-4' and x.name = 'Ethyl Benzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-42-5', 'Styrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-42-5' and x.name = 'Styrene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-44-7', 'Benzyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-44-7' and x.name = 'Benzyl Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-51-6', 'Benzyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-51-6' and x.name = 'Benzyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-52-7', 'Benzaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-52-7' and x.name = 'Benzaldehyde' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-61-8', 'Monomethyl Aniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-61-8' and x.name = 'Monomethyl Aniline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-63-0', 'Phenylhydrazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-63-0' and x.name = 'Phenylhydrazine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-66-3', 'Anisole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-66-3' and x.name = 'Anisole' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-74-3', 'N-Ethylmorpholine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-74-3' and x.name = 'N-Ethylmorpholine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-75-4', 'N-Nitrosopiperidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-75-4' and x.name = 'N-Nitrosopiperidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '100-97-0', 'Hexamethylenetetramine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '100-97-0' and x.name = 'Hexamethylenetetramine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '101-14-4', '4,4''-Methylene-bis(2-Chloroaniline)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '101-14-4' and x.name = '4,4''-Methylene-bis(2-Chloroaniline)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '101-21-3', 'Isopropyl m-Chlorocarbaniliate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '101-21-3' and x.name = 'Isopropyl m-Chlorocarbaniliate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '101-68-8', 'Methylene bisphenyl isocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '101-68-8' and x.name = 'Methylene bisphenyl isocyanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '101-77-9', '4,4''-Methylenedianiline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '101-77-9' and x.name = '4,4''-Methylenedianiline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '101-80-4', '4,4''-Oxydianiline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '101-80-4' and x.name = '4,4''-Oxydianiline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '101-83-7', 'Dicyclohexylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '101-83-7' and x.name = 'Dicyclohexylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '101-84-8', 'Phenyl Ether (Vapor)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '101-84-8' and x.name = 'Phenyl Ether (Vapor)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-01-2', 'Acetoacetanilide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-01-2' and x.name = 'Acetoacetanilide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-54-5', 'Dicyclopentadienyl Iron (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-54-5' and x.name = 'Dicyclopentadienyl Iron (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-54-5', 'Dicyclopentadienyl Iron (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-54-5' and x.name = 'Dicyclopentadienyl Iron (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-56-7', '2,5-Dimethoxyaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-56-7' and x.name = '2,5-Dimethoxyaniline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-60-3', 'Quadrol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-60-3' and x.name = 'Quadrol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-71-6', 'Triethanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-71-6' and x.name = 'Triethanolamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-81-8', '2-n-Dibutylaminoethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-81-8' and x.name = '2-n-Dibutylaminoethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '102-82-9', 'Tributylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '102-82-9' and x.name = 'Tributylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-09-3', 'Ethyl Hexyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-09-3' and x.name = 'Ethyl Hexyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-11-7', '2-Ethylhexyl acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-11-7' and x.name = '2-Ethylhexyl acrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-23-1', 'Di-(2-Ethylhexyl) Adipate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-23-1' and x.name = 'Di-(2-Ethylhexyl) Adipate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-34-4', '4,4''-Dithiodimorpholine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-34-4' and x.name = '4,4''-Dithiodimorpholine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-65-1', 'n-Propyl Benzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-65-1' and x.name = 'n-Propyl Benzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-71-9', 'Phenyl Isocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-71-9' and x.name = 'Phenyl Isocyanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-79-7', 'Phenyl-2-Propanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-79-7' and x.name = 'Phenyl-2-Propanone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-82-2', 'Phenyl Acetic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-82-2' and x.name = 'Phenyl Acetic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-83-3', 'N,N-Dimethylbenzylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-83-3' and x.name = 'N,N-Dimethylbenzylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-84-4', 'Acetanilide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-84-4' and x.name = 'Acetanilide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '103-90-2', 'Tylenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '103-90-2' and x.name = 'Tylenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '104-15-4', 'p-Toluenesulfonic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '104-15-4' and x.name = 'p-Toluenesulfonic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '104-55-2', 'Cinnamaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '104-55-2' and x.name = 'Cinnamaldehyde' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '104-75-6', '2-Ethylhexylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '104-75-6' and x.name = '2-Ethylhexylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '104-76-7', '2-Ethylhexanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '104-76-7' and x.name = '2-Ethylhexanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '104-78-9', 'Diethylaminopropylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '104-78-9' and x.name = 'Diethylaminopropylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '104-87-0', 'Tolualdehyde (o, m and p isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '104-87-0' and x.name = 'Tolualdehyde (o, m and p isomers)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-05-5', 'p-Diethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-05-5' and x.name = 'p-Diethylbenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-37-3', 'Ethyl Propionate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-37-3' and x.name = 'Ethyl Propionate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-46-4', 'sec-Butyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-46-4' and x.name = 'sec-Butyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-54-4', 'Ethyl Butyrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-54-4' and x.name = 'Ethyl Butyrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-58-8', 'Diethyl Carbonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-58-8' and x.name = 'Diethyl Carbonate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-59-9', 'N-Methyldiethanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-59-9' and x.name = 'N-Methyldiethanolamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-60-2', 'Caprolactam (Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-60-2' and x.name = 'Caprolactam (Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '105-60-2', 'Caprolactam (Vapor)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '105-60-2' and x.name = 'Caprolactam (Vapor)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-35-4', 'Ethyl Butyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-35-4' and x.name = 'Ethyl Butyl Ketone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-42-3', 'p-Xylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-42-3' and x.name = 'p-Xylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-43-4', 'p-Chlorotoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-43-4' and x.name = 'p-Chlorotoluene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-46-7', 'p-Dichlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-46-7' and x.name = 'p-Dichlorobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-47-8', 'p-Chloroaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-47-8' and x.name = 'p-Chloroaniline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-48-9', 'p-Chlorophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-48-9' and x.name = 'p-Chlorophenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-49-0', 'p-Toluidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-49-0' and x.name = 'p-Toluidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-50-3', 'p-Phenylene Diamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-50-3' and x.name = 'p-Phenylene Diamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-51-4', 'Quinone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-51-4' and x.name = 'Quinone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-63-8', 'Isobutyl Acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-63-8' and x.name = 'Isobutyl Acrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-65-0', 'Dimethyl Succinate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-65-0' and x.name = 'Dimethyl Succinate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-71-8', 'Cyanoethyl acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-71-8' and x.name = 'Cyanoethyl acrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-87-6', 'Vinyl Cyclohexene Dioxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-87-6' and x.name = 'Vinyl Cyclohexene Dioxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-88-7', '1,2-Epoxybutane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-88-7' and x.name = '1,2-Epoxybutane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-89-8', 'Epichlorohydrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-89-8' and x.name = 'Epichlorohydrin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-91-2', 'Glycidyl Methacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-91-2' and x.name = 'Glycidyl Methacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-92-3', 'Allyl Glycidyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-92-3' and x.name = 'Allyl Glycidyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-93-4', 'Ethylene Dibromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-93-4' and x.name = 'Ethylene Dibromide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-94-5', '1-Bromopropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-94-5' and x.name = '1-Bromopropane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-97-8', 'Butane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-97-8' and x.name = 'Butane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '106-99-0', 'Butadiene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '106-99-0' and x.name = 'Butadiene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-02-8', 'Acrolein', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-02-8' and x.name = 'Acrolein' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-05-1', 'Allyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-05-1' and x.name = 'Allyl Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-06-2', 'Ethylene Dichloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-06-2' and x.name = 'Ethylene Dichloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-07-3', 'Ethylene Chlorohydrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-07-3' and x.name = 'Ethylene Chlorohydrin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-10-8', 'Propylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-10-8' and x.name = 'Propylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-12-0', 'Propionitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-12-0' and x.name = 'Propionitrile' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-13-1', 'Acrylonitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-13-1' and x.name = 'Acrylonitrile' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-15-3', 'Ethylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-15-3' and x.name = 'Ethylenediamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-18-6', 'Allyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-18-6' and x.name = 'Allyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-19-7', 'Propargyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-19-7' and x.name = 'Propargyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-20-0', 'Chloroacetaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-20-0' and x.name = 'Chloroacetaldehyde' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-21-1', 'Ethylene Glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-21-1' and x.name = 'Ethylene Glycol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-22-2', 'Glyoxal', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-22-2' and x.name = 'Glyoxal' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-30-2', 'Chloromethyl Methyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-30-2' and x.name = 'Chloromethyl Methyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-31-3', 'Methyl Formate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-31-3' and x.name = 'Methyl Formate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-41-5', 'Hexylene Glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-41-5' and x.name = 'Hexylene Glycol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-44-8', 'Sarin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-44-8' and x.name = 'Sarin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-49-3', 'TEPP', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-49-3' and x.name = 'TEPP' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-66-4', 'Dibutyl Phosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-66-4' and x.name = 'Dibutyl Phosphate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-70-0', '4-Methoxy-4-Methyl-2-Pentanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-70-0' and x.name = '4-Methoxy-4-Methyl-2-Pentanone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-83-5', '2-Methylpentane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-83-5' and x.name = '2-Methylpentane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-87-9', '2-Pentanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-87-9' and x.name = '2-Pentanone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-88-0', '1,3-Butanediol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-88-0' and x.name = '1,3-Butanediol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-92-6', 'Butyric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-92-6' and x.name = 'Butyric Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '107-98-2', 'Propylene Glycol Monomethyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '107-98-2' and x.name = 'Propylene Glycol Monomethyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-01-0', 'N,N-Dimethylethanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-01-0' and x.name = 'N,N-Dimethylethanolamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-03-2', '1-Nitropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-03-2' and x.name = '1-Nitropropane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-05-4', 'Vinyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-05-4' and x.name = 'Vinyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-10-1', 'Hexone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-10-1' and x.name = 'Hexone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-11-2', 'Methyl Isobutyl Carbinol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-11-2' and x.name = 'Methyl Isobutyl Carbinol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-18-9', 'Diisopropylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-18-9' and x.name = 'Diisopropylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-20-3', 'Isopropyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-20-3' and x.name = 'Isopropyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-21-4', 'Isopropyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-21-4' and x.name = 'Isopropyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-24-7', 'Acetic Anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-24-7' and x.name = 'Acetic Anhydride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-31-6', 'Maleic Anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-31-6' and x.name = 'Maleic Anhydride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-32-7', 'Propylene Carbonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-32-7' and x.name = 'Propylene Carbonate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-38-3', 'm-Xylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-38-3' and x.name = 'm-Xylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-41-8', 'm-Chlorotoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-41-8' and x.name = 'm-Chlorotoluene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-44-1', 'm-Toluidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-44-1' and x.name = 'm-Toluidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-45-2', 'm-Phenylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-45-2' and x.name = 'm-Phenylenediamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-46-3', 'Resorcinol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-46-3' and x.name = 'Resorcinol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-48-5', '2,6-Dimethylpyridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-48-5' and x.name = '2,6-Dimethylpyridine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-65-6', 'Propylene Glycol Monomethyl Ether Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-65-6' and x.name = 'Propylene Glycol Monomethyl Ether Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-70-3', '1,3,5-Trichlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-70-3' and x.name = '1,3,5-Trichlorobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-77-0', 'Cyanuric Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-77-0' and x.name = 'Cyanuric Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-78-1', 'Melamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-78-1' and x.name = 'Melamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-80-5', 'Cyanuric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-80-5' and x.name = 'Cyanuric Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-83-8', 'Diisobutyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-83-8' and x.name = 'Diisobutyl Ketone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-84-9', 'sec-Hexyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-84-9' and x.name = 'sec-Hexyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-86-1', 'Bromobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-86-1' and x.name = 'Bromobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-87-2', 'Methylcyclohexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-87-2' and x.name = 'Methylcyclohexane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-88-3', 'Toluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-88-3' and x.name = 'Toluene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-90-7', 'Chlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-90-7' and x.name = 'Chlorobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-91-8', 'Cyclohexylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-91-8' and x.name = 'Cyclohexylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-93-0', 'Cyclohexanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-93-0' and x.name = 'Cyclohexanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-94-1', 'Cyclohexanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-94-1' and x.name = 'Cyclohexanone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-95-2', 'Phenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-95-2' and x.name = 'Phenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '108-98-5', 'Phenyl Mercaptan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '108-98-5' and x.name = 'Phenyl Mercaptan' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-02-4', '4-Methyl Morpholine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-02-4' and x.name = '4-Methyl Morpholine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-17-1', 'Tetraethyleneglycol Dimethacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-17-1' and x.name = 'Tetraethyleneglycol Dimethacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-21-7', 'Butyl Butryrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-21-7' and x.name = 'Butyl Butryrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-46-6', 'Dibutylthiourea', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-46-6' and x.name = 'Dibutylthiourea' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-52-4', 'Valeric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-52-4' and x.name = 'Valeric Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-55-7', 'N,N-Dimethyl-1,3-propanediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-55-7' and x.name = 'N,N-Dimethyl-1,3-propanediamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-59-1', 'Isopropyl Cellosolve', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-59-1' and x.name = 'Isopropyl Cellosolve' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-60-4', 'n-Propyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-60-4' and x.name = 'n-Propyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-66-0', 'Pentane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-66-0' and x.name = 'Pentane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-67-1', '1-Pentene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-67-1' and x.name = '1-Pentene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-73-9', 'Butylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-73-9' and x.name = 'Butylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-75-1', 'Allyl Cyanide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-75-1' and x.name = 'Allyl Cyanide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-79-5', 'Butyl Mercaptan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-79-5' and x.name = 'Butyl Mercaptan' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-83-1', '2-Methylaminoethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-83-1' and x.name = '2-Methylaminoethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-86-4', '2-Methoxyethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-86-4' and x.name = '2-Methoxyethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-87-5', 'Methylal', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-87-5' and x.name = 'Methylal' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-89-7', 'Diethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-89-7' and x.name = 'Diethylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-94-4', 'Ethyl Formate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-94-4' and x.name = 'Ethyl Formate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '109-99-9', 'Tetrahydrofuran', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '109-99-9' and x.name = 'Tetrahydrofuran' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-02-1', 'Thiophene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-02-1' and x.name = 'Thiophene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-05-4', 'tert-Butylperoxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-05-4' and x.name = 'tert-Butylperoxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-12-3', 'Methyl Isoamyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-12-3' and x.name = 'Methyl Isoamyl Ketone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-16-7', 'Maleic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-16-7' and x.name = 'Maleic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-17-8', 'Fumaric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-17-8' and x.name = 'Fumaric Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-18-9', 'N,N,N'',N''-Tetramethylethylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-18-9' and x.name = 'N,N,N'',N''-Tetramethylethylenediamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-19-0', 'Isobutyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-19-0' and x.name = 'Isobutyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-43-0', 'Methyl (n-amyl) ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-43-0' and x.name = 'Methyl (n-amyl) ketone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-46-3', 'Isoamyl Nitrite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-46-3' and x.name = 'Isoamyl Nitrite' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-49-6', '2-Methoxyethyl acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-49-6' and x.name = '2-Methoxyethyl acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-54-3', 'Hexane (n-Hexane)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-54-3' and x.name = 'Hexane (n-Hexane)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-62-3', 'n-Valeraldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-62-3' and x.name = 'n-Valeraldehyde' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-69-0', 'Butyraldehyde Oxime', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-69-0' and x.name = 'Butyraldehyde Oxime' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-71-4', 'Ethylene Glycol Dimethyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-71-4' and x.name = 'Ethylene Glycol Dimethyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-80-5', '2-Ethoxyethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-80-5' and x.name = '2-Ethoxyethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-82-7', 'Cyclohexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-82-7' and x.name = 'Cyclohexane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-83-8', 'Cyclohexene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-83-8' and x.name = 'Cyclohexene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-85-0', 'Piperazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-85-0' and x.name = 'Piperazine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-86-1', 'Pyridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-86-1' and x.name = 'Pyridine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-89-4', 'Piperidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-89-4' and x.name = 'Piperidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-91-8', 'Morpholine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-91-8' and x.name = 'Morpholine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-97-4', 'Diisopropanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-97-4' and x.name = 'Diisopropanolamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '110-98-5', 'Dipropylene Glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '110-98-5' and x.name = 'Dipropylene Glycol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-15-9', '2-Ethoxyethyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-15-9' and x.name = '2-Ethoxyethyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-26-2', 'Hexylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-26-2' and x.name = 'Hexylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-27-3', 'Hexyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-27-3' and x.name = 'Hexyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-30-8', 'Glutaraldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-30-8' and x.name = 'Glutaraldehyde' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-36-4', 'Butyl Isocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-36-4' and x.name = 'Butyl Isocyanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-40-0', 'Diethylenetriamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-40-0' and x.name = 'Diethylenetriamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-41-1', 'Aminoethylethanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-41-1' and x.name = 'Aminoethylethanolamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-42-2', 'Diethanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-42-2' and x.name = 'Diethanolamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-44-4', 'Dichloroethyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-44-4' and x.name = 'Dichloroethyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-46-6', 'Diethylene Glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-46-6' and x.name = 'Diethylene Glycol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-65-9', 'Octane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-65-9' and x.name = 'Octane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-66-0', '1-Octene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-66-0' and x.name = '1-Octene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-68-2', 'n-Heptylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-68-2' and x.name = 'n-Heptylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-69-3', 'Adiponitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-69-3' and x.name = 'Adiponitrile' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-76-2', '2-Butoxyethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-76-2' and x.name = '2-Butoxyethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-77-3', 'Diethylene Glycol Monomethyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-77-3' and x.name = 'Diethylene Glycol Monomethyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-84-2', 'Nonane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-84-2' and x.name = 'Nonane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-87-5', 'Octanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-87-5' and x.name = 'Octanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-88-6', '1-Octanethiol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-88-6' and x.name = '1-Octanethiol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-90-0', 'Diethylene Glycol Monoethyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-90-0' and x.name = 'Diethylene Glycol Monoethyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-92-2', 'Dibutylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-92-2' and x.name = 'Dibutylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '111-96-6', 'Diglyme', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '111-96-6' and x.name = 'Diglyme' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-07-2', 'Butyl Cellosolve Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-07-2' and x.name = 'Butyl Cellosolve Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-15-2', 'Carbitol Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-15-2' and x.name = 'Carbitol Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-24-3', 'Triethylenetetramine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-24-3' and x.name = 'Triethylenetetramine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-25-4', 'Ethylene Glycol Monohexyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-25-4' and x.name = 'Ethylene Glycol Monohexyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-27-6', 'Triethylene Glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-27-6' and x.name = 'Triethylene Glycol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-30-1', 'Decyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-30-1' and x.name = 'Decyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-34-5', 'Butyl Carbitol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-34-5' and x.name = 'Butyl Carbitol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-50-5', 'Triethylene glycol monoethyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-50-5' and x.name = 'Triethylene glycol monoethyl ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-57-2', 'Tetraethylenepentamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-57-2' and x.name = 'Tetraethylenepentamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-59-4', 'Hexyl Carbitol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-59-4' and x.name = 'Hexyl Carbitol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-60-7', 'Tetraethylene Glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-60-7' and x.name = 'Tetraethylene Glycol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-70-9', '1-Tridecanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-70-9' and x.name = '1-Tridecanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112-92-5', 'Octadecanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112-92-5' and x.name = 'Octadecanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '114-26-1', 'Propoxur', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '114-26-1' and x.name = 'Propoxur' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-07-1', 'Propylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-07-1' and x.name = 'Propylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-10-6', 'Methyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-10-6' and x.name = 'Methyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-11-7', 'Isobutylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-11-7' and x.name = 'Isobutylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-29-7', 'Endosulfan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-29-7' and x.name = 'Endosulfan' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-32-2', 'Dicofol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-32-2' and x.name = 'Dicofol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-77-5', 'Pentaerythritol (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-77-5' and x.name = 'Pentaerythritol (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-77-5', 'Pentaerythritol (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-77-5' and x.name = 'Pentaerythritol (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-86-6', 'Triphenyl Phosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-86-6' and x.name = 'Triphenyl Phosphate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '115-90-2', 'Fensulfothion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '115-90-2' and x.name = 'Fensulfothion' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '116-06-3', 'Aldicarb', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '116-06-3' and x.name = 'Aldicarb' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '116-14-3', 'Tetrafluoroethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '116-14-3' and x.name = 'Tetrafluoroethylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '117-08-8', 'Tetrachlorophthalic Anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '117-08-8' and x.name = 'Tetrachlorophthalic Anhydride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '117-52-2', 'Fumarin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '117-52-2' and x.name = 'Fumarin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '117-81-7', 'Di-(2-Ethylhexyl)phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '117-81-7' and x.name = 'Di-(2-Ethylhexyl)phthalate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '117-84-0', 'Di-n-Octyl Phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '117-84-0' and x.name = 'Di-n-Octyl Phthalate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '118-52-5', '1,3-Dichloro-5,5-dimethyl hydantoin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '118-52-5' and x.name = '1,3-Dichloro-5,5-dimethyl hydantoin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '118-74-1', 'Hexachlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '118-74-1' and x.name = 'Hexachlorobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '118-96-7', '2,4,6-Trinitrotoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '118-96-7' and x.name = '2,4,6-Trinitrotoluene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-26-6', '2,4-Dinitrophenyl Hydrazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-26-6' and x.name = '2,4-Dinitrophenyl Hydrazine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-36-8', 'Methyl Salicylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-36-8' and x.name = 'Methyl Salicylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-61-9', 'Benzophenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-61-9' and x.name = 'Benzophenone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-64-2', 'Tetrahydronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-64-2' and x.name = 'Tetrahydronaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-90-4', 'o-Dianisidine-Based Dyes', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-90-4' and x.name = 'o-Dianisidine-Based Dyes' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-90-4', 'o-Dianisidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-90-4' and x.name = 'o-Dianisidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-93-7', 'o-Tolidine Based Dyes', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-93-7' and x.name = 'o-Tolidine Based Dyes' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '119-93-7', 'o-Tolidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '119-93-7' and x.name = 'o-Tolidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '120-12-7', 'Anthracene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '120-12-7' and x.name = 'Anthracene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '120-32-1', 'Chlorophene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '120-32-1' and x.name = 'Chlorophene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '120-71-8', '5-Methyl-o-Anisidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '120-71-8' and x.name = '5-Methyl-o-Anisidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '120-78-5', '2,2''-Dithiobis[benzothiazole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '120-78-5' and x.name = '2,2''-Dithiobis[benzothiazole' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '120-80-9', 'Catechol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '120-80-9' and x.name = 'Catechol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '120-82-1', '1,2,4-Trichlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '120-82-1' and x.name = '1,2,4-Trichlorobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '120-83-2', '2,4-Dichlorophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '120-83-2' and x.name = '2,4-Dichlorophenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-44-8', 'Triethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-44-8' and x.name = 'Triethylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-45-9', 'Trimethyl Phosphite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-45-9' and x.name = 'Trimethyl Phosphite' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-53-9', 'm-Sulfobenzoic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-53-9' and x.name = 'm-Sulfobenzoic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-69-7', 'Dimethylaniline (N,N-Dimethylaniline)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-69-7' and x.name = 'Dimethylaniline (N,N-Dimethylaniline)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-71-1', 'm-Hydroxyacetophenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-71-1' and x.name = 'm-Hydroxyacetophenone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-75-5', 'Malathion (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-75-5' and x.name = 'Malathion (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-82-4', 'Cyclonite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-82-4' and x.name = 'Cyclonite' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '121-91-5', 'Isophthalic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '121-91-5' and x.name = 'Isophthalic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '122-14-5', 'Fenitrothion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '122-14-5' and x.name = 'Fenitrothion' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '122-34-9', 'Simazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '122-34-9' and x.name = 'Simazine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '122-39-4', 'Diphenylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '122-39-4' and x.name = 'Diphenylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '122-60-1', 'Phenyl Glycidyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '122-60-1' and x.name = 'Phenyl Glycidyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '122-62-3', 'Dioctyl Sebacate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '122-62-3' and x.name = 'Dioctyl Sebacate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '122-99-6', '2-Phenoxyethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '122-99-6' and x.name = '2-Phenoxyethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-01-3', 'Dodecyl Benzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-01-3' and x.name = 'Dodecyl Benzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-11-5', 'o-Anisaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-11-5' and x.name = 'o-Anisaldehyde' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-19-3', 'Dipropyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-19-3' and x.name = 'Dipropyl Ketone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-31-9', 'Hydroquinone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-31-9' and x.name = 'Hydroquinone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-38-6', 'Propionaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-38-6' and x.name = 'Propionaldehyde' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-39-7', 'Methyl Formamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-39-7' and x.name = 'Methyl Formamide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-42-2', 'Diacetone Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-42-2' and x.name = 'Diacetone Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-51-3', 'Isoamyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-51-3' and x.name = 'Isoamyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-54-6', 'Acetylacetone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-54-6' and x.name = 'Acetylacetone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-72-8', 'Butyraldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-72-8' and x.name = 'Butyraldehyde' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-73-9', 'Crotonaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-73-9' and x.name = 'Crotonaldehyde' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-77-3', '1,1''-Azobisformamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-77-3' and x.name = '1,1''-Azobisformamide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-86-4', 'n-Butyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-86-4' and x.name = 'n-Butyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-91-1', 'Dioxane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-91-1' and x.name = 'Dioxane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-92-2', 'Isoamyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-92-2' and x.name = 'Isoamyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '123-95-5', 'Butyl Stearate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '123-95-5' and x.name = 'Butyl Stearate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-04-9', 'Adipic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-04-9' and x.name = 'Adipic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-07-2', 'Octanoic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-07-2' and x.name = 'Octanoic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-09-4', 'Hexamethylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-09-4' and x.name = 'Hexamethylenediamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-17-4', 'Diethylene Glycol Monobutyl Ether Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-17-4' and x.name = 'Diethylene Glycol Monobutyl Ether Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-18-5', 'Decane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-18-5' and x.name = 'Decane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-38-9', 'Carbon Dioxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-38-9' and x.name = 'Carbon Dioxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-40-3', 'Dimethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-40-3' and x.name = 'Dimethylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '124-68-5', '2-Amino-2-Methylpropanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '124-68-5' and x.name = '2-Amino-2-Methylpropanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '125-69-9', 'Dextromethorphan hydrobromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '125-69-9' and x.name = 'Dextromethorphan hydrobromide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '126-73-8', 'Tributyl Phosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '126-73-8' and x.name = 'Tributyl Phosphate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '126-98-7', 'Methyl Acrylonitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '126-98-7' and x.name = 'Methyl Acrylonitrile' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '126-99-8', 'Chloroprene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '126-99-8' and x.name = 'Chloroprene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '127-18-4', 'Tetrachloroethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '127-18-4' and x.name = 'Tetrachloroethylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '127-19-5', 'Dimethyl Acetamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '127-19-5' and x.name = 'Dimethyl Acetamide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '127-65-1', 'Chloramine-T', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '127-65-1' and x.name = 'Chloramine-T' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '127-91-3', 'beta-Pinene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '127-91-3' and x.name = 'beta-Pinene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '128-37-0', '2,6-Di-tert-Butyl-p-Cresol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '128-37-0' and x.name = '2,6-Di-tert-Butyl-p-Cresol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '128-39-2', '2,6-Di-Tert-Butylphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '128-39-2' and x.name = '2,6-Di-Tert-Butylphenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '129-00-0', 'Pyrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '129-00-0' and x.name = 'Pyrene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '129-79-3', '2,4,7-Trinitro-9-fluorenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '129-79-3' and x.name = '2,4,7-Trinitro-9-fluorenone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '131-11-3', 'Dimethylphthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '131-11-3' and x.name = 'Dimethylphthalate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '131-17-9', 'Diallyl Phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '131-17-9' and x.name = 'Diallyl Phthalate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '131-52-2', 'Sodium Pentachlorophenate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '131-52-2' and x.name = 'Sodium Pentachlorophenate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '132-27-4', 'Sodium o-Phenyl Phenate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '132-27-4' and x.name = 'Sodium o-Phenyl Phenate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '132-33-2', 'Thoron', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '132-33-2' and x.name = 'Thoron' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '132-64-9', 'Dibenzofuran', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '132-64-9' and x.name = 'Dibenzofuran' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '133-06-2', 'Captan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '133-06-2' and x.name = 'Captan' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '133-07-3', 'N-(Trichloromethylthio)phthalimide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '133-07-3' and x.name = 'N-(Trichloromethylthio)phthalimide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '133-90-4', 'Amiben', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '133-90-4' and x.name = 'Amiben' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '134-32-7', 'alpha-Naphthylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '134-32-7' and x.name = 'alpha-Naphthylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '134-81-6', 'Benzil', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '134-81-6' and x.name = 'Benzil' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '135-01-3', 'o-Diethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '135-01-3' and x.name = 'o-Diethylbenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '135-19-3', 'beta-Naphthol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '135-19-3' and x.name = 'beta-Naphthol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '135-88-6', 'N-Phenyl-2-Naphthylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '135-88-6' and x.name = 'N-Phenyl-2-Naphthylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '135-98-8', 'sec-Butylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '135-98-8' and x.name = 'sec-Butylbenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '136-23-2', 'Zinc Dibutyldithiocarbamate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '136-23-2' and x.name = 'Zinc Dibutyldithiocarbamate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '136-78-7', 'Crag Herbicide (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '136-78-7' and x.name = 'Crag Herbicide (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '136-78-7', 'Crag Herbicide (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '136-78-7' and x.name = 'Crag Herbicide (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '137-05-3', 'Methyl 2-Cyanoacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '137-05-3' and x.name = 'Methyl 2-Cyanoacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '137-26-8', 'Thiram', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '137-26-8' and x.name = 'Thiram' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '137-30-4', 'Ziram', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '137-30-4' and x.name = 'Ziram' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '137-41-7', 'Wemcide CW 104', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '137-41-7' and x.name = 'Wemcide CW 104' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '137-42-8', 'Metham Sodium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '137-42-8' and x.name = 'Metham Sodium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '138-22-7', 'n-Butyl Lactate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '138-22-7' and x.name = 'n-Butyl Lactate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '138-86-3', 'Limonene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '138-86-3' and x.name = 'Limonene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '138-93-2', '2-(2,4-Dinitrophenoxy)ethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '138-93-2' and x.name = '2-(2,4-Dinitrophenoxy)ethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '139-89-9', 'N-Hydroxyethylethylenediaminetriacetate Trisodium salt', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '139-89-9' and x.name = 'N-Hydroxyethylethylenediaminetriacetate Trisodium salt' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '140-11-4', 'Benzyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '140-11-4' and x.name = 'Benzyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '140-31-8', 'N-Aminoethylpiperazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '140-31-8' and x.name = 'N-Aminoethylpiperazine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '140-64-7', 'Pentamine Isethionate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '140-64-7' and x.name = 'Pentamine Isethionate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '140-88-5', 'Ethyl Acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '140-88-5' and x.name = 'Ethyl Acrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '141-32-2', 'Butyl Acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '141-32-2' and x.name = 'Butyl Acrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '141-43-5', 'Ethanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '141-43-5' and x.name = 'Ethanolamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '141-66-2', 'Dicrotophos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '141-66-2' and x.name = 'Dicrotophos' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '141-78-6', 'Ethyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '141-78-6' and x.name = 'Ethyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '141-79-7', 'Mesityl Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '141-79-7' and x.name = 'Mesityl Oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '141-93-5', 'm-Diethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '141-93-5' and x.name = 'm-Diethylbenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '142-22-3', 'Allyl Diglycol Carbonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '142-22-3' and x.name = 'Allyl Diglycol Carbonate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '142-28-9', '1,3-Dichloropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '142-28-9' and x.name = '1,3-Dichloropropane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '142-64-3', 'Piperazine Dihydrochloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '142-64-3' and x.name = 'Piperazine Dihydrochloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '142-82-5', 'Heptane (n-Heptane)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '142-82-5' and x.name = 'Heptane (n-Heptane)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '142-84-7', 'Dipropylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '142-84-7' and x.name = 'Dipropylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '142-92-7', 'n-Hexyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '142-92-7' and x.name = 'n-Hexyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '142-96-1', 'Di-n-Butyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '142-96-1' and x.name = 'Di-n-Butyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '143-08-8', 'Nonyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '143-08-8' and x.name = 'Nonyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '143-22-6', 'Triethylene glycol monobutyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '143-22-6' and x.name = 'Triethylene glycol monobutyl ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '143-33-9', 'Sodium cyanide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '143-33-9' and x.name = 'Sodium cyanide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '143-50-0', 'Kepone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '143-50-0' and x.name = 'Kepone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '144-21-8', 'Disodium Acid Methane Arsenate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '144-21-8' and x.name = 'Disodium Acid Methane Arsenate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '144-62-7', 'Oxalic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '144-62-7' and x.name = 'Oxalic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '144-83-2', 'Sulfapyridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '144-83-2' and x.name = 'Sulfapyridine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '148-01-6', 'Dinitolmide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '148-01-6' and x.name = 'Dinitolmide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '148-79-8', 'Thiabendazole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '148-79-8' and x.name = 'Thiabendazole' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '149-30-4', '2-Benzothiazolethiol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '149-30-4' and x.name = '2-Benzothiazolethiol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '150-19-6', '3-Methoxyphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '150-19-6' and x.name = '3-Methoxyphenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '150-76-5', '4-Methoxyphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '150-76-5' and x.name = '4-Methoxyphenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '151-21-3', 'Sodium Lauryl Sulfate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '151-21-3' and x.name = 'Sodium Lauryl Sulfate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '151-50-8', 'Potassium cyanide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '151-50-8' and x.name = 'Potassium cyanide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '151-56-4', 'Ethyleneimine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '151-56-4' and x.name = 'Ethyleneimine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '151-67-7', 'Halothane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '151-67-7' and x.name = 'Halothane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '152-11-4', '(¦)-Verapamil hydrochloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '152-11-4' and x.name = '(¦)-Verapamil hydrochloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '156-62-7', 'Calcium Cyanamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '156-62-7' and x.name = 'Calcium Cyanamide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '156-87-6', '3-Amino-1-Propanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '156-87-6' and x.name = '3-Amino-1-Propanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '191-07-1', 'Coronene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '191-07-1' and x.name = 'Coronene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '191-24-2', 'Benzo(g,h,i)perylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '191-24-2' and x.name = 'Benzo(g,h,i)perylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '192-97-2', 'Benzo (e) Pyrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '192-97-2' and x.name = 'Benzo (e) Pyrene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '193-39-5', 'Ideneo(1,2,3-cd)pyrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '193-39-5' and x.name = 'Ideneo(1,2,3-cd)pyrene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '198-55-0', 'Perylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '198-55-0' and x.name = 'Perylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '205-99-2', 'Benzo(b)fluoranthene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '205-99-2' and x.name = 'Benzo(b)fluoranthene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '206-44-0', 'Fluoranthene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '206-44-0' and x.name = 'Fluoranthene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '207-08-9', 'Benzo(k)fluoranthene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '207-08-9' and x.name = 'Benzo(k)fluoranthene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '208-96-8', 'Acenaphthylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '208-96-8' and x.name = 'Acenaphthylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '218-01-9', 'Chrysene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '218-01-9' and x.name = 'Chrysene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '260-94-6', 'Acridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '260-94-6' and x.name = 'Acridine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '271-89-6', '2,3-Benzofuran', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '271-89-6' and x.name = '2,3-Benzofuran' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '280-57-9', 'Triethylenediamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '280-57-9' and x.name = 'Triethylenediamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '287-92-3', 'Cyclopentane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '287-92-3' and x.name = 'Cyclopentane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '298-00-0', 'Methyl Parathion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '298-00-0' and x.name = 'Methyl Parathion' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '298-02-2', 'Phorate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '298-02-2' and x.name = 'Phorate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '298-04-4', 'Disulfoton', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '298-04-4' and x.name = 'Disulfoton' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '299-84-3', 'Ronnel', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '299-84-3' and x.name = 'Ronnel' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '299-86-5', 'Crufomate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '299-86-5' and x.name = 'Crufomate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '300-76-5', 'Dimethyl-1,2-dibromo-2,2-dichloroethyl phosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '300-76-5' and x.name = 'Dimethyl-1,2-dibromo-2,2-dichloroethyl phosphate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '301-10-0', 'Stannous-2-Ethyl Hexanoate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '301-10-0' and x.name = 'Stannous-2-Ethyl Hexanoate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '301-12-2', 'Oxydemeton-Methyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '301-12-2' and x.name = 'Oxydemeton-Methyl' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '302-01-2', 'Hydrazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '302-01-2' and x.name = 'Hydrazine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '306-83-2', '2,2-Dichloro-1,1,1-trifluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '306-83-2' and x.name = '2,2-Dichloro-1,1,1-trifluoroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '309-00-2', 'Aldrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '309-00-2' and x.name = 'Aldrin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '314-40-9', 'Bromacil', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '314-40-9' and x.name = 'Bromacil' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '315-18-4', 'Zectran', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '315-18-4' and x.name = 'Zectran' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '321-55-1', 'Haloxon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '321-55-1' and x.name = 'Haloxon' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '330-54-1', 'Diuron', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '330-54-1' and x.name = 'Diuron' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '330-55-2', 'Linuron', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '330-55-2' and x.name = 'Linuron' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '333-41-5', 'Diazinon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '333-41-5' and x.name = 'Diazinon' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '334-88-3', 'Diazomethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '334-88-3' and x.name = 'Diazomethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '352-93-2', 'Diethyl Sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '352-93-2' and x.name = 'Diethyl Sulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '353-50-4', 'Carbonyl Fluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '353-50-4' and x.name = 'Carbonyl Fluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '353-66-2', 'Difluorodimethylsilane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '353-66-2' and x.name = 'Difluorodimethylsilane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '354-23-4', '1,2-Dichloro-1,1,2-Trifluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '354-23-4' and x.name = '1,2-Dichloro-1,1,2-Trifluoroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '354-58-5', '1,1,1-Trichloro-2,2,2-Trifluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '354-58-5' and x.name = '1,1,1-Trichloro-2,2,2-Trifluoroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '357-57-3', 'Brucine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '357-57-3' and x.name = 'Brucine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '374-07-2', '1,1-Dichlorotetrafluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '374-07-2' and x.name = '1,1-Dichlorotetrafluoroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '382-21-8', 'Perfluoroisobutylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '382-21-8' and x.name = 'Perfluoroisobutylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '404-86-4', 'Capsaicin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '404-86-4' and x.name = 'Capsaicin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '407-25-0', 'Trifluoroacetic Anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '407-25-0' and x.name = 'Trifluoroacetic Anhydride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '409-21-2', 'Silicon Carbide (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '409-21-2' and x.name = 'Silicon Carbide (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '409-21-2', 'Silicon Carbide (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '409-21-2' and x.name = 'Silicon Carbide (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '420-04-2', 'Cyanamide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '420-04-2' and x.name = 'Cyanamide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '420-46-2', '1,1,1-Trifluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '420-46-2' and x.name = '1,1,1-Trifluoroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '422-56-0', '3,3-Dichloro-1,1,1,2,2-pentafluoropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '422-56-0' and x.name = '3,3-Dichloro-1,1,1,2,2-pentafluoropropane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '431-03-8', 'Diacetyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '431-03-8' and x.name = 'Diacetyl' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '460-19-5', 'Cyanogen', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '460-19-5' and x.name = 'Cyanogen' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '461-58-5', 'Cyanoguanidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '461-58-5' and x.name = 'Cyanoguanidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '462-08-8', '3-Aminopyridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '462-08-8' and x.name = '3-Aminopyridine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '463-04-7', 'Amyl Nitrite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '463-04-7' and x.name = 'Amyl Nitrite' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '463-51-4', 'Ketene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '463-51-4' and x.name = 'Ketene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '463-58-1', 'Carbonyl Sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '463-58-1' and x.name = 'Carbonyl Sulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '471-34-1', 'Calcium Carbonate (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '471-34-1' and x.name = 'Calcium Carbonate (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '477-73-6', 'Basic Red 2', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '477-73-6' and x.name = 'Basic Red 2' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '479-45-8', 'Tetryl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '479-45-8' and x.name = 'Tetryl' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '485-47-2', '2,2-Dihydroxy-1,3-Indandione', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '485-47-2' and x.name = '2,2-Dihydroxy-1,3-Indandione' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '486-25-9', '9-Fluorenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '486-25-9' and x.name = '9-Fluorenone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '488-23-3', '1,2,3,4-Tetramethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '488-23-3' and x.name = '1,2,3,4-Tetramethylbenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '492-80-8', 'Benzenamine, 4,4'' Carbonimidoyl bis(N,N'' dimethyl-)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '492-80-8' and x.name = 'Benzenamine, 4,4'' Carbonimidoyl bis(N,N'' dimethyl-)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '497-19-8', 'Sodium Carbonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '497-19-8' and x.name = 'Sodium Carbonate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '497-23-4', '2(5H)-Furanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '497-23-4' and x.name = '2(5H)-Furanone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '503-30-0', '1,3-Epoxypropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '503-30-0' and x.name = '1,3-Epoxypropane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '504-24-5', '4-Aminopyridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '504-24-5' and x.name = '4-Aminopyridine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '504-29-0', '2-Aminopyridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '504-29-0' and x.name = '2-Aminopyridine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '504-60-9', '1,3-Pentadiene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '504-60-9' and x.name = '1,3-Pentadiene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '505-60-2', 'bis-(2-Chloroethyl)sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '505-60-2' and x.name = 'bis-(2-Chloroethyl)sulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '506-77-4', 'Cyanogen Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '506-77-4' and x.name = 'Cyanogen Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '507-55-1', '1,3-Dichloro-1,1,2,2,3-pentafluoropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '507-55-1' and x.name = '1,3-Dichloro-1,1,2,2,3-pentafluoropropane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '509-14-8', 'Tetranitromethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '509-14-8' and x.name = 'Tetranitromethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '510-15-6', 'Ethyl-4,4''-Dichlorobenzilate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '510-15-6' and x.name = 'Ethyl-4,4''-Dichlorobenzilate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '513-86-0', 'Acetyl Methyl Carbinol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '513-86-0' and x.name = 'Acetyl Methyl Carbinol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '514-10-3', 'Abietic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '514-10-3' and x.name = 'Abietic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '527-07-1', 'Sodium Gluconate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '527-07-1' and x.name = 'Sodium Gluconate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '527-53-7', '1,2,3,5-Tetramethylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '527-53-7' and x.name = '1,2,3,5-Tetramethylbenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '528-44-9', 'Trimellitic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '528-44-9' and x.name = 'Trimellitic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '529-20-4', 'Tolualdehyde (o, m and p isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '529-20-4' and x.name = 'Tolualdehyde (o, m and p isomers)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '532-27-4', 'alpha-Chloroacetophenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '532-27-4' and x.name = 'alpha-Chloroacetophenone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '533-60-8', '2-Hydroxycyclohexanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '533-60-8' and x.name = '2-Hydroxycyclohexanone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '534-52-1', 'Dinitro-o-cresol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '534-52-1' and x.name = 'Dinitro-o-cresol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '538-93-2', 'Isobutylbenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '538-93-2' and x.name = 'Isobutylbenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '539-48-0', 'p-Xylene-alpha,alpha''-diamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '539-48-0' and x.name = 'p-Xylene-alpha,alpha''-diamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '540-59-0', '1,2-Dichloroethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '540-59-0' and x.name = '1,2-Dichloroethylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '540-67-0', 'Ethyl Methyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '540-67-0' and x.name = 'Ethyl Methyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '540-88-5', 'tert-Butyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '540-88-5' and x.name = 'tert-Butyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '541-02-6', 'Decamethylcyclopentasiloxane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '541-02-6' and x.name = 'Decamethylcyclopentasiloxane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '541-05-9', 'Hexamethylcyclotrisiloxane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '541-05-9' and x.name = 'Hexamethylcyclotrisiloxane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '541-73-1', 'm-Dichlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '541-73-1' and x.name = 'm-Dichlorobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '541-85-5', 'Ethyl Amyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '541-85-5' and x.name = 'Ethyl Amyl Ketone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '542-56-3', 'Isobutyl Nitrite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '542-56-3' and x.name = 'Isobutyl Nitrite' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '542-75-6', '1,3-Dichloropropene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '542-75-6' and x.name = '1,3-Dichloropropene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '542-88-1', 'Bis(Chloromethyl) Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '542-88-1' and x.name = 'Bis(Chloromethyl) Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '542-92-7', 'Cyclopentadiene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '542-92-7' and x.name = 'Cyclopentadiene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '543-49-7', 'Isoheptanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '543-49-7' and x.name = 'Isoheptanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '546-93-0', 'Magnesium carbonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '546-93-0' and x.name = 'Magnesium carbonate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '547-63-7', 'Methyl Isobutyrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '547-63-7' and x.name = 'Methyl Isobutyrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '548-62-9', 'Gentian Violet', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '548-62-9' and x.name = 'Gentian Violet' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '551-06-4', '1-Naphthylisothiocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '551-06-4' and x.name = '1-Naphthylisothiocyanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '552-30-7', 'Trimellitic Anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '552-30-7' and x.name = 'Trimellitic Anhydride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '554-14-3', '2-Methylthiophene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '554-14-3' and x.name = '2-Methylthiophene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '555-77-1', 'tris-(2-Chloroethyl)amine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '555-77-1' and x.name = 'tris-(2-Chloroethyl)amine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '556-52-5', 'Glycidol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '556-52-5' and x.name = 'Glycidol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '556-61-6', 'Methyl Isothiocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '556-61-6' and x.name = 'Methyl Isothiocyanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '556-64-9', 'Methyl Thiocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '556-64-9' and x.name = 'Methyl Thiocyanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '556-67-2', 'Octamethylcyclotetrasiloxane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '556-67-2' and x.name = 'Octamethylcyclotetrasiloxane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '557-05-1', 'Zinc Stearate (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '557-05-1' and x.name = 'Zinc Stearate (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '557-05-1', 'Zinc Stearate (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '557-05-1' and x.name = 'Zinc Stearate (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '557-75-5', 'Vinyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '557-75-5' and x.name = 'Vinyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '558-13-4', 'Carbon Tetrabromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '558-13-4' and x.name = 'Carbon Tetrabromide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '561-27-3', 'Heroin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '561-27-3' and x.name = 'Heroin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '563-12-2', 'Ethion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '563-12-2' and x.name = 'Ethion' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '563-16-6', '3,3-Dimethylhexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '563-16-6' and x.name = '3,3-Dimethylhexane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '563-80-4', 'Methyl Isopropyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '563-80-4' and x.name = 'Methyl Isopropyl Ketone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '571-58-4', '1,4-Dimethylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '571-58-4' and x.name = '1,4-Dimethylnaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '573-98-8', '1,2-Dimethylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '573-98-8' and x.name = '1,2-Dimethylnaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '575-41-7', '1,3-Dimethylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '575-41-7' and x.name = '1,3-Dimethylnaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '575-43-9', '1,6-Dimethylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '575-43-9' and x.name = '1,6-Dimethylnaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '583-48-2', '3,4-Dimethylhexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '583-48-2' and x.name = '3,4-Dimethylhexane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '583-60-8', 'o-Methylcyclohexanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '583-60-8' and x.name = 'o-Methylcyclohexanone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '584-79-2', 'Allethrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '584-79-2' and x.name = 'Allethrin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '584-84-9', 'Toluene-2,4-Diisocyanate (TDI)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '584-84-9' and x.name = 'Toluene-2,4-Diisocyanate (TDI)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '584-94-1', '2,3-Dimethylhexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '584-94-1' and x.name = '2,3-Dimethylhexane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '589-43-5', '2,4-Dimethylhexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '589-43-5' and x.name = '2,4-Dimethylhexane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '589-81-1', 'Methylheptane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '589-81-1' and x.name = 'Methylheptane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '590-73-8', '2,2-Dimethylhexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '590-73-8' and x.name = '2,2-Dimethylhexane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '590-86-3', 'Isovalderaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '590-86-3' and x.name = 'Isovalderaldehyde' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '591-78-6', '2-Hexanone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '591-78-6' and x.name = '2-Hexanone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '591-87-7', 'Allyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '591-87-7' and x.name = 'Allyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '592-01-8', 'Calcium cyanide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '592-01-8' and x.name = 'Calcium cyanide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '592-13-2', '2,5-Dimethylhexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '592-13-2' and x.name = '2,5-Dimethylhexane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '592-41-6', '1-Hexene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '592-41-6' and x.name = '1-Hexene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '592-76-7', '1-Heptene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '592-76-7' and x.name = '1-Heptene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '593-60-2', 'Vinyl Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '593-60-2' and x.name = 'Vinyl Bromide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '594-27-4', 'Tetramethyl Tin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '594-27-4' and x.name = 'Tetramethyl Tin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '594-42-3', 'Perchloromethyl Mercaptan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '594-42-3' and x.name = 'Perchloromethyl Mercaptan' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '594-72-9', '1,1-Dichloro-1-Nitroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '594-72-9' and x.name = '1,1-Dichloro-1-Nitroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '597-64-8', 'Tetraethyl Tin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '597-64-8' and x.name = 'Tetraethyl Tin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '598-16-3', 'Tribromoethylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '598-16-3' and x.name = 'Tribromoethylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '598-56-1', 'Dimethylethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '598-56-1' and x.name = 'Dimethylethylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '600-25-9', '1-Chloro-1-Nitropropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '600-25-9' and x.name = '1-Chloro-1-Nitropropane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '601-77-4', 'N-Nitrosodiisopropylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '601-77-4' and x.name = 'N-Nitrosodiisopropylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '603-34-9', 'Triphenylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '603-34-9' and x.name = 'Triphenylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '605-02-7', '1-Phenylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '605-02-7' and x.name = '1-Phenylnaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '608-93-5', 'Pentachlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '608-93-5' and x.name = 'Pentachlorobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '611-14-3', 'Ethyl Toluene (all isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '611-14-3' and x.name = 'Ethyl Toluene (all isomers)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '612-94-2', '2-Phenylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '612-94-2' and x.name = '2-Phenylnaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '614-44-4', '3-Methylthiophene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '614-44-4' and x.name = '3-Methylthiophene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '614-68-6', 'o-Tolyl Isocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '614-68-6' and x.name = 'o-Tolyl Isocyanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '615-05-4', '2,4-Diaminoanisole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '615-05-4' and x.name = '2,4-Diaminoanisole' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '617-94-7', 'Phenyl Isopropanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '617-94-7' and x.name = 'Phenyl Isopropanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '620-23-5', 'Tolualdehyde (o, m and p isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '620-23-5' and x.name = 'Tolualdehyde (o, m and p isomers)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '621-64-7', 'N-Nitrosodipropylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '621-64-7' and x.name = 'N-Nitrosodipropylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '622-40-2', 'N-(2-Hydroxyethyl)Morpholine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '622-40-2' and x.name = 'N-(2-Hydroxyethyl)Morpholine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '623-56-3', 'Ethyl Isobutyl Ketone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '623-56-3' and x.name = 'Ethyl Isobutyl Ketone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '624-78-2', 'Methylethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '624-78-2' and x.name = 'Methylethylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '624-83-9', 'Methyl Isocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '624-83-9' and x.name = 'Methyl Isocyanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '624-92-0', 'Dimethyl Disulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '624-92-0' and x.name = 'Dimethyl Disulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '626-17-5', 'm-Phthalodinitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '626-17-5' and x.name = 'm-Phthalodinitrile' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '626-38-0', 'sec-Amyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '626-38-0' and x.name = 'sec-Amyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '626-67-5', 'N-Methylpiperidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '626-67-5' and x.name = 'N-Methylpiperidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '627-13-4', 'n-Propyl Nitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '627-13-4' and x.name = 'n-Propyl Nitrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '627-51-0', 'Divinyl Sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '627-51-0' and x.name = 'Divinyl Sulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '627-93-0', 'Dimethyl Adipate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '627-93-0' and x.name = 'Dimethyl Adipate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '628-63-7', 'n-Amyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '628-63-7' and x.name = 'n-Amyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '628-96-6', 'Ethylene Glycol Dinitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '628-96-6' and x.name = 'Ethylene Glycol Dinitrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '629-11-8', '1,6-Hexanediol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '629-11-8' and x.name = '1,6-Hexanediol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '629-14-1', 'Ethylene Glycol Diethyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '629-14-1' and x.name = 'Ethylene Glycol Diethyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '629-19-6', 'Dipropyl Disulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '629-19-6' and x.name = 'Dipropyl Disulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '630-08-0', 'Carbon Monoxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '630-08-0' and x.name = 'Carbon Monoxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '630-08-0', 'Carbon Monoxide (by COHb)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '630-08-0' and x.name = 'Carbon Monoxide (by COHb)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '632-99-5', 'Rosaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '632-99-5' and x.name = 'Rosaniline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '634-90-2', '1,2,3,5-Tetrachlorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '634-90-2' and x.name = '1,2,3,5-Tetrachlorobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '637-50-3', 'beta-Methyl Styrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '637-50-3' and x.name = 'beta-Methyl Styrene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '637-92-3', 'Ethyl tert-butyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '637-92-3' and x.name = 'Ethyl tert-butyl ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '638-21-1', 'Phenylphosphine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '638-21-1' and x.name = 'Phenylphosphine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '646-06-0', '1,3-Dioxalane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '646-06-0' and x.name = '1,3-Dioxalane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '680-31-9', 'Hexamethyl phosphoramide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '680-31-9' and x.name = 'Hexamethyl phosphoramide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '681-84-5', 'Methyl Silicate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '681-84-5' and x.name = 'Methyl Silicate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '684-16-2', 'Hexafluoroacetone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '684-16-2' and x.name = 'Hexafluoroacetone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '693-98-1', '2-Methylimidazole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '693-98-1' and x.name = '2-Methylimidazole' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '707-07-3', 'Trimethyl orthobenzoate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '707-07-3' and x.name = 'Trimethyl orthobenzoate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '709-98-8', '3,4-Dichloropropionanilide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '709-98-8' and x.name = '3,4-Dichloropropionanilide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '732-11-6', 'Phosmet', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '732-11-6' and x.name = 'Phosmet' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '741-58-2', 'Betasan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '741-58-2' and x.name = 'Betasan' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '759-94-4', 'Dipropylthiocarbamic Acid S-Ethyl Ester', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '759-94-4' and x.name = 'Dipropylthiocarbamic Acid S-Ethyl Ester' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '763-69-9', 'Ethyl-3-ethoxypropionate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '763-69-9' and x.name = 'Ethyl-3-ethoxypropionate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '766-97-2', 'p-Methylphenylacetylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '766-97-2' and x.name = 'p-Methylphenylacetylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '768-52-5', 'N-Isopropylaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '768-52-5' and x.name = 'N-Isopropylaniline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '786-19-6', 'Carbophenothion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '786-19-6' and x.name = 'Carbophenothion' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '811-97-2', '1,1,1,2-Tetrafluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '811-97-2' and x.name = '1,1,1,2-Tetrafluoroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '818-61-1', 'Hydroxyethyl Acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '818-61-1' and x.name = 'Hydroxyethyl Acrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '822-06-0', 'Hexamethylene Diisocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '822-06-0' and x.name = 'Hexamethylene Diisocyanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '823-40-5', 'Toluene-2,6-Diamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '823-40-5' and x.name = 'Toluene-2,6-Diamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '824-78-2', 'Sodium p-Nitrophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '824-78-2' and x.name = 'Sodium p-Nitrophenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '836-30-6', '4-Nitrodiphenylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '836-30-6' and x.name = '4-Nitrodiphenylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '842-07-9', 'Sudan I', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '842-07-9' and x.name = 'Sudan I' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '868-77-9', '2-Hydroxyethyl Methacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '868-77-9' and x.name = '2-Hydroxyethyl Methacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '872-50-4', '1-Methyl-2-Pyrrolidinone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '872-50-4' and x.name = '1-Methyl-2-Pyrrolidinone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '924-16-3', 'N-Nitrosodibutylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '924-16-3' and x.name = 'N-Nitrosodibutylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '929-06-6', 'Diglycolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '929-06-6' and x.name = 'Diglycolamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '930-55-2', 'N-Nitrosopyrrolidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '930-55-2' and x.name = 'N-Nitrosopyrrolidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '939-27-5', '2-Ethylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '939-27-5' and x.name = '2-Ethylnaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '944-22-9', 'Fonofos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '944-22-9' and x.name = 'Fonofos' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '947-92-2', 'Dicyclohexylnitrosamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '947-92-2' and x.name = 'Dicyclohexylnitrosamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '950-37-8', 'Methidathion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '950-37-8' and x.name = 'Methidathion' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '961-11-5', 'Rabon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '961-11-5' and x.name = 'Rabon' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '987-24-6', 'Betamethasone Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '987-24-6' and x.name = 'Betamethasone Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '992-59-6', 'Direct Red 2', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '992-59-6' and x.name = 'Direct Red 2' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '999-61-1', '2-Hydroxypropyl Acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '999-61-1' and x.name = '2-Hydroxypropyl Acrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '999-97-3', 'Hexamethyldisilazane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '999-97-3' and x.name = 'Hexamethyldisilazane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1025-15-6', 'Trially Isocyanurate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1025-15-6' and x.name = 'Trially Isocyanurate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1066-40-6', 'Trimethylsilanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1066-40-6' and x.name = 'Trimethylsilanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1076-38-6', '4-Hydroxycoumarin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1076-38-6' and x.name = '4-Hydroxycoumarin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1076-43-3', 'Hexadeutorobenzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1076-43-3' and x.name = 'Hexadeutorobenzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1078-19-9', '6-Methoxytetralone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1078-19-9' and x.name = '6-Methoxytetralone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1111-78-0', 'Ammonium Carbamate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1111-78-0' and x.name = 'Ammonium Carbamate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1116-54-7', 'N-Nitrosodiethanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1116-54-7' and x.name = 'N-Nitrosodiethanolamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1118-46-3', 'Butyltin Trichloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1118-46-3' and x.name = 'Butyltin Trichloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1119-40-0', 'Dimethyl Glutarate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1119-40-0' and x.name = 'Dimethyl Glutarate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1120-21-4', 'Undecane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1120-21-4' and x.name = 'Undecane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1127-76-0', '1-Ethylnaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1127-76-0' and x.name = '1-Ethylnaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1138-52-9', '3,5-Di-Tert-Butylphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1138-52-9' and x.name = '3,5-Di-Tert-Butylphenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1141-16-5', 'Chlorodiphenyl (32% Cl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1141-16-5' and x.name = 'Chlorodiphenyl (32% Cl)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1162-65-8', 'Aflatoxin (B1)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1162-65-8' and x.name = 'Aflatoxin (B1)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1163-19-5', 'Decabromodiphenyl Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1163-19-5' and x.name = 'Decabromodiphenyl Oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1165-39-5', 'Aflatoxin (G1)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1165-39-5' and x.name = 'Aflatoxin (G1)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1189-85-1', 'tert-Butyl Chromate (as CrO3)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1189-85-1' and x.name = 'tert-Butyl Chromate (as CrO3)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1239-45-8', 'Ethidium Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1239-45-8' and x.name = 'Ethidium Bromide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1300-71-6', 'Xylenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1300-71-6' and x.name = 'Xylenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1300-73-8', 'Xylidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1300-73-8' and x.name = 'Xylidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1302-74-5', 'Corundum', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1302-74-5' and x.name = 'Corundum' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1303-43-4', 'Borates, Tetra, Sodium Salts, Anhydrous', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1303-43-4' and x.name = 'Borates, Tetra, Sodium Salts, Anhydrous' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1303-86-2', 'Boron Oxide (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1303-86-2' and x.name = 'Boron Oxide (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1303-96-4', 'Borates, Tetra, Sodium Salts, Decahydrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1303-96-4' and x.name = 'Borates, Tetra, Sodium Salts, Decahydrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1304-82-1', 'Bismuth Telluride, Se Doped', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1304-82-1' and x.name = 'Bismuth Telluride, Se Doped' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1304-82-1', 'Bismuth Telluride, Undoped (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1304-82-1' and x.name = 'Bismuth Telluride, Undoped (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1304-82-1', 'Bismuth Telluride, Undoped (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1304-82-1' and x.name = 'Bismuth Telluride, Undoped (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1305-62-0', 'Calcium Hydroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1305-62-0' and x.name = 'Calcium Hydroxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1305-78-8', 'Calcium Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1305-78-8' and x.name = 'Calcium Oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1306-19-0', 'Cadmium Fume (as Cd)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1306-19-0' and x.name = 'Cadmium Fume (as Cd)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1309-37-1', 'Iron Oxide Fume', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1309-37-1' and x.name = 'Iron Oxide Fume' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1309-37-1', 'Rouge (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1309-37-1' and x.name = 'Rouge (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1309-37-1', 'Rouge (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1309-37-1' and x.name = 'Rouge (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1309-48-4', 'Magnesium Oxide Fume (Total Particulate)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1309-48-4' and x.name = 'Magnesium Oxide Fume (Total Particulate)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1310-58-3', 'Potassium Hydroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1310-58-3' and x.name = 'Potassium Hydroxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1310-73-2', 'Sodium Hydroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1310-73-2' and x.name = 'Sodium Hydroxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-13-2', 'Zinc Oxide (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-13-2' and x.name = 'Zinc Oxide (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-13-2', 'Zinc Oxide (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-13-2' and x.name = 'Zinc Oxide (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-13-2', 'Zinc Oxide Fume', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-13-2' and x.name = 'Zinc Oxide Fume' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-20-1', 'Thorium Dioxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-20-1' and x.name = 'Thorium Dioxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-56-3', 'Phosphorus Pentoxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-56-3' and x.name = 'Phosphorus Pentoxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-62-1', 'Vanadium fume (as V2O5)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-62-1' and x.name = 'Vanadium fume (as V2O5)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-62-1', 'Vanadium, Respirable Dust (as V2O5)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-62-1' and x.name = 'Vanadium, Respirable Dust (as V2O5)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-62-1', 'Vanadium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-62-1' and x.name = 'Vanadium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1314-80-3', 'Phosphorus Pentasulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1314-80-3' and x.name = 'Phosphorus Pentasulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-35-7', 'Manganese Tetroxide (as Mn)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-35-7' and x.name = 'Manganese Tetroxide (as Mn)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-36-8', 'lead monoxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-36-8' and x.name = 'lead monoxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-65-3', 'Calcium Carbonate (Respirable Fraction), OSHA/NIOSH', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-65-3' and x.name = 'Calcium Carbonate (Respirable Fraction), OSHA/NIOSH' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-65-3', 'Calcium Carbonate (Total Dust), OSHA/NIOSH', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-65-3' and x.name = 'Calcium Carbonate (Total Dust), OSHA/NIOSH' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-65-3', 'Limestone (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-65-3' and x.name = 'Limestone (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-65-3', 'Limestone (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-65-3' and x.name = 'Limestone (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-65-3', 'Marble (Respirable Fraction), OSHA/NIOSH', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-65-3' and x.name = 'Marble (Respirable Fraction), OSHA/NIOSH' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-65-3', 'Marble (Total Dust), OSHA/NIOSH', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-65-3' and x.name = 'Marble (Total Dust), OSHA/NIOSH' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1317-95-9', 'Silica, Crystalline Tripoli (as Quartz), Respirable Dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1317-95-9' and x.name = 'Silica, Crystalline Tripoli (as Quartz), Respirable Dust' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1319-77-3', 'Cresol (All Isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1319-77-3' and x.name = 'Cresol (All Isomers)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1321-64-8', 'Pentachloronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1321-64-8' and x.name = 'Pentachloronaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1321-65-9', 'Trichloronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1321-65-9' and x.name = 'Trichloronaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1321-74-0', 'Divinyl Benzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1321-74-0' and x.name = 'Divinyl Benzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1321-94-4', 'Methyl Naphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1321-94-4' and x.name = 'Methyl Naphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1330-20-7', 'Xylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1330-20-7' and x.name = 'Xylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1332-21-4', 'Asbestos (Action Level, State of Oregon Only)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1332-21-4' and x.name = 'Asbestos (Action Level, State of Oregon Only)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1332-21-4', 'Asbestos (all forms)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1332-21-4' and x.name = 'Asbestos (all forms)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1332-29-2', 'Tin Oxide (as Sn) (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1332-29-2' and x.name = 'Tin Oxide (as Sn) (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1332-58-7', 'Kaolin (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1332-58-7' and x.name = 'Kaolin (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1332-58-7', 'Kaolin (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1332-58-7' and x.name = 'Kaolin (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1333-74-0', 'Hydrogen', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1333-74-0' and x.name = 'Hydrogen' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1333-82-0', 'chromium (VI) trioxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1333-82-0' and x.name = 'chromium (VI) trioxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1333-86-4', 'Carbon Black', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1333-86-4' and x.name = 'Carbon Black' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1335-87-1', 'Hexachloronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1335-87-1' and x.name = 'Hexachloronaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1335-88-2', 'Tetrachloronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1335-88-2' and x.name = 'Tetrachloronaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1338-23-4', 'Methyl Ethyl Ketone Peroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1338-23-4' and x.name = 'Methyl Ethyl Ketone Peroxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1344-28-1', 'alpha-Alumina (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1344-28-1' and x.name = 'alpha-Alumina (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1344-28-1', 'alpha-Alumina (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1344-28-1' and x.name = 'alpha-Alumina (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1344-38-3', 'basic lead chromate orange', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1344-38-3' and x.name = 'basic lead chromate orange' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1344-95-2', 'Calcium Silicate (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1344-95-2' and x.name = 'Calcium Silicate (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1344-95-2', 'Calcium Silicate (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1344-95-2' and x.name = 'Calcium Silicate (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1395-21-7', 'Subtilisins', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1395-21-7' and x.name = 'Subtilisins' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1401-55-4', 'Tannin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1401-55-4' and x.name = 'Tannin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1402-68-2', 'Aflatoxin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1402-68-2' and x.name = 'Aflatoxin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1477-55-0', 'm-Xylene-alpha,alpha''-diamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1477-55-0' and x.name = 'm-Xylene-alpha,alpha''-diamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1498-51-7', 'Ethyl dichlorophosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1498-51-7' and x.name = 'Ethyl dichlorophosphate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1499-10-1', '9,10-Diphenylanthracene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1499-10-1' and x.name = '9,10-Diphenylanthracene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1563-66-2', 'Carbofuran', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1563-66-2' and x.name = 'Carbofuran' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1569-02-4', '1-Ethoxy-2-propanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1569-02-4' and x.name = '1-Ethoxy-2-propanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1571-33-1', 'Benzenephosphonic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1571-33-1' and x.name = 'Benzenephosphonic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1582-09-8', 'Trifluralin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1582-09-8' and x.name = 'Trifluralin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1610-18-0', 'Pramitol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1610-18-0' and x.name = 'Pramitol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1634-04-4', 'tert-Butyl Methyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1634-04-4' and x.name = 'tert-Butyl Methyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1649-08-7', '1,2-Dichloro-1,1-Difluoroethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1649-08-7' and x.name = '1,2-Dichloro-1,1-Difluoroethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1675-54-3', 'Diglycidyl Ether of Bisphenol A', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1675-54-3' and x.name = 'Diglycidyl Ether of Bisphenol A' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1704-62-7', 'Dimethylaminoethoxy ethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1704-62-7' and x.name = 'Dimethylaminoethoxy ethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1738-25-6', 'Dimethylaminopropionitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1738-25-6' and x.name = 'Dimethylaminopropionitrile' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1740-19-3', 'Dehydroabietic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1740-19-3' and x.name = 'Dehydroabietic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1746-01-6', '2,3,7,8-Tetrachlorodibenzo-p-Dioxin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1746-01-6' and x.name = '2,3,7,8-Tetrachlorodibenzo-p-Dioxin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1817-73-8', '2,4-Dinitro-6-Bromoaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1817-73-8' and x.name = '2,4-Dinitro-6-Bromoaniline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1825-21-4', 'Pentachloroanisole', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1825-21-4' and x.name = 'Pentachloroanisole' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1861-32-1', 'Dimethyl 2,3,5,6-Tetrachloroterephthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1861-32-1' and x.name = 'Dimethyl 2,3,5,6-Tetrachloroterephthalate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1861-40-1', 'Benefin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1861-40-1' and x.name = 'Benefin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1897-45-6', 'Chlorothalonil', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1897-45-6' and x.name = 'Chlorothalonil' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1910-42-5', 'Paraquat dichloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1910-42-5' and x.name = 'Paraquat dichloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1912-24-9', 'Atrazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1912-24-9' and x.name = 'Atrazine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1918-00-9', 'Dicamba', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1918-00-9' and x.name = 'Dicamba' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1918-02-1', 'Picloram (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1918-02-1' and x.name = 'Picloram (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1918-02-1', 'Picloram (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1918-02-1' and x.name = 'Picloram (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1918-16-7', 'Ramrod', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1918-16-7' and x.name = 'Ramrod' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1929-82-4', '2-Chloro-6-(Trichloromethyl) Pyridine (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1929-82-4' and x.name = '2-Chloro-6-(Trichloromethyl) Pyridine (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1929-82-4', '2-Chloro-6-(Trichloromethyl) Pyridine (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1929-82-4' and x.name = '2-Chloro-6-(Trichloromethyl) Pyridine (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1937-37-7', 'Direct Black 38', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1937-37-7' and x.name = 'Direct Black 38' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1982-69-0', 'Dicamba, Sodium Salt', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1982-69-0' and x.name = 'Dicamba, Sodium Salt' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '1983-10-4', 'Tributyltin Fluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '1983-10-4' and x.name = 'Tributyltin Fluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2008-39-1', '2,4-D, Dimethylamine Salt', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2008-39-1' and x.name = '2,4-D, Dimethylamine Salt' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2039-87-4', 'o-Chlorostyrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2039-87-4' and x.name = 'o-Chlorostyrene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2074-50-2', 'Paraquat dimethyl sulfate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2074-50-2' and x.name = 'Paraquat dimethyl sulfate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2077-46-5', '2,3,6-Trichlorotoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2077-46-5' and x.name = '2,3,6-Trichlorotoluene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2104-64-5', 'EPN', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2104-64-5' and x.name = 'EPN' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2163-80-6', 'Monosodium Acid Methanearsonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2163-80-6' and x.name = 'Monosodium Acid Methanearsonate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2179-57-9', 'Diallyl Disulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2179-57-9' and x.name = 'Diallyl Disulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2179-59-1', 'Allyl Propyl Disulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2179-59-1' and x.name = 'Allyl Propyl Disulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2207-04-7', 'trans-1,4-Dimethylcyclohexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2207-04-7' and x.name = 'trans-1,4-Dimethylcyclohexane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2227-17-0', 'Pentac', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2227-17-0' and x.name = 'Pentac' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2234-13-1', 'Octachloronaphthalene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2234-13-1' and x.name = 'Octachloronaphthalene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2238-07-5', 'Diglycidyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2238-07-5' and x.name = 'Diglycidyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2385-85-5', 'Mirex', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2385-85-5' and x.name = 'Mirex' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2399-48-6', 'tetrahydrofurfuryl acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2399-48-6' and x.name = 'tetrahydrofurfuryl acrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2421-28-5', 'Benzophenonetetracarboxylic Acid Dianhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2421-28-5' and x.name = 'Benzophenonetetracarboxylic Acid Dianhydride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2422-91-5', 'Triphenylmethane Triisocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2422-91-5' and x.name = 'Triphenylmethane Triisocyanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2425-06-1', 'Captafol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2425-06-1' and x.name = 'Captafol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2425-79-8', '1,4-Butanediol diglycidyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2425-79-8' and x.name = '1,4-Butanediol diglycidyl ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2426-08-6', 'n-Butyl Glycidyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2426-08-6' and x.name = 'n-Butyl Glycidyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2429-73-4', 'Direct Blue 2', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2429-73-4' and x.name = 'Direct Blue 2' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2429-81-4', 'Direct Brown 31', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2429-81-4' and x.name = 'Direct Brown 31' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2439-10-3', 'Dodine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2439-10-3' and x.name = 'Dodine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2451-62-9', '1,3,5-Triglycidyl Isocyanurate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2451-62-9' and x.name = '1,3,5-Triglycidyl Isocyanurate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2465-27-2', 'Aniline, 4,4'' - (imidocarbonyl) bis (N,N - dimethyl - , hydrochloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2465-27-2' and x.name = 'Aniline, 4,4'' - (imidocarbonyl) bis (N,N - dimethyl - , hydrochloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2524-04-1', 'Diethylphosphorochloridothioate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2524-04-1' and x.name = 'Diethylphosphorochloridothioate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2551-62-4', 'Sulfur Hexafluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2551-62-4' and x.name = 'Sulfur Hexafluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2568-91-4', 'Diisobutoxymethane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2568-91-4' and x.name = 'Diisobutoxymethane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2602-46-2', 'Direct Blue 6', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2602-46-2' and x.name = 'Direct Blue 6' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2610-11-9', 'Direct Red 81', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2610-11-9' and x.name = 'Direct Red 81' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2642-71-9', 'Azinphos-Ethyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2642-71-9' and x.name = 'Azinphos-Ethyl' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2650-18-2', 'Acid Blue 9', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2650-18-2' and x.name = 'Acid Blue 9' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2675-77-6', 'Demosan', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2675-77-6' and x.name = 'Demosan' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2682-20-4', '2-Methyl-4-Isothiazolin-3-one', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2682-20-4' and x.name = '2-Methyl-4-Isothiazolin-3-one' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2691-41-0', 'HMX', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2691-41-0' and x.name = 'HMX' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2698-41-1', 'o-Chlorobenzylidene Malononitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2698-41-1' and x.name = 'o-Chlorobenzylidene Malononitrile' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2699-79-8', 'Sulfuryl Fluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2699-79-8' and x.name = 'Sulfuryl Fluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2782-57-2', 'Dichloroisocyanuric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2782-57-2' and x.name = 'Dichloroisocyanuric Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2807-30-9', '2-Propoxyethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2807-30-9' and x.name = '2-Propoxyethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2825-82-3', 'Tetrahydrobicyclopentadiene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2825-82-3' and x.name = 'Tetrahydrobicyclopentadiene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2832-40-8', 'Disperse Yellow 3', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2832-40-8' and x.name = 'Disperse Yellow 3' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2855-13-2', 'Isophorone Diamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2855-13-2' and x.name = 'Isophorone Diamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2919-66-6', 'Melengestrol Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2919-66-6' and x.name = 'Melengestrol Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2921-88-2', 'Chlorpyrifos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2921-88-2' and x.name = 'Chlorpyrifos' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2971-90-6', 'Clopidol (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2971-90-6' and x.name = 'Clopidol (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '2971-90-6', 'Clopidol (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '2971-90-6' and x.name = 'Clopidol (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3030-47-5', 'Pentamethyldiethylenetriamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3030-47-5' and x.name = 'Pentamethyldiethylenetriamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3032-55-1', 'Trimethylolethane Trinitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3032-55-1' and x.name = 'Trimethylolethane Trinitrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3033-62-3', '2,2''-Oxybis-(N,N-Dimethylethylamine)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3033-62-3' and x.name = '2,2''-Oxybis-(N,N-Dimethylethylamine)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3068-88-0', 'beta-Butyrolactone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3068-88-0' and x.name = 'beta-Butyrolactone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3101-60-8', '4-tert-Butylphenyl glycidyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3101-60-8' and x.name = '4-tert-Butylphenyl glycidyl ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3173-72-6', '1,5-Naphthalene Diisocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3173-72-6' and x.name = '1,5-Naphthalene Diisocyanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3179-90-6', 'Disperse Blue 7', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3179-90-6' and x.name = 'Disperse Blue 7' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3268-87-9', '1,2,3,4,6,7,8,9-Octachlorodibenzodioxin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3268-87-9' and x.name = '1,2,3,4,6,7,8,9-Octachlorodibenzodioxin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3333-52-6', 'Tetramethyl Succinonitrile', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3333-52-6' and x.name = 'Tetramethyl Succinonitrile' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3366-61-8', 'N-Acetylbenzidine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3366-61-8' and x.name = 'N-Acetylbenzidine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3383-96-8', 'Temephos (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3383-96-8' and x.name = 'Temephos (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3383-96-8', 'Temephos (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3383-96-8' and x.name = 'Temephos (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3385-21-5', 'Diaminocyclohexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3385-21-5' and x.name = 'Diaminocyclohexane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3478-94-2', 'Pipron', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3478-94-2' and x.name = 'Pipron' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3524-68-3', 'Pentaerythritol Triacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3524-68-3' and x.name = 'Pentaerythritol Triacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3648-20-2', 'Diundecyl Phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3648-20-2' and x.name = 'Diundecyl Phthalate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3687-31-8', 'lead(II) arsenate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3687-31-8' and x.name = 'lead(II) arsenate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3689-24-5', 'TEDP', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3689-24-5' and x.name = 'TEDP' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3691-35-8', 'Rozol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3691-35-8' and x.name = 'Rozol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3734-33-6', 'Denatonium Benzoate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3734-33-6' and x.name = 'Denatonium Benzoate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3841-14-3', 'Direct Blue 1', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3841-14-3' and x.name = 'Direct Blue 1' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '3855-32-1', 'N-[3-(Dimethylamino)propyl-N,N'',N''-trimethyl-1,3-Propanediami', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '3855-32-1' and x.name = 'N-[3-(Dimethylamino)propyl-N,N'',N''-trimethyl-1,3-Propanediami' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4016-14-2', 'Isopropyl Glycidyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4016-14-2' and x.name = 'Isopropyl Glycidyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4035-89-6', 'Hexamethylene Diisocyanate Biuret', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4035-89-6' and x.name = 'Hexamethylene Diisocyanate Biuret' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4098-71-9', 'Isophorone Diisocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4098-71-9' and x.name = 'Isophorone Diisocyanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4110-50-3', 'Ethyl Propyl Sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4110-50-3' and x.name = 'Ethyl Propyl Sulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4164-28-7', 'N-Nitrodimethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4164-28-7' and x.name = 'N-Nitrodimethylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4342-36-3', 'Tributyltin Benzoate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4342-36-3' and x.name = 'Tributyltin Benzoate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4435-53-4', '3-Methoxy-n-butyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4435-53-4' and x.name = '3-Methoxy-n-butyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4549-44-4', 'N-Nitrosoethyl-n-butylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4549-44-4' and x.name = 'N-Nitrosoethyl-n-butylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4685-14-7', 'Paraquat, respirable dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4685-14-7' and x.name = 'Paraquat, respirable dust' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4719-04-4', 'Triazinetriethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4719-04-4' and x.name = 'Triazinetriethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4792-15-8', 'Pentaethylene glycol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4792-15-8' and x.name = 'Pentaethylene glycol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '4994-16-5', '4-Phenylcyclohexene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '4994-16-5' and x.name = '4-Phenylcyclohexene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5115-25-3', 'Difurfurylidene Pentaerythritol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5115-25-3' and x.name = 'Difurfurylidene Pentaerythritol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5124-30-1', 'Methylene-bis(4-Cyclohexylisocyanate)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5124-30-1' and x.name = 'Methylene-bis(4-Cyclohexylisocyanate)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5131-66-8', '1-Butoxy-2-propanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5131-66-8' and x.name = '1-Butoxy-2-propanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5160-02-1', 'Lake Red C', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5160-02-1' and x.name = 'Lake Red C' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5234-68-4', 'Carboxin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5234-68-4' and x.name = 'Carboxin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5329-14-6', 'Sulfamic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5329-14-6' and x.name = 'Sulfamic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5421-66-9', 'Bismark Brown', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5421-66-9' and x.name = 'Bismark Brown' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5522-43-0', '1-Nitropyrene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5522-43-0' and x.name = '1-Nitropyrene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5534-09-8', 'Beclomethasone Dipropionate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5534-09-8' and x.name = 'Beclomethasone Dipropionate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5593-20-4', 'Betamethasone Dipropionate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5593-20-4' and x.name = 'Betamethasone Dipropionate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5714-22-7', 'Sulfur Pentafluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5714-22-7' and x.name = 'Sulfur Pentafluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5874-97-5', 'Alupent', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5874-97-5' and x.name = 'Alupent' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '5989-27-5', 'd-Limonene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '5989-27-5' and x.name = 'd-Limonene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6106-46-3', 'Scopolamine methyl nitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6106-46-3' and x.name = 'Scopolamine methyl nitrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6164-98-3', 'Chlordimeform', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6164-98-3' and x.name = 'Chlordimeform' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6211-15-0', 'Morphine sulfate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6211-15-0' and x.name = 'Morphine sulfate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6359-90-6', 'Acid Yellow 34', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6359-90-6' and x.name = 'Acid Yellow 34' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6375-55-9', 'Acid Yellow 42', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6375-55-9' and x.name = 'Acid Yellow 42' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6423-43-4', '1,2-Propylene Glycol Dinitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6423-43-4' and x.name = '1,2-Propylene Glycol Dinitrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6459-94-5', 'Acid Red 114', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6459-94-5' and x.name = 'Acid Red 114' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6484-52-2', 'Ammonium Nitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6484-52-2' and x.name = 'Ammonium Nitrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6533-73-9', 'thallium(I) carbonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6533-73-9' and x.name = 'thallium(I) carbonate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6627-34-5', '2,5-Dichloro-4-Nitroaniline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6627-34-5' and x.name = '2,5-Dichloro-4-Nitroaniline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6637-88-3', 'C.I. Direct Orange 6, disodium salt', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6637-88-3' and x.name = 'C.I. Direct Orange 6, disodium salt' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6656-03-7', 'Direct Blue 98', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6656-03-7' and x.name = 'Direct Blue 98' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6659-60-5', '1,2,4-Butanetriol, trinitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6659-60-5' and x.name = '1,2,4-Butanetriol, trinitrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6683-19-8', 'Tetrakis(methylene(3,5-di-t-butyl-4-hydroxyhydrocinnamte))methane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6683-19-8' and x.name = 'Tetrakis(methylene(3,5-di-t-butyl-4-hydroxyhydrocinnamte))methane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6795-23-9', 'Aflatoxin (M1)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6795-23-9' and x.name = 'Aflatoxin (M1)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6804-07-5', 'Carbadox', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6804-07-5' and x.name = 'Carbadox' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6834-92-0', 'Sodium Metasilicate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6834-92-0' and x.name = 'Sodium Metasilicate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6846-50-0', '2,2,4-Trimethyl-1,3-pentanediol diisobutyrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6846-50-0' and x.name = '2,2,4-Trimethyl-1,3-pentanediol diisobutyrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6885-57-0', 'Aflatoxin (M2)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6885-57-0' and x.name = 'Aflatoxin (M2)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '6923-22-4', 'Monocrotophos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '6923-22-4' and x.name = 'Monocrotophos' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7068-83-9', 'N-Nitrosomethyl-n-butylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7068-83-9' and x.name = 'N-Nitrosomethyl-n-butylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7085-85-0', 'Ethyl 2-Cyanoacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7085-85-0' and x.name = 'Ethyl 2-Cyanoacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7220-81-7', 'Aflatoxin (B2)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7220-81-7' and x.name = 'Aflatoxin (B2)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7241-98-7', 'Aflatoxin (G2)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7241-98-7' and x.name = 'Aflatoxin (G2)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7328-17-8', 'di(ethylene glycol)ethyl ether acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7328-17-8' and x.name = 'di(ethylene glycol)ethyl ether acrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7429-90-5', 'Aluminum (as Al), Alkyls', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7429-90-5' and x.name = 'Aluminum (as Al), Alkyls' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7429-90-5', 'Aluminum (as Al), Metal (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7429-90-5' and x.name = 'Aluminum (as Al), Metal (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7429-90-5', 'Aluminum (as Al), Metal (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7429-90-5' and x.name = 'Aluminum (as Al), Metal (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7429-90-5', 'Aluminum (as Al), Pyro Powder', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7429-90-5' and x.name = 'Aluminum (as Al), Pyro Powder' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7429-90-5', 'Aluminum (as Al), Soluble Salts', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7429-90-5' and x.name = 'Aluminum (as Al), Soluble Salts' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7429-90-5', 'Aluminum (as Al), Welding Fumes', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7429-90-5' and x.name = 'Aluminum (as Al), Welding Fumes' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-88-5', 'Iridium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-88-5' and x.name = 'Iridium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-89-6', 'Iron (Bulk)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-89-6' and x.name = 'Iron (Bulk)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-92-1', 'Lead, Inorganic (as Pb)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-92-1' and x.name = 'Lead, Inorganic (as Pb)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-93-2', 'Lithium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-93-2' and x.name = 'Lithium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-95-4', 'Magnesium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-95-4' and x.name = 'Magnesium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-96-5', 'Manganese Compounds (as Mn)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-96-5' and x.name = 'Manganese Compounds (as Mn)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-96-5', 'Manganese Fume (as Mn)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-96-5' and x.name = 'Manganese Fume (as Mn)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-97-6', 'Mercury (Aryl and Inorganic) (as Hg)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-97-6' and x.name = 'Mercury (Aryl and Inorganic) (as Hg)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-97-6', 'Mercury (Vapor) (as Hg)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-97-6' and x.name = 'Mercury (Vapor) (as Hg)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-98-7', 'Molybdenum (as Mo), Insoluble Compounds (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-98-7' and x.name = 'Molybdenum (as Mo), Insoluble Compounds (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7439-98-7', 'Molybdenum (as Mo), Soluble Compounds', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7439-98-7' and x.name = 'Molybdenum (as Mo), Soluble Compounds' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-00-8', 'Neodymium (as Nd)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-00-8' and x.name = 'Neodymium (as Nd)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-01-9', 'Neon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-01-9' and x.name = 'Neon' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-02-0', 'Nickel, Metal and Insoluble compounds (as Ni)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-02-0' and x.name = 'Nickel, Metal and Insoluble compounds (as Ni)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-02-0', 'Nickel, Soluble Compounds (as Ni)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-02-0' and x.name = 'Nickel, Soluble Compounds (as Ni)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-05-3', 'Palladium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-05-3' and x.name = 'Palladium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-06-4', 'Platinum (as Pt), metal', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-06-4' and x.name = 'Platinum (as Pt), metal' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-06-4', 'Platinum (as Pt), soluble salts', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-06-4' and x.name = 'Platinum (as Pt), soluble salts' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-16-6', 'Rhodium (as Rh), Metal Fume and Insoluble Compounds', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-16-6' and x.name = 'Rhodium (as Rh), Metal Fume and Insoluble Compounds' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-16-6', 'Rhodium (as Rh), Soluble Compounds', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-16-6' and x.name = 'Rhodium (as Rh), Soluble Compounds' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-17-7', 'Rubidium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-17-7' and x.name = 'Rubidium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-18-8', 'Ruthenium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-18-8' and x.name = 'Ruthenium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-21-3', 'Silicon (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-21-3' and x.name = 'Silicon (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-21-3', 'Silicon (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-21-3' and x.name = 'Silicon (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-22-4', 'Silver, Metal & Soluble Compounds (as Ag)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-22-4' and x.name = 'Silver, Metal & Soluble Compounds (as Ag)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-24-6', 'Strontium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-24-6' and x.name = 'Strontium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-25-7', 'Tantalum (metal, oxide dusts)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-25-7' and x.name = 'Tantalum (metal, oxide dusts)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-28-0', 'Thallium, soluble compounds (as Tl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-28-0' and x.name = 'Thallium, soluble compounds (as Tl)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-29-1', 'Thorium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-29-1' and x.name = 'Thorium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-31-5', 'Tin, inorganic compounds (except oxides) (as Sn)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-31-5' and x.name = 'Tin, inorganic compounds (except oxides) (as Sn)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-32-6', 'Titanium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-32-6' and x.name = 'Titanium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-33-7', 'Tungsten (as W) Insoluble Compounds', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-33-7' and x.name = 'Tungsten (as W) Insoluble Compounds' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-33-7', 'Tungsten (as W) Soluble Compounds', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-33-7' and x.name = 'Tungsten (as W) Soluble Compounds' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-36-0', 'Antimony & Compounds (as Sb)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-36-0' and x.name = 'Antimony & Compounds (as Sb)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-37-1', 'Argon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-37-1' and x.name = 'Argon' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-38-2', 'Arsenic, Inorganic', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-38-2' and x.name = 'Arsenic, Inorganic' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-38-2', 'Arsenic, Organic Compounds (as As)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-38-2' and x.name = 'Arsenic, Organic Compounds (as As)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-39-3', 'Barium (Insoluble Compounds)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-39-3' and x.name = 'Barium (Insoluble Compounds)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-39-3', 'Barium, Soluble Compounds (as Ba)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-39-3' and x.name = 'Barium, Soluble Compounds (as Ba)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-41-7', 'Beryllium and Beryllium Compounds (as Be)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-41-7' and x.name = 'Beryllium and Beryllium Compounds (as Be)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-42-8', 'Boron', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-42-8' and x.name = 'Boron' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-43-9', 'Cadmium Dust (as Cd)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-43-9' and x.name = 'Cadmium Dust (as Cd)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-43-9', 'Cadmium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-43-9' and x.name = 'Cadmium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-44-0', 'Carbon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-44-0' and x.name = 'Carbon' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-45-1', 'Cerium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-45-1' and x.name = 'Cerium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-47-3', 'chromium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-47-3' and x.name = 'chromium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-47-3', 'Chromium (II) Compounds (as Cr)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-47-3' and x.name = 'Chromium (II) Compounds (as Cr)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-47-3', 'Chromium (III) Compounds (as Cr)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-47-3' and x.name = 'Chromium (III) Compounds (as Cr)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-47-3', 'Chromium, Metal and Insoluble Salts', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-47-3' and x.name = 'Chromium, Metal and Insoluble Salts' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-47-3', 'Chromium, Soluble Chromic, Chromous Salts (as Cr)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-47-3' and x.name = 'Chromium, Soluble Chromic, Chromous Salts (as Cr)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-48-4', 'Cobalt, Metal, Dust & Fume (as Co)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-48-4' and x.name = 'Cobalt, Metal, Dust & Fume (as Co)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-50-8', 'Copper Dusts & Mists (as Cu)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-50-8' and x.name = 'Copper Dusts & Mists (as Cu)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-50-8', 'Copper Fume (as Cu)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-50-8' and x.name = 'Copper Fume (as Cu)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-55-3', 'Gallium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-55-3' and x.name = 'Gallium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-57-5', 'Gold', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-57-5' and x.name = 'Gold' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-58-6', 'Hafnium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-58-6' and x.name = 'Hafnium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-59-7', 'Helium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-59-7' and x.name = 'Helium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-61-1', 'Uranium (as U), Insoluble compounds', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-61-1' and x.name = 'Uranium (as U), Insoluble compounds' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-61-1', 'Uranium (as U), Soluble Compounds', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-61-1' and x.name = 'Uranium (as U), Soluble Compounds' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-65-5', 'Yttrium', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-65-5' and x.name = 'Yttrium' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-66-6', 'Zinc', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-66-6' and x.name = 'Zinc' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-67-7', 'Zirconium Compounds (as Zr)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-67-7' and x.name = 'Zirconium Compounds (as Zr)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-69-6', 'Bismuth', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-69-6' and x.name = 'Bismuth' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7440-74-6', 'Indium & Compounds (as In)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7440-74-6' and x.name = 'Indium & Compounds (as In)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7446-09-5', 'Sulfur Dioxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7446-09-5' and x.name = 'Sulfur Dioxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7446-34-6', 'Selenium sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7446-34-6' and x.name = 'Selenium sulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7529-22-8', '4-Methyl Morpholine N-oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7529-22-8' and x.name = '4-Methyl Morpholine N-oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7553-56-2', 'Iodine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7553-56-2' and x.name = 'Iodine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7560-83-0', 'Methyl Dicyclohexylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7560-83-0' and x.name = 'Methyl Dicyclohexylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7572-29-4', 'Dichloroacetylene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7572-29-4' and x.name = 'Dichloroacetylene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7580-67-8', 'Lithium Hydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7580-67-8' and x.name = 'Lithium Hydride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7601-90-3', 'Perchloric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7601-90-3' and x.name = 'Perchloric Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7616-94-6', 'Perchloryl Fluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7616-94-6' and x.name = 'Perchloryl Fluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7631-86-9', 'Silica, Amorphous', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7631-86-9' and x.name = 'Silica, Amorphous' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7631-90-5', 'Sodium Bisulfite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7631-90-5' and x.name = 'Sodium Bisulfite' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7631-99-4', 'Sodium Nitrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7631-99-4' and x.name = 'Sodium Nitrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7632-00-0', 'Sodium Nitrite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7632-00-0' and x.name = 'Sodium Nitrite' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7632-10-2', 'Methamphetamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7632-10-2' and x.name = 'Methamphetamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7637-07-2', 'Boron Trifluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7637-07-2' and x.name = 'Boron Trifluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7645-25-2', 'lead arsenate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7645-25-2' and x.name = 'lead arsenate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7646-85-7', 'Zinc Chloride Fume', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7646-85-7' and x.name = 'Zinc Chloride Fume' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7647-01-0', 'Hydrogen Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7647-01-0' and x.name = 'Hydrogen Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7647-14-5', 'Sodium Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7647-14-5' and x.name = 'Sodium Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7664-38-2', 'Phosphoric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7664-38-2' and x.name = 'Phosphoric Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7664-39-3', 'Hydrogen Fluoride (as F)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7664-39-3' and x.name = 'Hydrogen Fluoride (as F)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7664-41-7', 'Ammonia', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7664-41-7' and x.name = 'Ammonia' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7664-93-9', 'Sulfuric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7664-93-9' and x.name = 'Sulfuric Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7665-72-2', 'tert-Butyl Glycidyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7665-72-2' and x.name = 'tert-Butyl Glycidyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7681-57-4', 'Sodium Metabisulfite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7681-57-4' and x.name = 'Sodium Metabisulfite' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7696-12-0', 'Tetramethrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7696-12-0' and x.name = 'Tetramethrin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7697-37-2', 'Nitric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7697-37-2' and x.name = 'Nitric Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7699-41-4', 'Silica, Gel', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7699-41-4' and x.name = 'Silica, Gel' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7699-45-8', 'Zinc Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7699-45-8' and x.name = 'Zinc Bromide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7704-34-9', 'Sulfur', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7704-34-9' and x.name = 'Sulfur' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7705-08-0', 'Ferric Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7705-08-0' and x.name = 'Ferric Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7719-09-7', 'Thionyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7719-09-7' and x.name = 'Thionyl Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7719-12-2', 'Phosphorus Trichloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7719-12-2' and x.name = 'Phosphorus Trichloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7722-84-1', 'Hydrogen Peroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7722-84-1' and x.name = 'Hydrogen Peroxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7722-88-5', 'Tetrasodium Pyrophosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7722-88-5' and x.name = 'Tetrasodium Pyrophosphate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7723-14-0', 'Phosphorus (yellow)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7723-14-0' and x.name = 'Phosphorus (yellow)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7726-95-6', 'Bromine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7726-95-6' and x.name = 'Bromine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7727-37-9', 'Nitrogen', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7727-37-9' and x.name = 'Nitrogen' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7727-43-7', 'Barium Sulfate (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7727-43-7' and x.name = 'Barium Sulfate (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7727-43-7', 'Barium Sulfate (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7727-43-7' and x.name = 'Barium Sulfate (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7758-29-4', 'Sodium Tripolyphosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7758-29-4' and x.name = 'Sodium Tripolyphosphate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7758-97-6', 'lead chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7758-97-6' and x.name = 'lead chromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7758-97-6', 'lead chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7758-97-6' and x.name = 'lead chromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7773-06-0', 'Ammonium Sulfamate (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7773-06-0' and x.name = 'Ammonium Sulfamate (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7773-06-0', 'Ammonium Sulfamate (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7773-06-0' and x.name = 'Ammonium Sulfamate (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7775-11-3', 'sodium chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7775-11-3' and x.name = 'sodium chromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7775-14-6', 'Sodium Hydrosulfite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7775-14-6' and x.name = 'Sodium Hydrosulfite' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7775-27-1', 'Sodium Persulfate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7775-27-1' and x.name = 'Sodium Persulfate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7778-18-9', 'Calcium Sulfate (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7778-18-9' and x.name = 'Calcium Sulfate (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7778-18-9', 'Calcium Sulfate (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7778-18-9' and x.name = 'Calcium Sulfate (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7778-44-1', 'Calcium Arsenate (as As)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7778-44-1' and x.name = 'Calcium Arsenate (as As)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7778-50-9', 'potassium dichromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7778-50-9' and x.name = 'potassium dichromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7778-85-0', '1,2-Dimethoxypropane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7778-85-0' and x.name = '1,2-Dimethoxypropane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-41-4', 'Fluorine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-41-4' and x.name = 'Fluorine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-42-5', 'Graphite, Synthetic (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-42-5' and x.name = 'Graphite, Synthetic (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-42-5', 'Graphite, Synthetic (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-42-5' and x.name = 'Graphite, Synthetic (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-42-5', 'Graphite, natural respirable dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-42-5' and x.name = 'Graphite, natural respirable dust' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-44-7', 'Oxygen', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-44-7' and x.name = 'Oxygen' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-49-2', 'Selenium Compounds (as Se)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-49-2' and x.name = 'Selenium Compounds (as Se)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-50-5', 'Chlorine (as Available Chlorine)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-50-5' and x.name = 'Chlorine (as Available Chlorine)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-50-5', 'Chlorine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-50-5' and x.name = 'Chlorine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-65-2', 'Germanium Tetrahydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-65-2' and x.name = 'Germanium Tetrahydride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7782-79-8', 'Hydrazoic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7782-79-8' and x.name = 'Hydrazoic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-06-4', 'Hydrogen Sulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-06-4' and x.name = 'Hydrogen Sulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-07-5', 'Hydrogen Selenide (as Se)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-07-5' and x.name = 'Hydrogen Selenide (as Se)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-41-7', 'Oxygen Difluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-41-7' and x.name = 'Oxygen Difluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-54-2', 'Nitrogen Trifluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-54-2' and x.name = 'Nitrogen Trifluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-60-0', 'Sulfur Tetrafluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-60-0' and x.name = 'Sulfur Tetrafluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-61-1', 'Silicon Tetrafluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-61-1' and x.name = 'Silicon Tetrafluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-79-1', 'Selenium Hexafluoride (as Se)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-79-1' and x.name = 'Selenium Hexafluoride (as Se)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7783-80-4', 'Tellurium Hexafluoride (as Te)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7783-80-4' and x.name = 'Tellurium Hexafluoride (as Te)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7784-01-2', 'silver chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7784-01-2' and x.name = 'silver chromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7784-40-9', 'lead arsenate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7784-40-9' and x.name = 'lead arsenate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7784-42-1', 'Arsine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7784-42-1' and x.name = 'Arsine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7786-34-7', 'Phosdrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7786-34-7' and x.name = 'Phosdrin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-00-6', 'potassium chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-00-6' and x.name = 'potassium chromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-06-2', 'strontium chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-06-2' and x.name = 'strontium chromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-09-5', 'ammonium dichromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-09-5' and x.name = 'ammonium dichromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-12-0', 'sodium dichromate dehydrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-12-0' and x.name = 'sodium dichromate dehydrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-30-2', 'Bromine Pentafluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-30-2' and x.name = 'Bromine Pentafluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-38-0', 'Sodium Bromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-38-0' and x.name = 'Sodium Bromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-41-5', 'Calcium Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-41-5' and x.name = 'Calcium Bromide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7789-98-9', 'ammonium chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7789-98-9' and x.name = 'ammonium chromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7790-91-2', 'Chlorine Trifluoride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7790-91-2' and x.name = 'Chlorine Trifluoride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7803-49-8', 'Hydroxylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7803-49-8' and x.name = 'Hydroxylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7803-51-2', 'Phosphine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7803-51-2' and x.name = 'Phosphine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7803-52-3', 'Stibine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7803-52-3' and x.name = 'Stibine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '7803-62-5', 'Silicon Tetrahydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '7803-62-5' and x.name = 'Silicon Tetrahydride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8001-35-2', 'Chlorinated Camphene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8001-35-2' and x.name = 'Chlorinated Camphene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8001-58-9', 'Creosote', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8001-58-9' and x.name = 'Creosote' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8002-05-9', 'Petroleum Distillate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8002-05-9' and x.name = 'Petroleum Distillate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8002-74-2', 'Paraffin Wax Fume', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8002-74-2' and x.name = 'Paraffin Wax Fume' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8003-34-7', 'Pyrethrum', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8003-34-7' and x.name = 'Pyrethrum' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8004-13-5', 'Phenyl Ether-Biphenyl Mix (Vapor)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8004-13-5' and x.name = 'Phenyl Ether-Biphenyl Mix (Vapor)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8004-87-3', 'Methyl Violet', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8004-87-3' and x.name = 'Methyl Violet' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8006-61-9', 'Gasoline', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8006-61-9' and x.name = 'Gasoline' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8006-64-2', 'Turpentine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8006-64-2' and x.name = 'Turpentine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8008-20-6', 'Kerosene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8008-20-6' and x.name = 'Kerosene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8012-95-1', 'Oil Mist, Mineral', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8012-95-1' and x.name = 'Oil Mist, Mineral' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8022-00-2', 'Methyl Demeton', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8022-00-2' and x.name = 'Methyl Demeton' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8030-30-6', 'Naphtha (Coal Tar)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8030-30-6' and x.name = 'Naphtha (Coal Tar)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8032-32-4', 'VM & P Naphtha', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8032-32-4' and x.name = 'VM & P Naphtha' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8049-47-6', 'Pancreatin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8049-47-6' and x.name = 'Pancreatin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8052-41-3', 'Stoddard Solvent', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8052-41-3' and x.name = 'Stoddard Solvent' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8052-42-4', 'Asphalt Fumes (Petroleum)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8052-42-4' and x.name = 'Asphalt Fumes (Petroleum)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8061-51-6', 'Sodium Ligninsulfonate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8061-51-6' and x.name = 'Sodium Ligninsulfonate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '8065-48-3', 'Demeton', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '8065-48-3' and x.name = 'Demeton' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9001-00-7', 'Bromelain', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9001-00-7' and x.name = 'Bromelain' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9001-73-4', 'Papain', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9001-73-4' and x.name = 'Papain' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9001-92-7', 'Protease', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9001-92-7' and x.name = 'Protease' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9002-07-7', 'Trypsin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9002-07-7' and x.name = 'Trypsin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9002-84-0', 'Polytetrafluoroethylene Decomposition Products', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9002-84-0' and x.name = 'Polytetrafluoroethylene Decomposition Products' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9004-34-6', 'Cellulose (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9004-34-6' and x.name = 'Cellulose (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9004-34-6', 'Cellulose (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9004-34-6' and x.name = 'Cellulose (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9004-35-7', 'Cellulose Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9004-35-7' and x.name = 'Cellulose Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9004-57-3', 'Ethyl Cellulose', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9004-57-3' and x.name = 'Ethyl Cellulose' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9004-70-0', 'Nitrocellulose', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9004-70-0' and x.name = 'Nitrocellulose' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9005-25-8', 'Starch (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9005-25-8' and x.name = 'Starch (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9005-25-8', 'Starch (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9005-25-8' and x.name = 'Starch (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9016-45-9', 'Tergitol NP-33', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9016-45-9' and x.name = 'Tergitol NP-33' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '9016-87-9', 'PAPI', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '9016-87-9' and x.name = 'PAPI' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10024-97-2', 'Nitrous Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10024-97-2' and x.name = 'Nitrous Oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10025-67-9', 'Sulfur Monochloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10025-67-9' and x.name = 'Sulfur Monochloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10025-85-1', 'Nitrogen Trichloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10025-85-1' and x.name = 'Nitrogen Trichloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10025-87-3', 'Phosphorus Oxychloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10025-87-3' and x.name = 'Phosphorus Oxychloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10026-13-8', 'Phosphorus Pentachloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10026-13-8' and x.name = 'Phosphorus Pentachloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10028-15-6', 'Ozone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10028-15-6' and x.name = 'Ozone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10031-59-1', 'thallium sulfate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10031-59-1' and x.name = 'thallium sulfate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10035-10-6', 'Hydrogen Bromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10035-10-6' and x.name = 'Hydrogen Bromide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10043-35-3', 'Boric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10043-35-3' and x.name = 'Boric Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10049-04-4', 'Chlorine Dioxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10049-04-4' and x.name = 'Chlorine Dioxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10102-43-9', 'Nitric Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10102-43-9' and x.name = 'Nitric Oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10102-44-0', 'Nitrogen Dioxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10102-44-0' and x.name = 'Nitrogen Dioxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10127-27-2', 'Acid Orange 74', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10127-27-2' and x.name = 'Acid Orange 74' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10210-68-1', 'Cobalt Carbonyl (as Co)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10210-68-1' and x.name = 'Cobalt Carbonyl (as Co)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10265-92-6', 'Methamidophos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10265-92-6' and x.name = 'Methamidophos' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10294-33-4', 'Boron Tribromide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10294-33-4' and x.name = 'Boron Tribromide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10294-40-3', 'barium chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10294-40-3' and x.name = 'barium chromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10311-84-9', 'Torak', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10311-84-9' and x.name = 'Torak' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10453-86-8', 'Resmethrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10453-86-8' and x.name = 'Resmethrin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10588-01-9', 'sodium dichromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10588-01-9' and x.name = 'sodium dichromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '10595-95-6', 'N-Nitrosomethylethylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '10595-95-6' and x.name = 'N-Nitrosomethylethylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '11029-72-4', 'Holothurin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '11029-72-4' and x.name = 'Holothurin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '11096-82-5', 'Chlorodiphenyl (60% Cl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '11096-82-5' and x.name = 'Chlorodiphenyl (60% Cl)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '11097-69-1', 'Chlorodiphenyl (54% Cl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '11097-69-1' and x.name = 'Chlorodiphenyl (54% Cl)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '11104-28-2', 'Chlorodiphenyl (21% Cl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '11104-28-2' and x.name = 'Chlorodiphenyl (21% Cl)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12001-26-2', 'Mica', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12001-26-2' and x.name = 'Mica' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12035-72-2', 'Nickel subsulfide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12035-72-2' and x.name = 'Nickel subsulfide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12079-65-1', 'Manganese Cyclopentadienyl Tricarbonyl (as Mn)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12079-65-1' and x.name = 'Manganese Cyclopentadienyl Tricarbonyl (as Mn)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12108-13-3', 'Methylcyclopentadienyl Manganese Tricarbonyl (as Mn)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12108-13-3' and x.name = 'Methylcyclopentadienyl Manganese Tricarbonyl (as Mn)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12122-67-7', 'Zineb', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12122-67-7' and x.name = 'Zineb' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12125-02-9', 'Ammonium Chloride (Fume)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12125-02-9' and x.name = 'Ammonium Chloride (Fume)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12179-04-3', 'Borates, Tetra, Sodium Salts, Pentahydrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12179-04-3' and x.name = 'Borates, Tetra, Sodium Salts, Pentahydrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12407-86-2', 'Landrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12407-86-2' and x.name = 'Landrin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12415-34-8', 'Emery (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12415-34-8' and x.name = 'Emery (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12415-34-8', 'Emery (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12415-34-8' and x.name = 'Emery (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12427-38-2', 'Maneb', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12427-38-2' and x.name = 'Maneb' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12604-58-9', 'Ferrovanadium Dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12604-58-9' and x.name = 'Ferrovanadium Dust' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12656-85-8', 'molybdenum orange', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12656-85-8' and x.name = 'molybdenum orange' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12672-29-6', 'Chlorodiphenyl (48% Cl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12672-29-6' and x.name = 'Chlorodiphenyl (48% Cl)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '12674-11-2', 'Chlorodiphenyl (1016)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '12674-11-2' and x.name = 'Chlorodiphenyl (1016)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13048-33-4', '1,6-Hexanediol Diacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13048-33-4' and x.name = '1,6-Hexanediol Diacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13071-79-9', 'Terbufos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13071-79-9' and x.name = 'Terbufos' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13121-70-5', 'Cyhexatin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13121-70-5' and x.name = 'Cyhexatin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13194-48-4', 'MOCAP', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13194-48-4' and x.name = 'MOCAP' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13256-06-9', 'N-Nitrosodiamylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13256-06-9' and x.name = 'N-Nitrosodiamylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13389-42-9', 'trans-2-Octene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13389-42-9' and x.name = 'trans-2-Octene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13292-46-1', 'Rifampicin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13292-46-1' and x.name = 'Rifampicin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13397-24-5', 'Gypsum (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13397-24-5' and x.name = 'Gypsum (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13397-24-5', 'Gypsum (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13397-24-5' and x.name = 'Gypsum (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13463-39-3', 'Nickel Carbonyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13463-39-3' and x.name = 'Nickel Carbonyl' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13463-40-6', 'Iron Pentacarbonyl (as Fe)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13463-40-6' and x.name = 'Iron Pentacarbonyl (as Fe)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13463-67-7', 'Titanium Dioxide (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13463-67-7' and x.name = 'Titanium Dioxide (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13466-78-9', '3-Carene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13466-78-9' and x.name = '3-Carene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13494-80-9', 'Tellurium and compounds (as Te)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13494-80-9' and x.name = 'Tellurium and compounds (as Te)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13530-65-9', 'Zinc Chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13530-65-9' and x.name = 'Zinc Chromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13530-65-9', 'zinc chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13530-65-9' and x.name = 'zinc chromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13684-56-5', 'Desmedipham', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13684-56-5' and x.name = 'Desmedipham' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13684-63-4', 'Phenmedipham', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13684-63-4' and x.name = 'Phenmedipham' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13717-00-5', 'Magnesite (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13717-00-5' and x.name = 'Magnesite (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13717-00-5', 'Magnesite (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13717-00-5' and x.name = 'Magnesite (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13765-19-0', 'calcium chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13765-19-0' and x.name = 'calcium chromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13838-16-9', 'Enflurane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13838-16-9' and x.name = 'Enflurane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13983-17-0', 'Wollastonite', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13983-17-0' and x.name = 'Wollastonite' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '13991-37-2', 't-2-Pentenoic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '13991-37-2' and x.name = 't-2-Pentenoic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14018-95-2', 'zinc chromate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14018-95-2' and x.name = 'zinc chromate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14464-46-1', 'Silica, Crystalline Cristobalite, Respirable Dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14464-46-1' and x.name = 'Silica, Crystalline Cristobalite, Respirable Dust' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14484-64-1', 'Ferbam, Total dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14484-64-1' and x.name = 'Ferbam, Total dust' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14807-96-6', 'Talc (Containing asbestos)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14807-96-6' and x.name = 'Talc (Containing asbestos)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14807-96-6', 'Talc (Containing no asbestos)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14807-96-6' and x.name = 'Talc (Containing no asbestos)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14808-60-7', 'Silica (Quartz, Total)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14808-60-7' and x.name = 'Silica (Quartz, Total)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14808-60-7', 'Silica, Crystalline Quartz, Respirable Dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14808-60-7' and x.name = 'Silica, Crystalline Quartz, Respirable Dust' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14850-23-8', 'trans-4-Octene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14850-23-8' and x.name = 'trans-4-Octene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14919-01-8', 'trans-3-Octene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14919-01-8' and x.name = 'trans-3-Octene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '14986-48-2', 'chromium (VI) chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '14986-48-2' and x.name = 'chromium (VI) chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '15442-64-5', 'Zinc Protoporphyrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '15442-64-5' and x.name = 'Zinc Protoporphyrin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '15468-32-3', 'Silica, Crystalline Tridymite, Respirable Dust', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '15468-32-3' and x.name = 'Silica, Crystalline Tridymite, Respirable Dust' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '15625-89-5', 'Trimethylolpropane Triacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '15625-89-5' and x.name = 'Trimethylolpropane Triacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '15972-60-8', 'Alachlor', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '15972-60-8' and x.name = 'Alachlor' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '16071-86-6', 'Direct Brown 95', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '16071-86-6' and x.name = 'Direct Brown 95' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '16219-75-3', 'Ethylidene Norbornene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '16219-75-3' and x.name = 'Ethylidene Norbornene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '16752-77-5', 'Methomyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '16752-77-5' and x.name = 'Methomyl' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '16842-03-8', 'Cobalt Hydrocarbonyl (as Co)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '16842-03-8' and x.name = 'Cobalt Hydrocarbonyl (as Co)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '16872-11-0', 'Fluoboric Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '16872-11-0' and x.name = 'Fluoboric Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '16984-48-8', 'Fluorides (as F)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '16984-48-8' and x.name = 'Fluorides (as F)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '17090-79-8', 'Monensin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '17090-79-8' and x.name = 'Monensin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '17702-41-9', 'Decaborane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '17702-41-9' and x.name = 'Decaborane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '17804-35-2', 'Benomyl (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '17804-35-2' and x.name = 'Benomyl (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '17804-35-2', 'Benomyl (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '17804-35-2' and x.name = 'Benomyl (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '17831-71-9', 'Tetraethylene Glycol Diacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '17831-71-9' and x.name = 'Tetraethylene Glycol Diacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '17924-92-4', 'Zearalenone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '17924-92-4' and x.name = 'Zearalenone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '18282-10-5', 'Stannic Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '18282-10-5' and x.name = 'Stannic Oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '18454-12-1', 'lead chromate oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '18454-12-1' and x.name = 'lead chromate oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '18454-12-1', 'lead chromate oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '18454-12-1' and x.name = 'lead chromate oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '18540-29-9', 'chromium (VI) ion', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '18540-29-9' and x.name = 'chromium (VI) ion' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '18883-66-4', 'Streptozotocin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '18883-66-4' and x.name = 'Streptozotocin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '19044-88-3', 'Oryzalin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '19044-88-3' and x.name = 'Oryzalin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '19287-45-7', 'Diborane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '19287-45-7' and x.name = 'Diborane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '19408-84-5', 'Dihydrocapsaicin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '19408-84-5' and x.name = 'Dihydrocapsaicin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '19624-22-7', 'Pentaborane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '19624-22-7' and x.name = 'Pentaborane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '20619-16-3', 'Germanium Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '20619-16-3' and x.name = 'Germanium Oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '20816-12-0', 'Osmium Tetroxide (as Os)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '20816-12-0' and x.name = 'Osmium Tetroxide (as Os)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '20830-81-3', 'Daunamycin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '20830-81-3' and x.name = 'Daunamycin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '21087-64-9', 'Metribuzin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '21087-64-9' and x.name = 'Metribuzin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '21351-79-1', 'Cesium Hydroxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '21351-79-1' and x.name = 'Cesium Hydroxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '21609-90-5', 'Phosvel', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '21609-90-5' and x.name = 'Phosvel' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '21651-19-4', 'Stannous Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '21651-19-4' and x.name = 'Stannous Oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '21725-46-2', 'Bladex', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '21725-46-2' and x.name = 'Bladex' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '22224-92-6', 'Fenamiphos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '22224-92-6' and x.name = 'Fenamiphos' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '22781-23-3', 'Ficam', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '22781-23-3' and x.name = 'Ficam' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '22839-47-0', 'Aspartame', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '22839-47-0' and x.name = 'Aspartame' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '23103-98-2', 'Pirimicarb', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '23103-98-2' and x.name = 'Pirimicarb' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '23135-22-0', 'Vydate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '23135-22-0' and x.name = 'Vydate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '23184-66-9', 'Machette', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '23184-66-9' and x.name = 'Machette' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '23564-05-8', 'Thiophanate-methyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '23564-05-8' and x.name = 'Thiophanate-methyl' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '23564-06-9', 'Thiophanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '23564-06-9' and x.name = 'Thiophanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '23950-58-5', 'Kerb', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '23950-58-5' and x.name = 'Kerb' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25013-15-4', 'Vinyl Toluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25013-15-4' and x.name = 'Vinyl Toluene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25134-21-8', 'Nadic methyl anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25134-21-8' and x.name = 'Nadic methyl anhydride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25154-52-3', 'Nonylphenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25154-52-3' and x.name = 'Nonylphenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25154-54-5', 'Dinitrobenzene (All Isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25154-54-5' and x.name = 'Dinitrobenzene (All Isomers)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25157-70-8', '2,4,4-Trimethyl Pentene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25157-70-8' and x.name = '2,4,4-Trimethyl Pentene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25167-67-3', 'Butene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25167-67-3' and x.name = 'Butene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25167-82-2', 'Trichlorophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25167-82-2' and x.name = 'Trichlorophenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25167-83-3', 'Tetrachlorophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25167-83-3' and x.name = 'Tetrachlorophenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25168-26-7', '2,4-D, Isooctyl Ester', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25168-26-7' and x.name = '2,4-D, Isooctyl Ester' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25265-77-4', '2,2,4-Trimethyl-1,3-pentanediol monoisobutyrate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25265-77-4' and x.name = '2,2,4-Trimethyl-1,3-pentanediol monoisobutyrate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25311-71-1', 'Isofenphos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25311-71-1' and x.name = 'Isofenphos' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25321-14-6', 'Dinitrotoluene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25321-14-6' and x.name = 'Dinitrotoluene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25340-18-5', 'Triethylbenzenes', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25340-18-5' and x.name = 'Triethylbenzenes' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25377-73-5', 'Dodecenylsuccinic anhydride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25377-73-5' and x.name = 'Dodecenylsuccinic anhydride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25413-64-3', 'N-Nitroso-N-propyl-n-butylamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25413-64-3' and x.name = 'N-Nitroso-N-propyl-n-butylamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25495-88-9', 'Methylhexane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25495-88-9' and x.name = 'Methylhexane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25550-58-7', 'Dinitrophenol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25550-58-7' and x.name = 'Dinitrophenol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25551-13-7', 'Trimethylbenzene (mixed isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25551-13-7' and x.name = 'Trimethylbenzene (mixed isomers)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '25639-42-3', 'Methylcyclohexanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '25639-42-3' and x.name = 'Methylcyclohexanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '26172-55-4', '5-Chloro-2-Methyl-4-Isothiazolin-3-One', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '26172-55-4' and x.name = '5-Chloro-2-Methyl-4-Isothiazolin-3-One' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '26499-65-0', 'Plaster of Paris (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '26499-65-0' and x.name = 'Plaster of Paris (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '26499-65-0', 'Plaster of Paris (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '26499-65-0' and x.name = 'Plaster of Paris (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '26628-22-8', 'Sodium Azide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '26628-22-8' and x.name = 'Sodium Azide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '26635-64-3', 'Isooctane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '26635-64-3' and x.name = 'Isooctane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '26675-46-7', 'Isoflurane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '26675-46-7' and x.name = 'Isoflurane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '26952-21-6', 'Isooctyl Alcohol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '26952-21-6' and x.name = 'Isooctyl Alcohol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '27176-87-0', 'Dodecyl Benzenesulfonic Acid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '27176-87-0' and x.name = 'Dodecyl Benzenesulfonic Acid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28106-30-1', 'Ethyl Vinyl Benzene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28106-30-1' and x.name = 'Ethyl Vinyl Benzene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28178-42-9', '2,6-Diisopropylphenyl isocyanate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28178-42-9' and x.name = '2,6-Diisopropylphenyl isocyanate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28182-81-2', '1,6-Hexamethylene Diisocyanate Homopolymer', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28182-81-2' and x.name = '1,6-Hexamethylene Diisocyanate Homopolymer' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28351-09-9', 'Dimethylbenzaldehyde', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28351-09-9' and x.name = 'Dimethylbenzaldehyde' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28523-86-6', 'Sevoflurane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28523-86-6' and x.name = 'Sevoflurane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28553-12-0', 'Diisononyl Phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28553-12-0' and x.name = 'Diisononyl Phthalate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28768-32-3', '4,4''-Methylenebis (N,N-diglycidylaniline)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28768-32-3' and x.name = '4,4''-Methylenebis (N,N-diglycidylaniline)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '28777-67-5', 'Dimethylhexane (all isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '28777-67-5' and x.name = 'Dimethylhexane (all isomers)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '29191-52-4', 'Anisidine (o,p-Isomers)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '29191-52-4' and x.name = 'Anisidine (o,p-Isomers)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '29232-93-7', 'Pirimiphos Methyl', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '29232-93-7' and x.name = 'Pirimiphos Methyl' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '29590-42-9', 'Isooctyl Acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '29590-42-9' and x.name = 'Isooctyl Acrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '29911-28-2', 'dipropylene glycol mono-n-butyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '29911-28-2' and x.name = 'dipropylene glycol mono-n-butyl ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '30136-13-1', 'n-Propoxypropanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '30136-13-1' and x.name = 'n-Propoxypropanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '30560-19-1', 'Orthene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '30560-19-1' and x.name = 'Orthene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '31017-40-0', '1-Phenyl-1-Cyclohexene', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '31017-40-0' and x.name = '1-Phenyl-1-Cyclohexene' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '31218-83-4', 'Safrotin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '31218-83-4' and x.name = 'Safrotin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '32536-52-0', 'Octabromodiphenyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '32536-52-0' and x.name = 'Octabromodiphenyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '34464-38-5', 'Isodecane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '34464-38-5' and x.name = 'Isodecane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '34590-94-8', 'Dipropylene Glycol Methyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '34590-94-8' and x.name = 'Dipropylene Glycol Methyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '34803-66-2', '1-(2-Pyridyl)piperazine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '34803-66-2' and x.name = '1-(2-Pyridyl)piperazine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '35400-43-2', 'Sulprofos', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '35400-43-2' and x.name = 'Sulprofos' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '36791-04-5', 'Ribavirin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '36791-04-5' and x.name = 'Ribavirin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '37293-45-1', 'Acid Black 128', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '37293-45-1' and x.name = 'Acid Black 128' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '37324-23-5', 'Chlorodiphenyl (62% Cl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '37324-23-5' and x.name = 'Chlorodiphenyl (62% Cl)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '38641-94-0', 'Glyphosate isopropylamine salt', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '38641-94-0' and x.name = 'Glyphosate isopropylamine salt' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '38721-71-0', 'Dichlorobenzyl Chloride', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '38721-71-0' and x.name = 'Dichlorobenzyl Chloride' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '40487-42-1', 'Pendimethalin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '40487-42-1' and x.name = 'Pendimethalin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '42978-66-5', 'Tripropylene Glycol Diacrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '42978-66-5' and x.name = 'Tripropylene Glycol Diacrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '48145-04-6', '2-Phenoxyethyl acrylate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '48145-04-6' and x.name = '2-Phenoxyethyl acrylate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '51207-31-9', '2,3,7,8-Tetrachlorodibenzofuran', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '51207-31-9' and x.name = '2,3,7,8-Tetrachlorodibenzofuran' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '51218-45-2', 'Metolachlor', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '51218-45-2' and x.name = 'Metolachlor' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '51235-04-2', 'Hexazinone', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '51235-04-2' and x.name = 'Hexazinone' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '52315-07-8', 'Cypermethrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '52315-07-8' and x.name = 'Cypermethrin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '52645-53-1', 'Permethrin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '52645-53-1' and x.name = 'Permethrin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '53404-18-5', 'Potassium p-tert-amylphenate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '53404-18-5' and x.name = 'Potassium p-tert-amylphenate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '53469-21-9', 'Chlorodiphenyl (42% Cl)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '53469-21-9' and x.name = 'Chlorodiphenyl (42% Cl)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '53609-64-6', 'N-Nitrosodiisopropanolamine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '53609-64-6' and x.name = 'N-Nitrosodiisopropanolamine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '54446-78-5', '1-(2-Butoxyethoxy)ethanol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '54446-78-5' and x.name = '1-(2-Butoxyethoxy)ethanol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '55107-14-7', 'Methyl pivaloylacetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '55107-14-7' and x.name = 'Methyl pivaloylacetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '55406-53-6', 'Iodopropanyl Butyl Carbamate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '55406-53-6' and x.name = 'Iodopropanyl Butyl Carbamate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '55720-99-5', 'Chlorinated Diphenyl Oxide', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '55720-99-5' and x.name = 'Chlorinated Diphenyl Oxide' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57041-67-5', 'Desflurane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57041-67-5' and x.name = 'Desflurane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '57837-19-1', 'Apron', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '57837-19-1' and x.name = 'Apron' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '59355-75-8', 'Methyl Acetylene-Propadiene Mixture', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '59355-75-8' and x.name = 'Methyl Acetylene-Propadiene Mixture' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60168-88-9', 'Fenarimol', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60168-88-9' and x.name = 'Fenarimol' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '60676-86-0', 'Silica, Fused (Respirable Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '60676-86-0' and x.name = 'Silica, Fused (Respirable Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '61788-32-7', 'Hydrogenated Terphenyls', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '61788-32-7' and x.name = 'Hydrogenated Terphenyls' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '61790-53-2', 'Silica, Amorphous, Diatomaceous Earth (<1% Crystalline Silica)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '61790-53-2' and x.name = 'Silica, Amorphous, Diatomaceous Earth (<1% Crystalline Silica)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '63428-83-1', 'Nylon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '63428-83-1' and x.name = 'Nylon' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '64265-57-2', 'Polyfunctional Aziridine', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '64265-57-2' and x.name = 'Polyfunctional Aziridine' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '65996-93-2', 'Coal Tar Pitch Volatiles (benzene soluble fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '65996-93-2' and x.name = 'Coal Tar Pitch Volatiles (benzene soluble fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '65997-15-1', 'Portland Cement (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '65997-15-1' and x.name = 'Portland Cement (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '65997-15-1', 'Portland Cement (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '65997-15-1' and x.name = 'Portland Cement (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '65997-17-3', 'Fibrous Glass', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '65997-17-3' and x.name = 'Fibrous Glass' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '67485-29-4', 'Hydramethylnon', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '67485-29-4' and x.name = 'Hydramethylnon' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68131-74-8', 'Coal Dust (<5% Si02, Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68131-74-8' and x.name = 'Coal Dust (<5% Si02, Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68334-30-5', 'Diesel Fuel', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68334-30-5' and x.name = 'Diesel Fuel' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68359-37-5', 'Baythroid', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68359-37-5' and x.name = 'Baythroid' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68476-85-7', 'L.P.G.', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68476-85-7' and x.name = 'L.P.G.' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68515-50-4', 'Dihexyl phthalate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68515-50-4' and x.name = 'Dihexyl phthalate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68937-41-7', 'Triisopropylated Phenyl Phosphate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68937-41-7' and x.name = 'Triisopropylated Phenyl Phosphate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68956-68-3', 'Vegetable Oil Mist (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68956-68-3' and x.name = 'Vegetable Oil Mist (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '68956-68-3', 'Vegetable Oil Mist (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '68956-68-3' and x.name = 'Vegetable Oil Mist (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '69409-94-5', 'Mavrik', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '69409-94-5' and x.name = 'Mavrik' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '70657-70-4', '2-Methoxy-1-Propyl Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '70657-70-4' and x.name = '2-Methoxy-1-Propyl Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '71751-41-2', 'Abamectin', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '71751-41-2' and x.name = 'Abamectin' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '72490-01-8', 'Fenoxycarb', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '72490-01-8' and x.name = 'Fenoxycarb' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '81777-89-1', 'Command', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '81777-89-1' and x.name = 'Command' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '83919-23-7', 'Mometasone Furoate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '83919-23-7' and x.name = 'Mometasone Furoate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88230-35-7', 'Acetic Acid, Hexyl Esters Mixture', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88230-35-7' and x.name = 'Acetic Acid, Hexyl Esters Mixture' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '88917-22-0', 'Dipropylene Glycol Methyl Ether Acetate', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '88917-22-0' and x.name = 'Dipropylene Glycol Methyl Ether Acetate' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93763-70-3', 'Perlite (Respirable Fraction)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93763-70-3' and x.name = 'Perlite (Respirable Fraction)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '93763-70-3', 'Perlite (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '93763-70-3' and x.name = 'Perlite (Total Dust)' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '112926-00-8', 'Precipitated silica; silica gel', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '112926-00-8' and x.name = 'Precipitated silica; silica gel' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '138495-42-8', '1,1,1,2,3,4,4,5,5,5-Decafluoropentane', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '138495-42-8' and x.name = '1,1,1,2,3,4,4,5,5,5-Decafluoropentane' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '163702-05-4', 'Ethyl Perfluorobutyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '163702-05-4' and x.name = 'Ethyl Perfluorobutyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '163702-06-5', 'Ethyl Perfluoroisobutyl Ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '163702-06-5' and x.name = 'Ethyl Perfluoroisobutyl Ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '163702-07-8', 'Perfluoro-n-butyl methyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '163702-07-8' and x.name = 'Perfluoro-n-butyl methyl ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '163702-08-7', 'Perfluoroisobutyl methyl ether', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '163702-08-7' and x.name = 'Perfluoroisobutyl methyl ether' ); +insert into SUBSTANCE_T ( id, cas_number, name, active_date ) select SUBSTANCE_ID_SEQ.nextval, '308068-21-5', 'Marble (Total Dust)', to_date( '19000101', 'YYYYMMDD') from SYS.DUAL where not exists ( select 1 from SUBSTANCE_T x where x.cas_number = '308068-21-5' and x.name = 'Marble (Total Dust)' ); +commit; + +set define on; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'SUBSTANCE_T'); diff --git a/Chapter02/substance_t.tab b/Chapter02/substance_t.tab new file mode 100644 index 0000000..64da8db --- /dev/null +++ b/Chapter02/substance_t.tab @@ -0,0 +1,35 @@ +rem substance_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold substances + +execute drop_if_exists('table', 'SUBSTANCE_T'); +create table SUBSTANCE_T ( +id number not null, +cas_number varchar2(30) not null, +name varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute drop_if_exists('sequence', 'SUBSTANCE_ID_SEQ'); +create sequence SUBSTANCE_ID_SEQ +start with 1; + +alter table SUBSTANCE_T add +constraint SUBSTANCE_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table SUBSTANCE_T add +constraint SUBSTANCE_T_UK +unique ( +cas_number, +name ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'SUBSTANCE_T'); diff --git a/Chapter02/task_substance_t.tab b/Chapter02/task_substance_t.tab new file mode 100644 index 0000000..55adc70 --- /dev/null +++ b/Chapter02/task_substance_t.tab @@ -0,0 +1,52 @@ +rem task_substance_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold the substances assicated with a task + +execute drop_if_exists('table', 'TASK_SUBSTANCE_T'); +create table TASK_SUBSTANCE_T ( +id number not null, +task_id number not null, +substance_id number not null, +hazard_level_id number not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute drop_if_exists('sequence', 'TASK_SUBSTANCE_ID_SEQ'); +create sequence TASK_SUBSTANCE_ID_SEQ +start with 1; + +alter table TASK_SUBSTANCE_T add +constraint TASK_SUBSTANCE_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table TASK_SUBSTANCE_T add +constraint TASK_SUBSTANCE_T_UK +unique ( +task_id, +substance_id, +active_date ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table TASK_SUBSTANCE_T add +constraint TASK_SUBSTANCE_T_FK1 +foreign key ( task_id ) +references TASK_T ( id ); + +alter table TASK_SUBSTANCE_T add +constraint TASK_SUBSTANCE_T_FK2 +foreign key ( substance_id ) +references SUBSTANCE_T ( id ); + +alter table TASK_SUBSTANCE_T add +constraint TASK_SUBSTANCE_T_FK3 +foreign key ( hazard_level_id ) +references HAZARD_LEVEL_T ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'TASK_SUBSTANCE_T'); diff --git a/Chapter02/task_t.tab b/Chapter02/task_t.tab new file mode 100644 index 0000000..a11b0ce --- /dev/null +++ b/Chapter02/task_t.tab @@ -0,0 +1,39 @@ +rem task_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold task definitions + +execute drop_if_exists('table', 'TASK_T'); +create table TASK_T ( +id number not null, +name varchar2(80) not null, +narrative varchar2(2000) not null, +hazard_level_id number not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute drop_if_exists('sequence', 'TASK_ID_SEQ'); +create sequence TASK_ID_SEQ +start with 1; + +alter table TASK_T add +constraint TASK_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table TASK_T add +constraint TASK_T_UK +unique ( name ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table TASK_T add +constraint TASK_T_FK1 +foreign key ( hazard_level_id ) +references HAZARD_LEVEL_T ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'TASK_T'); diff --git a/Chapter02/to_number_or_null.fun b/Chapter02/to_number_or_null.fun new file mode 100644 index 0000000..1a6482a --- /dev/null +++ b/Chapter02/to_number_or_null.fun @@ -0,0 +1,16 @@ +create or replace FUNCTION to_number_or_null ( +aiv_number in varchar2 ) +return number is +/* +to_number_or_null.fun +by Donald J. Bales on 12/15/2006 +An errorless to_number( ) method +*/ +begin + return to_number(aiv_number); +exception + when INVALID_NUMBER then + return NULL; +end to_number_or_null; +/ +@fe.sql to_number_or_null; diff --git a/Chapter02/top_100_first_name.ins b/Chapter02/top_100_first_name.ins new file mode 100644 index 0000000..c0d7cb4 --- /dev/null +++ b/Chapter02/top_100_first_name.ins @@ -0,0 +1,108 @@ +rem top_100_first_name.ins +rem by Donald J. Bales on 12/15/2006 +rem Top 100 first names from www.namestatistics.com + +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ALICE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('AMANDA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('AMY', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANDREW', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANGELA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANN', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANNA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANTHONY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('BARBARA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('BETTY', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('BRENDA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('BRIAN', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CARL', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CAROL', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CAROLYN', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CATHERINE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CHARLES', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CHRISTINE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CHRISTOPHER', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CYNTHIA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DANIEL', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DAVID', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DEBORAH', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DEBRA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DENNIS', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DIANE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DONALD', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DONNA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DOROTHY', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DOUGLAS', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('EDWARD', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ELIZABETH', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ERIC', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('FRANCES', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('FRANK', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('GARY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('GEORGE', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('GREGORY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('HAROLD', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('HEATHER', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('HELEN', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('HENRY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JAMES', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JANET', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JASON', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JEFFREY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JENNIFER', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JERRY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JESSICA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOHN', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOSE', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOSEPH', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOSHUA', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOYCE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JULIE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KAREN', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KATHLEEN', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KENNETH', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KEVIN', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KIMBERLY', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('LARRY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('LAURA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('LINDA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('LISA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARGARET', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARIA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARIE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARK', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARTHA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MATTHEW', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MELISSA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MICHAEL', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MICHELLE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('NANCY', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PAMELA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PATRICIA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PATRICK', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PAUL', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PETER', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('RAYMOND', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('REBECCA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('RICHARD', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ROBERT', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('RONALD', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('RUTH', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SANDRA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SARAH', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SCOTT', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SHARON', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SHIRLEY', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('STEPHANIE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('STEPHEN', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('STEVEN', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SUSAN', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('THOMAS', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('TIMOTHY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('VIRGINIA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('WALTER', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('WILLIAM', 'M'); + +commit; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'TOP_100_FIRST_NAME'); diff --git a/Chapter02/top_100_first_name.tab b/Chapter02/top_100_first_name.tab new file mode 100644 index 0000000..4b69869 --- /dev/null +++ b/Chapter02/top_100_first_name.tab @@ -0,0 +1,17 @@ +rem top_100_first_name.tab +rem by Donald J. Bales on 12/15/2006 +rem Top 100 first names from www.namestatistics.com + +execute drop_if_exists('table','TOP_100_FIRST_NAME'); +create table TOP_100_FIRST_NAME ( +first_name varchar2(30) not null, +gender_code varchar2(1) not null); + +alter table TOP_100_FIRST_NAME add +constraint TOP_100_FIRST_NAME_PK +primary key ( +first_name, +gender_code ) +using index; + +@top_100_first_name.ins diff --git a/Chapter02/top_100_last_name.ins b/Chapter02/top_100_last_name.ins new file mode 100644 index 0000000..8bc0ac9 --- /dev/null +++ b/Chapter02/top_100_last_name.ins @@ -0,0 +1,108 @@ +rem top_100_last_name.ins +rem by Donald J. Bales on 12/15/2006 +rem Top 100 last names from www.namestatistics.com + +insert into TOP_100_LAST_NAME (last_name) values ('ADAMS'); +insert into TOP_100_LAST_NAME (last_name) values ('ALEXANDER'); +insert into TOP_100_LAST_NAME (last_name) values ('ALLEN'); +insert into TOP_100_LAST_NAME (last_name) values ('ANDERSON'); +insert into TOP_100_LAST_NAME (last_name) values ('BAILEY'); +insert into TOP_100_LAST_NAME (last_name) values ('BAKER'); +insert into TOP_100_LAST_NAME (last_name) values ('BARNES'); +insert into TOP_100_LAST_NAME (last_name) values ('BELL'); +insert into TOP_100_LAST_NAME (last_name) values ('BENNETT'); +insert into TOP_100_LAST_NAME (last_name) values ('BROOKS'); +insert into TOP_100_LAST_NAME (last_name) values ('BROWN'); +insert into TOP_100_LAST_NAME (last_name) values ('BRYANT'); +insert into TOP_100_LAST_NAME (last_name) values ('BUTLER'); +insert into TOP_100_LAST_NAME (last_name) values ('CAMPBELL'); +insert into TOP_100_LAST_NAME (last_name) values ('CARTER'); +insert into TOP_100_LAST_NAME (last_name) values ('CLARK'); +insert into TOP_100_LAST_NAME (last_name) values ('COLEMAN'); +insert into TOP_100_LAST_NAME (last_name) values ('COLLINS'); +insert into TOP_100_LAST_NAME (last_name) values ('COOK'); +insert into TOP_100_LAST_NAME (last_name) values ('COOPER'); +insert into TOP_100_LAST_NAME (last_name) values ('COX'); +insert into TOP_100_LAST_NAME (last_name) values ('DAVIS'); +insert into TOP_100_LAST_NAME (last_name) values ('DIAZ'); +insert into TOP_100_LAST_NAME (last_name) values ('EDWARDS'); +insert into TOP_100_LAST_NAME (last_name) values ('EVANS'); +insert into TOP_100_LAST_NAME (last_name) values ('FLORES'); +insert into TOP_100_LAST_NAME (last_name) values ('FOSTER'); +insert into TOP_100_LAST_NAME (last_name) values ('GARCIA'); +insert into TOP_100_LAST_NAME (last_name) values ('GONZALES'); +insert into TOP_100_LAST_NAME (last_name) values ('GONZALEZ'); +insert into TOP_100_LAST_NAME (last_name) values ('GRAY'); +insert into TOP_100_LAST_NAME (last_name) values ('GREEN'); +insert into TOP_100_LAST_NAME (last_name) values ('GRIFFIN'); +insert into TOP_100_LAST_NAME (last_name) values ('HALL'); +insert into TOP_100_LAST_NAME (last_name) values ('HARRIS'); +insert into TOP_100_LAST_NAME (last_name) values ('HAYES'); +insert into TOP_100_LAST_NAME (last_name) values ('HENDERSON'); +insert into TOP_100_LAST_NAME (last_name) values ('HERNANDEZ'); +insert into TOP_100_LAST_NAME (last_name) values ('HILL'); +insert into TOP_100_LAST_NAME (last_name) values ('HOWARD'); +insert into TOP_100_LAST_NAME (last_name) values ('HUGHES'); +insert into TOP_100_LAST_NAME (last_name) values ('JACKSON'); +insert into TOP_100_LAST_NAME (last_name) values ('JAMES'); +insert into TOP_100_LAST_NAME (last_name) values ('JENKINS'); +insert into TOP_100_LAST_NAME (last_name) values ('JOHNSON'); +insert into TOP_100_LAST_NAME (last_name) values ('JONES'); +insert into TOP_100_LAST_NAME (last_name) values ('KELLY'); +insert into TOP_100_LAST_NAME (last_name) values ('KING'); +insert into TOP_100_LAST_NAME (last_name) values ('LEE'); +insert into TOP_100_LAST_NAME (last_name) values ('LEWIS'); +insert into TOP_100_LAST_NAME (last_name) values ('LONG'); +insert into TOP_100_LAST_NAME (last_name) values ('LOPEZ'); +insert into TOP_100_LAST_NAME (last_name) values ('MARTIN'); +insert into TOP_100_LAST_NAME (last_name) values ('MARTINEZ'); +insert into TOP_100_LAST_NAME (last_name) values ('MILLER'); +insert into TOP_100_LAST_NAME (last_name) values ('MITCHELL'); +insert into TOP_100_LAST_NAME (last_name) values ('MOORE'); +insert into TOP_100_LAST_NAME (last_name) values ('MORGAN'); +insert into TOP_100_LAST_NAME (last_name) values ('MORRIS'); +insert into TOP_100_LAST_NAME (last_name) values ('MURPHY'); +insert into TOP_100_LAST_NAME (last_name) values ('NELSON'); +insert into TOP_100_LAST_NAME (last_name) values ('PARKER'); +insert into TOP_100_LAST_NAME (last_name) values ('PATTERSON'); +insert into TOP_100_LAST_NAME (last_name) values ('PEREZ'); +insert into TOP_100_LAST_NAME (last_name) values ('PERRY'); +insert into TOP_100_LAST_NAME (last_name) values ('PETERSON'); +insert into TOP_100_LAST_NAME (last_name) values ('PHILLIPS'); +insert into TOP_100_LAST_NAME (last_name) values ('POWELL'); +insert into TOP_100_LAST_NAME (last_name) values ('PRICE'); +insert into TOP_100_LAST_NAME (last_name) values ('RAMIREZ'); +insert into TOP_100_LAST_NAME (last_name) values ('REED'); +insert into TOP_100_LAST_NAME (last_name) values ('RICHARDSON'); +insert into TOP_100_LAST_NAME (last_name) values ('RIVERA'); +insert into TOP_100_LAST_NAME (last_name) values ('ROBERTS'); +insert into TOP_100_LAST_NAME (last_name) values ('ROBINSON'); +insert into TOP_100_LAST_NAME (last_name) values ('RODRIGUEZ'); +insert into TOP_100_LAST_NAME (last_name) values ('ROGERS'); +insert into TOP_100_LAST_NAME (last_name) values ('ROSS'); +insert into TOP_100_LAST_NAME (last_name) values ('RUSSELL'); +insert into TOP_100_LAST_NAME (last_name) values ('SANCHEZ'); +insert into TOP_100_LAST_NAME (last_name) values ('SANDERS'); +insert into TOP_100_LAST_NAME (last_name) values ('SCOTT'); +insert into TOP_100_LAST_NAME (last_name) values ('SIMMONS'); +insert into TOP_100_LAST_NAME (last_name) values ('SMITH'); +insert into TOP_100_LAST_NAME (last_name) values ('STEWART'); +insert into TOP_100_LAST_NAME (last_name) values ('TAYLOR'); +insert into TOP_100_LAST_NAME (last_name) values ('THOMAS'); +insert into TOP_100_LAST_NAME (last_name) values ('THOMPSON'); +insert into TOP_100_LAST_NAME (last_name) values ('TORRES'); +insert into TOP_100_LAST_NAME (last_name) values ('TURNER'); +insert into TOP_100_LAST_NAME (last_name) values ('WALKER'); +insert into TOP_100_LAST_NAME (last_name) values ('WARD'); +insert into TOP_100_LAST_NAME (last_name) values ('WASHINGTON'); +insert into TOP_100_LAST_NAME (last_name) values ('WATSON'); +insert into TOP_100_LAST_NAME (last_name) values ('WHITE'); +insert into TOP_100_LAST_NAME (last_name) values ('WILLIAMS'); +insert into TOP_100_LAST_NAME (last_name) values ('WILSON'); +insert into TOP_100_LAST_NAME (last_name) values ('WOOD'); +insert into TOP_100_LAST_NAME (last_name) values ('WRIGHT'); +insert into TOP_100_LAST_NAME (last_name) values ('YOUNG'); + +commit; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'TOP_100_LAST_NAME'); \ No newline at end of file diff --git a/Chapter02/top_100_last_name.tab b/Chapter02/top_100_last_name.tab new file mode 100644 index 0000000..9f92125 --- /dev/null +++ b/Chapter02/top_100_last_name.tab @@ -0,0 +1,15 @@ +rem top_100_last_name.tab +rem by Donald J. Bales on 12/15/2006 +rem Top 100 last names from www.namestatistics.com + +execute drop_if_exists('table','TOP_100_LAST_NAME'); +create table TOP_100_LAST_NAME ( +last_name varchar2(30)); + +alter table TOP_100_LAST_NAME add +constraint TOP_100_LAST_NAME_PK +primary key ( +last_name) +using index; + +@top_100_last_name.ins diff --git a/Chapter02/wait.prc b/Chapter02/wait.prc new file mode 100644 index 0000000..1f34e79 --- /dev/null +++ b/Chapter02/wait.prc @@ -0,0 +1,12 @@ +create or replace PROCEDURE wait( +ain_seconds in number) is +/* +wait.prc +by Donald J. Bales on 12/15/2006 +Wrapper for SYS.DBMS_LOCK.sleep() +*/ +begin + SYS.DBMS_LOCK.sleep(ain_seconds); +end wait; +/ +@pe.sql wait diff --git a/Chapter02/work_assignment_t.tab b/Chapter02/work_assignment_t.tab new file mode 100644 index 0000000..c932725 --- /dev/null +++ b/Chapter02/work_assignment_t.tab @@ -0,0 +1,46 @@ +rem work_assignment_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold work assignments + +--drop table WORK_ASSIGNMENT_T; +create table WORK_ASSIGNMENT_T ( +id number not null, +worker_id number not null, +work_id number not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence WORK_ASSIGNMENT_ID_SEQ; +create sequence WORK_ASSIGNMENT_ID_SEQ +start with 1; + +alter table WORK_ASSIGNMENT_T add +constraint WORK_ASSIGNMENT_T_PK +primary key ( +id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORK_ASSIGNMENT_T add +constraint WORK_ASSIGNMENT_T_UK +unique ( +worker_id, +active_date ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORK_ASSIGNMENT_T add +constraint WORK_ASSIGNMENT_T_FK1 +foreign key ( worker_id ) +references WORKER_T ( id ); + +alter table WORK_ASSIGNMENT_T add +constraint WORK_ASSIGNMENT_T_FK2 +foreign key ( work_id ) +references WORK_T ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORK_ASSIGNMENT_T'); diff --git a/Chapter02/work_t.tab b/Chapter02/work_t.tab new file mode 100644 index 0000000..d3e1d31 --- /dev/null +++ b/Chapter02/work_t.tab @@ -0,0 +1,36 @@ +rem work_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold work descriptions + +--drop table WORK_T; +create table WORK_T ( +id number not null, +code varchar2(30) not null, +name varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence WORK_ID_SEQ; +create sequence WORK_ID_SEQ +start with 1; + +alter table WORK_T add +constraint WORK_T_PK +primary key ( +id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORK_T add +constraint WORK_T_UK +unique ( +code, +name ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORK_T'); diff --git a/Chapter02/work_task_t.tab b/Chapter02/work_task_t.tab new file mode 100644 index 0000000..12d5a05 --- /dev/null +++ b/Chapter02/work_task_t.tab @@ -0,0 +1,52 @@ +rem work_task_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold the tasks associated with a work definition + +execute drop_if_exists('table', 'WORK_TASK_T'); +create table WORK_TASK_T ( +id number not null, +work_id number not null, +task_id number not null, +hazard_level_id number not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute drop_if_exists('sequence', 'WORK_TASK_ID_SEQ'); +create sequence WORK_TASK_ID_SEQ +start with 1; + +alter table WORK_TASK_T add +constraint WORK_TASK_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORK_TASK_T add +constraint WORK_TASK_T_UK +unique ( +work_id, +task_id, +active_date ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORK_TASK_T add +constraint WORK_TASK_T_FK1 +foreign key ( work_id ) +references WORK_T ( id ); + +alter table WORK_TASK_T add +constraint WORK_TASK_T_FK2 +foreign key ( task_id ) +references TASK_T ( id ); + +alter table WORK_TASK_T add +constraint WORK_TASK_T_FK3 +foreign key ( hazard_level_id ) +references HAZARD_LEVEL_T ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORK_TASK_T'); diff --git a/Chapter02/worker_t.tab b/Chapter02/worker_t.tab new file mode 100644 index 0000000..029e92e --- /dev/null +++ b/Chapter02/worker_t.tab @@ -0,0 +1,61 @@ +rem worker_t.tab +rem by Donald J. Bales on 12/15/2006 +rem + +--drop table WORKER_T; +create table WORKER_T ( +id number not null, +worker_type_id number not null, +external_id varchar2(30) not null, +first_name varchar2(30) not null, +middle_name varchar2(30), +last_name varchar2(30) not null, +name varchar2(100) not null, +birth_date date not null, +gender_id number not null ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence WORKER_ID_SEQ; +create sequence WORKER_ID_SEQ +start with 1; + +--drop sequence EXTERNAL_ID_SEQ; +create sequence EXTERNAL_ID_SEQ +start with 100000000 order; + +alter table WORKER_T add +constraint WORKER_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKER_T add +constraint WORKER_T_UK1 +unique ( external_id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKER_T add +constraint WORKER_T_UK2 +unique ( +name, +birth_date, +gender_id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKER_T add +constraint WORKER_T_FK1 +foreign key ( worker_type_id ) +references WORKER_TYPE_T ( id ); + +alter table WORKER_T add +constraint WORKER_T_FK2 +foreign key ( gender_id ) +references GENDER_T ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKER_T'); diff --git a/Chapter02/worker_type_t.ins b/Chapter02/worker_type_t.ins new file mode 100644 index 0000000..d58b203 --- /dev/null +++ b/Chapter02/worker_type_t.ins @@ -0,0 +1,34 @@ +rem worker_type_t.ins +rem by Donald J. Bales on 12/15/2006 +rem + +insert into WORKER_TYPE_T ( + id, + code, + description ) +values ( + WORKER_TYPE_ID_SEQ.nextval, + 'C', + 'Contractor' ); + +insert into WORKER_TYPE_T ( + id, + code, + description ) +values ( + WORKER_TYPE_ID_SEQ.nextval, + 'E', + 'Employee' ); + +insert into WORKER_TYPE_T ( + id, + code, + description ) +values ( + WORKER_TYPE_ID_SEQ.nextval, + 'U', + 'Unknown' ); + +commit; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKER_TYPE_T'); diff --git a/Chapter02/worker_type_t.tab b/Chapter02/worker_type_t.tab new file mode 100644 index 0000000..7fafa51 --- /dev/null +++ b/Chapter02/worker_type_t.tab @@ -0,0 +1,33 @@ +rem worker_type_t.tab +rem by Donald J. Bales on 12/15/2006 +rem + +--drop table WORKER_TYPE_T; +create table WORKER_TYPE_T ( +id number not null, +code varchar2(30) not null, +description varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence WORKER_TYPE_ID_SEQ; +create sequence WORKER_TYPE_ID_SEQ +start with 1; + +alter table WORKER_TYPE_T add +constraint WORKER_TYPE_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKER_TYPE_T add +constraint WORKER_TYPE_UK +unique ( code ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKER_TYPE_T'); diff --git a/Chapter02/workplace_type_t.ins b/Chapter02/workplace_type_t.ins new file mode 100644 index 0000000..627146c --- /dev/null +++ b/Chapter02/workplace_type_t.ins @@ -0,0 +1,14 @@ +rem workplace_type_t.ins +rem by Donald J. Bales on 12/15/2006 +rem Add workplace type code values + +insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'Y', 'N', 'B', 'Business Unit' ); +insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'Y', 'N', 'C', 'Company' ); +insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'Y', 'N', 'D', 'Department' ); +insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'N', 'Y', 'L', 'Line' ); +insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'N', 'Y', 'M', 'Machine' ); +insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'N', 'Y', 'S', 'Site' ); +insert into WORKPLACE_TYPE_T ( id, logical_indicator, physical_indicator, code, description ) values ( WORKPLACE_TYPE_ID_SEQ.nextval, 'Y', 'Y', 'U', 'Unknown' ); +commit; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKPLACE_TYPE_T'); diff --git a/Chapter02/workplace_type_t.tab b/Chapter02/workplace_type_t.tab new file mode 100644 index 0000000..87716e3 --- /dev/null +++ b/Chapter02/workplace_type_t.tab @@ -0,0 +1,35 @@ +rem workplace_type_t.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a table to hold workplace types + +--drop table WORKPLACE_TYPE_T; +create table WORKPLACE_TYPE_T ( +id number not null, +logical_indicator varchar2(1) default 'N' not null, +physical_indicator varchar2(1) default 'N' not null, +code varchar2(30) not null, +description varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence WORKPLACE_TYPE_ID_SEQ; +create sequence WORKPLACE_TYPE_ID_SEQ +start with 1; + +alter table WORKPLACE_TYPE_T add +constraint WORKPLACE_TYPE_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKPLACE_TYPE_T add +constraint WORKPLACE_TYPE_UK +unique ( code ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKPLACE_TYPE_T'); diff --git a/Chapter02/workplace_type_ts.pkb b/Chapter02/workplace_type_ts.pkb new file mode 100644 index 0000000..074a0ac --- /dev/null +++ b/Chapter02/workplace_type_ts.pkb @@ -0,0 +1,174 @@ +create or replace PACKAGE BODY WORKPLACE_TYPE_TS as +/* +workplace_type_ts.pkb +by Donald J. Bales on 12/15/2006 +Table WORKPLACE_TYPE_T's methods +*/ + + +-- FUNCTIONS + +FUNCTION get_id +return WORKPLACE_TYPE_T.id%TYPE is + +n_id WORKPLACE_TYPE_T.id%TYPE; + +begin + select WORKPLACE_TYPE_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_id( +aiv_code in WORKPLACE_TYPE_T.code%TYPE ) +return WORKPLACE_TYPE_T.id%TYPE is + +n_id WORKPLACE_TYPE_T.id%TYPE; + +begin + select id + into n_id + from WORKPLACE_TYPE_T + where code = aiv_code; + + return n_id; +end get_id; + + +-- PROCEDURES + +PROCEDURE get_code_descr( +ain_id in WORKPLACE_TYPE_T.id%TYPE, +aov_code out WORKPLACE_TYPE_T.code%TYPE, +aov_description out WORKPLACE_TYPE_T.description%TYPE ) is + +begin + select code, + description + into aov_code, + aov_description + from WORKPLACE_TYPE_T + where id = ain_id; +end get_code_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out WORKPLACE_TYPE_T.code%TYPE, +aon_id out WORKPLACE_TYPE_T.id%TYPE, +aov_description out WORKPLACE_TYPE_T.description%TYPE, +aid_on in WORKPLACE_TYPE_T.active_date%TYPE ) is + +v_code WORKPLACE_TYPE_T.code%TYPE; + +begin + select id, + description + into aon_id, + aov_description + from WORKPLACE_TYPE_T + where code = aiov_code + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); +exception + when NO_DATA_FOUND then + select id, + code, + description + into aon_id, + v_code, + aov_description + from WORKPLACE_TYPE_T + where code like aiov_code||'%' + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); + + aiov_code := v_code; +end get_code_id_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out WORKPLACE_TYPE_T.code%TYPE, +aon_id out WORKPLACE_TYPE_T.id%TYPE, +aov_description out WORKPLACE_TYPE_T.description%TYPE ) is + +begin + get_code_id_descr( + aiov_code, + aon_id, + aov_description, + SYSDATE ); +end get_code_id_descr; + +PROCEDURE help is + +begin +-- 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('WORKPLACE_TYPE_TS'); + pl(chr(9)); + pl('----------------------------------- FUNCTIONS ----------------------------------'); + pl(chr(9)); + pl('WORKPLACE_TYPE_TS.get_id'); + pl('return WORKPLACE_TYPE_T.id%TYPE;'); + pl(chr(9)||'Returns a newly allocated sequence value for id.'); + pl(chr(9)); + pl('WORKPLACE_TYPE_TS.get_id('); + pl('aiv_code in WORKPLACE_TYPE_T.code%TYPE )'); + pl('return WORKPLACE_TYPE_T.id%TYPE;'); + pl(chr(9)||'Returns the corresponding id for the specified code.'); + pl(chr(9)); + pl('----------------------------------- PROCEDURES ---------------------------------'); + pl(chr(9)); + pl('WORKPLACE_TYPE_TS.get_code_descr('); + pl('ain_id in WORKPLACE_TYPE_T.id%TYPE,'); + pl('aov_code out WORKPLACE_TYPE_T.code%TYPE,'); + pl('aov_description out WORKPLACE_TYPE_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding code and description for the specified'); + pl(chr(9)||'id.'); + pl(chr(9)); + pl('WORKPLACE_TYPE_TS.get_code_id_descr('); + pl('aiov_code in out WORKPLACE_TYPE_T.code%TYPE,'); + pl('aon_id out WORKPLACE_TYPE_T.id%TYPE,'); + pl('aov_description out WORKPLACE_TYPE_T.description%TYPE,'); + pl('aid_on in WORKPLACE_TYPE_T.active_date%TYPE );'); + pl(chr(9)||'Gets the corresponding code, id, and description for'); + pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified code and point in time.'); + pl(chr(9)); + pl('WORKPLACE_TYPE_TS.get_code_id_descr('); + pl('aiov_code in out WORKPLACE_TYPE_T.code%TYPE,'); + pl('aon_id out WORKPLACE_TYPE_T.id%TYPE,'); + pl('aov_description out WORKPLACE_TYPE_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding code, id, and description for'); + pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified code at the current point in time.'); + pl(chr(9)); + pl('WORKPLACE_TYPE_TS.help( );'); + pl(chr(9)||'Displays this help text if set serveroutput is on.'); + pl(chr(9)); + pl('WORKPLACE_TYPE_TS.test( );'); + pl(chr(9)||'Built-in test unit. It will report success or error for each test if set'); + pl(chr(9)||'serveroutput is on.'); + pl(chr(9)); +end help; + + +PROCEDURE test is + +begin + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl(chr(9)||'No tests coded at this time'); +end test; + + +end WORKPLACE_TYPE_TS; +/ +@be.sql WORKPLACE_TYPE_TS + diff --git a/Chapter02/workplace_type_ts.pks b/Chapter02/workplace_type_ts.pks new file mode 100644 index 0000000..7931f70 --- /dev/null +++ b/Chapter02/workplace_type_ts.pks @@ -0,0 +1,59 @@ +create or replace PACKAGE WORKPLACE_TYPE_TS as +/* +workplace_type_ts.pks +by Donald J. Bales on 12/15/2006 +Table WORKPLACE_TYPE_T's methods. +*/ + +/* +Gets the code and decription values for the specified id. +*/ +PROCEDURE get_code_descr( +ain_id in WORKPLACE_TYPE_T.id%TYPE, +aov_code out WORKPLACE_TYPE_T.code%TYPE, +aov_description out WORKPLACE_TYPE_T.description%TYPE); + +/* +Verifies that the passed code value is an exact or like match on the date specified. +*/ +PROCEDURE get_code_id_descr( +aiov_code in out WORKPLACE_TYPE_T.code%TYPE, +aon_id out WORKPLACE_TYPE_T.id%TYPE, +aov_description out WORKPLACE_TYPE_T.description%TYPE, +aid_on in WORKPLACE_TYPE_T.active_date%TYPE); + +/* +Verifies that the passed code value is currently an exact or like match. +*/ +PROCEDURE get_code_id_descr( +aiov_code in out WORKPLACE_TYPE_T.code%TYPE, +aon_id out WORKPLACE_TYPE_T.id%TYPE, +aov_description out WORKPLACE_TYPE_T.description%TYPE); + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return WORKPLACE_TYPE_T.id%TYPE; + +/* +Returns the id for the specified code value. +*/ +FUNCTION get_id( +aiv_code in WORKPLACE_TYPE_T.code%TYPE) +return WORKPLACE_TYPE_T.id%TYPE; + +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + +/* +Test units for this package. +*/ +PROCEDURE test; + + +end WORKPLACE_TYPE_TS; +/ +@se.sql WORKPLACE_TYPE_TS diff --git a/Chapter03/README.txt b/Chapter03/README.txt new file mode 100644 index 0000000..38bd008 --- /dev/null +++ b/Chapter03/README.txt @@ -0,0 +1,53 @@ +README.txt for Chapter 3 +by Donald J. Bales on 4/15/2007 + +OBJECT NAME DESCRIPTION +--------------------------------------- ------------------------------------- +be.sql Show package body compilation errors + +ci.sql Compile invalid packages + +desc.sql Describe an object + +fe.sql Show function compilation errors + +login.sql Set my SQL*Plus defaults + +multidimensional.sql Anonymous PL/SQL block to show the + used of nested PL/SQL tables + +parameters.pkb Create test package PARAMETERS' body + +parameters.pks Create test package PARAMETERS' + specification + +parameters.sql Test unit for test package PARAMETERS + +pe.sql Show procedure compilation errors + +pl.sql Don's handy-dandy "put_line" + procedure + +record.sql Anonymous PL/SQL block to show the + use of PL/SQL records + +row.sql Anonymous PL/SQL block to show the + use of PL/SQL tables based on a row + anchor + +scopes.pkb Create test package SCOPES' body + +scopes.pks Create test package SCOPES' + specification + +scopes.sql Test unit fot test package SCOPES + +se.sql Show package specification + compilation errors + +table.sql Anonymous PL/SQL block to show the + use of PL/SQL tables based on a + colun anchor + +solutions\worker_t_variables.sql Anonymous PL/SQL block to show the + use of column anchors diff --git a/Chapter03/be.sql b/Chapter03/be.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter03/be.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter03/ci.sql b/Chapter03/ci.sql new file mode 100644 index 0000000..6dcc7e7 --- /dev/null +++ b/Chapter03/ci.sql @@ -0,0 +1,50 @@ +rem ci.sql +rem by Donald J. Bales on 12/15/2006 +rem Compile my invalid objects + +set feedback off; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +set serveroutput on size 1000000; + +spool ci.txt; +declare + +cursor c1 is +select object_type, + object_name +from SYS.USER_OBJECTS +where status = 'INVALID' +order by 1, 2; + +v_sql varchar2(100); + +begin + for r1 in c1 loop + begin + if r1.object_type = 'PACKAGE BODY' then + v_sql := 'alter PACKAGE '||r1.object_name||' compile BODY'; + elsif r1.object_type = 'TYPE BODY' then + v_sql := 'alter TYPE '||r1.object_name||' compile BODY'; + else + v_sql := 'alter '||r1.object_type||' '||r1.object_name||' compile'; + end if; + execute immediate v_sql; + pl(r1.object_type||' '||r1.object_name||' compiled successfully'); + exception + when OTHERS then + pl(SQLERRM||' on '||v_sql); + end; + end loop; +end; +/ + +spool off; + +set feedback on; + + + + \ No newline at end of file diff --git a/Chapter03/ci.txt b/Chapter03/ci.txt new file mode 100644 index 0000000..e69de29 diff --git a/Chapter03/compile_all.sql b/Chapter03/compile_all.sql new file mode 100644 index 0000000..ec860ad --- /dev/null +++ b/Chapter03/compile_all.sql @@ -0,0 +1,14 @@ +set echo on; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +spool compile_all.txt; +@parameters.pks +@scopes.pks +@parameters.pkb +@scopes.pkb +spool off; +set echo off; +@ci.sql +@ci.sql diff --git a/Chapter03/desc.sql b/Chapter03/desc.sql new file mode 100644 index 0000000..45206dc --- /dev/null +++ b/Chapter03/desc.sql @@ -0,0 +1,6 @@ +define table_name="&1"; +set linesize 78; +prompt &table_name +desc &table_name +set linesize 1000; +undefine table_name \ No newline at end of file diff --git a/Chapter03/fe.sql b/Chapter03/fe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter03/fe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter03/login.sql b/Chapter03/login.sql new file mode 100644 index 0000000..dfde68b --- /dev/null +++ b/Chapter03/login.sql @@ -0,0 +1,10 @@ +rem login.sql +rem by Don Bales on 12/15/2006 +rem Set my default SQL*Plus environment +set linesize 1000; +set newpage 1; +set pagesize 32767; +set serveroutput on size 1000000; +set trimspool on; +alter session set nls_date_format = 'SYYYYMMDD HH24MISS'; +prompt BPS' default settings loaded successfully! diff --git a/Chapter03/multidimensional.sql b/Chapter03/multidimensional.sql new file mode 100644 index 0000000..7f200ab --- /dev/null +++ b/Chapter03/multidimensional.sql @@ -0,0 +1,31 @@ +rem multidimensional.sql +rem by Don Bales on 12/15/2006 +rem Anonymouos PL/SQL procedure to demonstrate +rem the use of nested PL/SQL tables + +declare + +TYPE name_table is table of WORKER_T.name%TYPE +index by binary_integer; + +TYPE name_record is record ( +dim2 name_table ); + +TYPE dim1 is table of name_record +index by binary_integer; + +t_dim1 dim1; + +begin + t_dim1(1).dim2(1) := 'DOE, JOHN'; + t_dim1(1).dim2(2) := 'DOE, JANE'; + + t_dim1(2).dim2(1) := 'DOUGH, JAYNE'; + t_dim1(2).dim2(2) := 'DOUGH, JON'; + + pl(t_dim1(1).dim2(1)); + pl(t_dim1(1).dim2(2)); + pl(t_dim1(2).dim2(1)); + pl(t_dim1(2).dim2(2)); +end; +/ diff --git a/Chapter03/parameters.pkb b/Chapter03/parameters.pkb new file mode 100644 index 0000000..d633942 --- /dev/null +++ b/Chapter03/parameters.pkb @@ -0,0 +1,63 @@ +create or replace package body PARAMETERS as +/* +parameters.pkb +by Donald J. Bales on 12/15/2006 +A packge to test parameter scope +*/ + +FUNCTION in_out_inout( +aiv_in in varchar2, +aov_out out varchar2, +aiov_inout in out varchar2) +return varchar2 is +begin + pl(chr(9)||'Before assignments...'); + pl(chr(9)||'Inside function in_out_inout, aiv_in = '||aiv_in); + pl(chr(9)||'Inside function in_out_inout, aov_out = '||aov_out); + pl(chr(9)||'Inside function in_out_inout, aiov_inout = '||aiov_inout); + -- You can only assign a value (write) to an OUT + -- parameter, you can't read it! + aov_out := 'OUT'; + + -- You can only read an IN parameter + aiov_inout := aiv_in; + + -- You can read and write an IN OUT parameter + aiov_inout := aiov_inout||'OUT'; + + pl(chr(9)||'After assignments...'); + pl(chr(9)||'Inside function in_out_inout, aiv_in = '||aiv_in); + pl(chr(9)||'Inside function in_out_inout, aov_out = '||aov_out); + pl(chr(9)||'Inside function in_out_inout, aiov_inout = '||aiov_inout); + return 'OK'; -- a function must return a value! +end in_out_inout; + + +PROCEDURE in_out_inout( +aiv_in in varchar2, +aov_out out varchar2, +aiov_inout in out varchar2) is +begin + pl(chr(9)||'Before assignments...'); + pl(chr(9)||'Inside procedure in_out_inout, aiv_in = '||aiv_in); + pl(chr(9)||'Inside procedure in_out_inout, aov_out = '||aov_out); + pl(chr(9)||'Inside procedure in_out_inout, aiov_inout = '||aiov_inout); + -- You can only assign a value (write) to an OUT + -- parameter, you can't read it! + aov_out := 'OUT'; + + -- You can only read an IN parameter + aiov_inout := aiv_in; + + -- You can read and write an IN OUT parameter + aiov_inout := aiov_inout||'OUT'; + pl(chr(9)||'After assignments...'); + pl(chr(9)||'Inside procedure in_out_inout, aiv_in = '||aiv_in); + pl(chr(9)||'Inside procedure in_out_inout, aov_out = '||aov_out); + pl(chr(9)||'Inside procedure in_out_inout, aiov_inout = '||aiov_inout); +end in_out_inout; + + +end PARAMETERS; +/ +@be.sql PARAMETERS diff --git a/Chapter03/parameters.pks b/Chapter03/parameters.pks new file mode 100644 index 0000000..d112247 --- /dev/null +++ b/Chapter03/parameters.pks @@ -0,0 +1,25 @@ +create or replace package PARAMETERS as +/* +parameters.pks +by Donald J. Bales on 12/15/2006 +A packge to test parameter scope +*/ + +-- A function that execises the scope of parameters +FUNCTION in_out_inout( +aiv_in in varchar2, +aov_out out varchar2, +aiov_inout in out varchar2) +return varchar2; + + +-- A procedure that execises the scope of parameters +PROCEDURE in_out_inout( +aiv_in in varchar2, +aov_out out varchar2, +aiov_inout in out varchar2); + + +end PARAMETERS; +/ +@se.sql PARAMETERS diff --git a/Chapter03/parameters.sql b/Chapter03/parameters.sql new file mode 100644 index 0000000..eee87a0 --- /dev/null +++ b/Chapter03/parameters.sql @@ -0,0 +1,41 @@ +rem parameters.sql +rem by Donald J. Bales on 12/15/2006 +rem A test unit for package PARAMETERS + +declare + +v_in varchar2(30) := 'IN'; +v_out varchar2(30) := + 'Na na, you can''t see me!'; +v_inout varchar2(30) := + 'But you can see me!'; +v_return varchar2(30); + +begin + pl('Before calling the function...'); + pl('Inside test unit parameters v_in = '||v_in); + pl('Inside test unit parameters v_out = '||v_out); + pl('Inside test unit parameters v_inout = '||v_inout); + pl('Test function PARAMETERS.in_out_inout(v_in, v_out, v_inout).'); + v_return := PARAMETERS.in_out_inout(v_in, v_out, v_inout); + pl(v_return); + pl('After calling the function...'); + pl('Inside test unit parameters v_in = '||v_in); + pl('Inside test unit parameters v_out = '||v_out); + pl('Inside test unit parameters v_inout = '||v_inout); + pl('Resetting initial values...'); + v_out := 'Na na, you can''t see me!'; + v_inout := 'But you can see me!'; + pl('Before calling the procedure...'); + pl('Inside test unit parameters v_in = '||v_in); + pl('Inside test unit parameters v_out = '||v_out); + pl('Inside test unit parameters v_inout = '||v_inout); + pl('Test procedure PARAMETERS.in_out_inout(v_in, v_out, v_inout).'); + PARAMETERS.in_out_inout(v_in, v_out, v_inout); + pl('OK'); + pl('After calling the procedure...'); + pl('Inside test unit parameters v_in = '||v_in); + pl('Inside test unit parameters v_out = '||v_out); + pl('Inside test unit parameters v_inout = '||v_inout); +end; +/ diff --git a/Chapter03/pe.sql b/Chapter03/pe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter03/pe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter03/pl.sql b/Chapter03/pl.sql new file mode 100644 index 0000000..08b13fc --- /dev/null +++ b/Chapter03/pl.sql @@ -0,0 +1,10 @@ +rem pl.sql +rem by Donald J. Bales on 12/15/2006 +rem pl's test unit + +prompt 'Test a line <= 255'; -- 20 21 22 23 24 25 +exec pl('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345'); +prompt 'Test a line > 255'; +exec pl('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); +prompt 'Test a multi-line'; +exec pl('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||chr(10)||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||chr(10)||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); diff --git a/Chapter03/record.sql b/Chapter03/record.sql new file mode 100644 index 0000000..20eaa0d --- /dev/null +++ b/Chapter03/record.sql @@ -0,0 +1,27 @@ +rem record.sql +rem by Don Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to demonstrate +rem the use of PL/SQL records + +declare + +TYPE name_record is record ( +first_name WORKER_T.first_name%TYPE, +middle_name WORKER_T.middle_name%TYPE, +last_name WORKER_T.last_name%TYPE ); + +TYPE name_table is table of name_record +index by binary_integer; + +t_name name_table; + +begin + t_name(1).first_name := 'JOHN'; + t_name(1).last_name := 'DOE'; + t_name(2).first_name := 'JANE'; + t_name(2).last_name := 'DOE'; + + pl(t_name(1).last_name||', '||t_name(1).first_name); + pl(t_name(2).last_name||', '||t_name(2).first_name); +end; +/ diff --git a/Chapter03/row.sql b/Chapter03/row.sql new file mode 100644 index 0000000..20fd478 --- /dev/null +++ b/Chapter03/row.sql @@ -0,0 +1,43 @@ +rem row.sql +rem by Don Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to demonstrate +rem the elementary use of PL/SQL tables + +declare + +TYPE name_table IS TABLE OF WORKER_T%ROWTYPE +INDEX BY BINARY_INTEGER; + +t_name name_table; + +n_name binary_integer; + +begin + t_name(1).name := 'DOE, JOHN'; + t_name(10).name := 'DOE, JANE'; + pl(t_name(1).name); + pl(t_name(10).name); + pl('There are '||t_name.count()||' elements.'); + n_name := t_name.first(); + pl('The first element is '||n_name||'.'); + n_name := t_name.next(n_name); + pl('The next element is '||n_name||'.'); + n_name := t_name.last(); + pl('The last element is '||n_name||'.'); + n_name := t_name.prior(n_name); + pl('The prior element is '||n_name||'.'); + if t_name.exists(1) then + pl('Element 1 exists.'); + end if; + pl('I''m deleting element 10'); + t_name.delete(10); + pl('There are '||t_name.count()||' elements.'); + if not t_name.exists(10) then + pl('Element 10 no longer exists.'); + end if; + pl('There are '||t_name.count()||' elements.'); + pl('I''m deleting all elements'); + t_name.delete(); + pl('There are '||t_name.count()||' elements.'); +end; +/ diff --git a/Chapter03/scopes.pkb b/Chapter03/scopes.pkb new file mode 100644 index 0000000..0238282 --- /dev/null +++ b/Chapter03/scopes.pkb @@ -0,0 +1,57 @@ +create or replace package body SCOPES as +/* +scopes.pkb +by Donald J. Bales on 12/15/2006 +A package to test scope +*/ + +-- Here's an instance (or package body) variable declaration +iv_scope varchar2(80) := + 'I''m an instance (or package body) variable'; + + +-- Here's an instance (or package body) function declaration +FUNCTION my_scope_is_instance +return varchar2 is +v_answer_1 varchar2(3) := 'Yes'; +begin + pl(chr(9)||'Can function my_scope_is_instance see variable gv_scope?'); + pl(chr(9)||gv_scope); + return v_answer_1; +end my_scope_is_instance; + + +-- Here's a global (or package spec) function declaration +FUNCTION my_scope_is_global +return varchar2 is +v_answer_2 varchar2(3) := 'Yes'; +begin + pl(chr(9)||'Can function my_scope_is_global see variable iv_scope?'); + pl(chr(9)||iv_scope); + return v_answer_2; +end my_scope_is_global; + + +-- Here's an instance (or package body) procedure declaration +PROCEDURE my_scope_is_instance is +v_answer_3 varchar2(3) := 'Yes'; +begin + pl(chr(9)||'Can procedure my_scope_is_instance see variable gv_scope?'); + pl(chr(9)||gv_scope); + pl(v_answer_3); +end my_scope_is_instance; + + +-- Here's a global (or package spec) procedure declaration +PROCEDURE my_scope_is_global is +v_answer_4 varchar2(3) := 'Yes'; +begin + pl(chr(9)||'Can procedure my_scope_is_global see variable iv_scope?'); + pl(chr(9)||iv_scope); + pl(v_answer_4); +end my_scope_is_global; + + +end SCOPES; +/ +@se.sql SCOPES diff --git a/Chapter03/scopes.pks b/Chapter03/scopes.pks new file mode 100644 index 0000000..7d53c14 --- /dev/null +++ b/Chapter03/scopes.pks @@ -0,0 +1,22 @@ +create or replace package SCOPES as +/* +scopes.pks +by Donald J. Bales on 12/15/2006 +A package to test scope +*/ + +-- Here's a global variable declaration +gv_scope varchar2(80) := + 'I''m a global (or package spec) variable'; + +-- Here's a global (or package spec) function declaration +FUNCTION my_scope_is_global +return varchar2; + +-- Here's a global (or package spec) procedure declaration +PROCEDURE my_scope_is_global; + + +end SCOPES; +/ +@se.sql SCOPES diff --git a/Chapter03/scopes.sql b/Chapter03/scopes.sql new file mode 100644 index 0000000..197fb1e --- /dev/null +++ b/Chapter03/scopes.sql @@ -0,0 +1,56 @@ +rem scopes.sql +rem by Donald J. Bales on 12/15/2006 +rem Test unit for package scopes + +declare + +-- ANONYMOUS PL/SQL BLOCK'S DECLARATION SECTION -- + +v_scope varchar2(40) := + 'I''m a local variable'; + +-- This is a local (or embedded) function +FUNCTION my_scope_is_local +return varchar2 is +v_answer_0 varchar2(3) := 'Yes'; +begin + return v_answer_0; +end my_scope_is_local; + +-- This is a local (or embedded) procedure +PROCEDURE my_scope_is_local is +v_answer varchar2(3) := 'Yes'; +begin + pl(v_answer); +end my_scope_is_local; + +begin + +-- ANONYMOUS PL/SQL BLOCK'S EXECUTABLE SECTION -- + + pl('Can I access my local variable?'); + pl(v_scope); + pl('Can I access SCOPES'' global variable?'); + pl(SCOPES.gv_scope); + pl('Can I access SCOPES'' instance variable?'); + --pl(SCOPES.iv_scope); + pl('No!'); + + pl('Can I access my local function?'); + pl(my_scope_is_local()); + pl('Can I access SCOPES'' global function?'); + pl(SCOPES.my_scope_is_global()); + pl('Can I access SCOPES'' instance function?'); + --pl(SCOPES.my_scope_is_instance()); + pl('No!'); + + pl('Can I access my local procedure?'); + my_scope_is_local(); + pl('Can I access SCOPES'' global procedure?'); + SCOPES.my_scope_is_global(); + pl('Can I access SCOPES'' instance procedure?'); + --SCOPES.my_scope_is_instance(); + pl('No!'); + +end; +/ diff --git a/Chapter03/se.sql b/Chapter03/se.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter03/se.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter03/solutions/worker_t_variables.sql b/Chapter03/solutions/worker_t_variables.sql new file mode 100644 index 0000000..0c2e354 --- /dev/null +++ b/Chapter03/solutions/worker_t_variables.sql @@ -0,0 +1,15 @@ +declare + n_id WORKER_T.id%TYPE := 1; + n_worker_type_id WORKER_T.worker_type_id%TYPE := 3; + v_external_id WORKER_T.external_id%TYPE := '6305551212'; + v_first_name WORKER_T.first_name%TYPE := 'JANE'; + v_middle_name WORKER_T.middle_name%TYPE := 'E'; + v_last_name WORKER_T.last_name%TYPE := 'DOE'; + v_name WORKER_T.name%TYPE := 'JANEDOEE'; + d_birth_date WORKER_T.birth_date%TYPE := + to_date('19800101', 'YYYYMMDD'); + n_gender_id WORKER_T.gender_id%TYPE := 1; +begin + null; +end; +/ diff --git a/Chapter03/table.sql b/Chapter03/table.sql new file mode 100644 index 0000000..e7b1881 --- /dev/null +++ b/Chapter03/table.sql @@ -0,0 +1,44 @@ +rem table.sql +rem by Don Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to demonstrate +rem the elementary use of PL/SQL tables + +declare + +TYPE name_table IS TABLE OF WORKER_T.name%TYPE +INDEX BY BINARY_INTEGER; + +t_name name_table; + +n_name binary_integer; + +begin + t_name(1) := 'DOE, JOHN'; + t_name(10) := 'DOE, JANE'; + + pl(t_name(1)); + pl(t_name(10)); + pl('There are '||t_name.count()||' elements.'); + n_name := t_name.first(); + pl('The first element is '||n_name||'.'); + n_name := t_name.next(n_name); + pl('The next element is '||n_name||'.'); + n_name := t_name.last(); + pl('The last element is '||n_name||'.'); + n_name := t_name.prior(n_name); + pl('The prior element is '||n_name||'.'); + if t_name.exists(1) then + pl('Element 1 exists.'); + end if; + pl('I''m deleting element 10'); + t_name.delete(10); + pl('There are '||t_name.count()||' elements.'); + if not t_name.exists(10) then + pl('Element 10 no longer exists.'); + end if; + pl('There are '||t_name.count()||' elements.'); + pl('I''m deleting all elements'); + t_name.delete(); + pl('There are '||t_name.count()||' elements.'); +end; +/ diff --git a/Chapter04/README.txt b/Chapter04/README.txt new file mode 100644 index 0000000..94e964b --- /dev/null +++ b/Chapter04/README.txt @@ -0,0 +1,52 @@ +README.txt for Chapter 4 +by Donald J. Bales on 4/15/2007 + +OBJECT NAME DESCRIPTION +--------------------------------------- ------------------------------------- +be.sql Show package body compilation errors + +ci.sql Compile invalid objects + +delete.sql Delete worker John J Doe + +desc.sql Describe an object + +fe.sql Show function compilation errors + +insert.sql Insert worker John J Doe + +solutions\insert_the_doe_family.sql Insert all members of the Doe family + as workers (it's a company town) + +insert_with_handled_exception.sql Insert worker John J Doe with a + handled exception + +insert_with_plsql_detection.sql Insert worker John J Doe with PL/SQL + detection + +insert_with_plsql_detection_for_update. Insert worker John J Doe with PL/SQL +sql detection for update + +insert_with_sql_detection.sql Insert worker John J Doe with SQL + detection + +login.sql Set my SQL*Plus defaults + +pe.sql Show procedure compilation errors + +pl.sql Don's handy-dandy "put_line" + procedure + +se.sql Show package specification + compilation errors + +select_no_data_found.sql Query worker John J Dough + handling exception NO_DATA_FOUND + +solutions\select_the_doe_family.sql Query the Doe family of workers + (remember, it's a company town) + +select_too_many_rows.sql Query all workers + handling exception TOO_MANY_ROWS + +update_multiple.sql Update workers diff --git a/Chapter04/be.sql b/Chapter04/be.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter04/be.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter04/ci.sql b/Chapter04/ci.sql new file mode 100644 index 0000000..6dcc7e7 --- /dev/null +++ b/Chapter04/ci.sql @@ -0,0 +1,50 @@ +rem ci.sql +rem by Donald J. Bales on 12/15/2006 +rem Compile my invalid objects + +set feedback off; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +set serveroutput on size 1000000; + +spool ci.txt; +declare + +cursor c1 is +select object_type, + object_name +from SYS.USER_OBJECTS +where status = 'INVALID' +order by 1, 2; + +v_sql varchar2(100); + +begin + for r1 in c1 loop + begin + if r1.object_type = 'PACKAGE BODY' then + v_sql := 'alter PACKAGE '||r1.object_name||' compile BODY'; + elsif r1.object_type = 'TYPE BODY' then + v_sql := 'alter TYPE '||r1.object_name||' compile BODY'; + else + v_sql := 'alter '||r1.object_type||' '||r1.object_name||' compile'; + end if; + execute immediate v_sql; + pl(r1.object_type||' '||r1.object_name||' compiled successfully'); + exception + when OTHERS then + pl(SQLERRM||' on '||v_sql); + end; + end loop; +end; +/ + +spool off; + +set feedback on; + + + + \ No newline at end of file diff --git a/Chapter04/compile_all.sql b/Chapter04/compile_all.sql new file mode 100644 index 0000000..4728ee4 --- /dev/null +++ b/Chapter04/compile_all.sql @@ -0,0 +1,10 @@ +set echo on; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +spool compile_all.txt; +spool off; +set echo off; +@ci.sql +@ci.sql diff --git a/Chapter04/delete.sql b/Chapter04/delete.sql new file mode 100644 index 0000000..861011c --- /dev/null +++ b/Chapter04/delete.sql @@ -0,0 +1,39 @@ +rem delete.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to delete +rem rows using PL/SQL literals and variables + +set serveroutput on size 1000000; + +declare + +-- I'll use this variable to hold the result +-- of the SQL delete statement. +n_count number; + +v_code GENDER_T.code%TYPE := 'M'; + +begin + + begin + delete from WORKER_T d + where d.name = 'DOE, JOHN J.' -- a literal + and d.birth_date = to_date('19800101', 'YYYYMMDD') -- a function + and d.gender_id = ( -- a sub-query + select c.gender_id + from GENDER_T c + where c.code = v_code ); -- a variable + + n_count := sql%rowcount; + exception + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on delete WORKER_T'|| + ' in filename delete.sql'); + end; + + pl(to_char(n_count)||' row(s) deleted.'); +end; +/ + +commit; diff --git a/Chapter04/desc.sql b/Chapter04/desc.sql new file mode 100644 index 0000000..45206dc --- /dev/null +++ b/Chapter04/desc.sql @@ -0,0 +1,6 @@ +define table_name="&1"; +set linesize 78; +prompt &table_name +desc &table_name +set linesize 1000; +undefine table_name \ No newline at end of file diff --git a/Chapter04/fe.sql b/Chapter04/fe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter04/fe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter04/insert.sql b/Chapter04/insert.sql new file mode 100644 index 0000000..3e2d4fd --- /dev/null +++ b/Chapter04/insert.sql @@ -0,0 +1,109 @@ +rem insert.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to insert +rem values using PL/SQL literals and variables + +set serveroutput on size 1000000; + +declare + +-- I declared these variables so I can get +-- the required ID values before I insert. +n_id WORKER_T.id%TYPE; +n_worker_type_id WORKER_T.worker_type_id%TYPE; +v_external_id WORKER_T.external_id%TYPE; +n_gender_id WORKER_T.gender_id%TYPE; + +-- I'll use this variable to hold the result +-- of the SQL insert statement. +n_count number; + +begin + + -- First, let's get the worker_type_id for a contractor + begin + select worker_type_id + into n_worker_type_id + from WORKER_TYPE_T + where code = 'C'; + exception + when OTHERS then + raise_application_error(-20002, SQLERRM|| + ' on select WORKER_TYPE_T'|| + ' in filename insert.sql'); + end; + + -- Next, let's get the gender_id for a male + begin + select gender_id + into n_gender_id + from GENDER_T + where code = 'M'; + exception + when OTHERS then + raise_application_error(-20004, SQLERRM|| + ' on select GENDER_T'|| + ' in filename insert.sql'); + end; + + -- Now, let's get the next id sequence + begin + select WORKER_ID_SEQ.nextval + into n_id + from SYS.DUAL; + exception + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select WORKER_ID_SEQ.nextval'|| + ' in filename insert.sql'); + end; + + -- And then, let's get the next external_id sequence + begin + select lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0') + into v_external_id + from SYS.DUAL; + exception + when OTHERS then + raise_application_error(-20003, SQLERRM|| + ' on select EXTERNAL_ID_SEQ.nextval'|| + ' in filename insert.sql'); + end; + + -- Now that we have all the necessary ID values + -- we can finally insert a row! + begin + insert into WORKER_T ( + id, + worker_type_id, + external_id, + first_name, + middle_name, + last_name, + name, + birth_date, + gender_id ) + values ( + n_id, -- a variable + n_worker_type_id, -- a variable + v_external_id, -- a variable + 'JOHN', -- a literal + 'J.', -- a literal + 'DOE', -- a literal + 'DOE, JOHN J.', -- a literal + to_date('19800101', 'YYYYMMDD'), -- a function + n_gender_id ); -- a variable + + n_count := sql%rowcount; + exception + when OTHERS then + raise_application_error(-20005, SQLERRM|| + ' on insert WORKER_T'|| + ' in filename insert.sql'); + end; + + pl(to_char(n_count)||' row(s) inserted.'); +end; +/ + +commit; diff --git a/Chapter04/insert_with_handled_exception.sql b/Chapter04/insert_with_handled_exception.sql new file mode 100644 index 0000000..49faa56 --- /dev/null +++ b/Chapter04/insert_with_handled_exception.sql @@ -0,0 +1,112 @@ +rem insert_with_handle_exception.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to insert +rem values using PL/SQL literals and variables + +set serveroutput on size 1000000; + +declare + +-- I declared these variables so I can get +-- the required ID values before I insert. +n_id WORKER_T.id%TYPE; +n_worker_type_id WORKER_T.worker_type_id%TYPE; +v_external_id WORKER_T.external_id%TYPE; +n_gender_id WORKER_T.gender_id%TYPE; + +-- I'll use this variable to hold the result +-- of the SQL insert statement. +n_count number; + +begin + + -- First, let's get the worker_type_id for a contractor + begin + select worker_type_id + into n_worker_type_id + from WORKER_TYPE_T + where code = 'C'; + exception + when OTHERS then + raise_application_error(-20002, SQLERRM|| + ' on select WORKER_TYPE_T'|| + ' in filename insert.sql'); + end; + + -- Next, let's get the gender_id for a male + begin + select gender_id + into n_gender_id + from GENDER_T + where code = 'M'; + exception + when OTHERS then + raise_application_error(-20004, SQLERRM|| + ' on select GENDER_T'|| + ' in filename insert.sql'); + end; + + -- Now, let's get the next id sequence + begin + select WORKER_ID_SEQ.nextval + into n_id + from SYS.DUAL; + exception + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select WORKER_ID_SEQ.nextval'|| + ' in filename insert.sql'); + end; + + -- And then, let's get the next external_id sequence + begin + select lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0') + into v_external_id + from SYS.DUAL; + exception + when OTHERS then + raise_application_error(-20003, SQLERRM|| + ' on select EXTERNAL_ID_SEQ.nextval'|| + ' in filename insert.sql'); + end; + + -- Now that we have all the necessary ID values + -- we can finally insert a row! + begin + insert into WORKER_T ( + id, + worker_type_id, + external_id, + first_name, + middle_name, + last_name, + name, + birth_date, + gender_id ) + values ( + n_id, -- a variable + n_worker_type_id, -- a variable + v_external_id, -- a variable + 'JOHN', -- a literal + 'J.', -- a literal + 'DOE', -- a literal + 'DOE, JOHN J.', -- a literal + to_date('19800101', 'YYYYMMDD'), -- a function + n_gender_id ); -- a variable + + n_count := sql%rowcount; + exception + when DUP_VAL_ON_INDEX then + n_count := 0; + pl('Caught a DUP_VAL_ON_INDEX exception'); + when OTHERS then + raise_application_error(-20005, SQLERRM|| + ' on insert WORKER_T'|| + ' in filename insert_with_handled_exception.sql'); + end; + + pl(to_char(n_count)||' row(s) inserted.'); +end; +/ + +commit; diff --git a/Chapter04/insert_with_plsql_detection.sql b/Chapter04/insert_with_plsql_detection.sql new file mode 100644 index 0000000..8a88e48 --- /dev/null +++ b/Chapter04/insert_with_plsql_detection.sql @@ -0,0 +1,147 @@ +rem insert_with_plsql_detection.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to insert +rem values using PL/SQL literals and variables + +set serveroutput on size 1000000; + +declare + +-- I declared these variables so I can get +-- the required ID values before I insert. +n_id WORKER_T.id%TYPE; +n_worker_type_id WORKER_T.worker_type_id%TYPE; +v_external_id WORKER_T.external_id%TYPE; +v_first_name WORKER_T.first_name%TYPE; +v_middle_name WORKER_T.middle_name%TYPE; +v_last_name WORKER_T.last_name%TYPE; +v_name WORKER_T.name%TYPE; +d_birth_date WORKER_T.birth_date%TYPE; +n_gender_id WORKER_T.gender_id%TYPE; + +-- I'll use this variable to hold the result +-- of the SQL insert statement. +n_count number; + +begin + v_first_name := 'JOHN'; + v_middle_name := 'J.'; + v_last_name := 'DOE'; + v_name := + rtrim(v_last_name||', '||v_first_name||' '||v_middle_name); + d_birth_date := + to_date('19800101', 'YYYYMMDD'); -- I'm guessing + + -- First, let's get the worker_type_id for a contractor + begin + select worker_type_id + into n_worker_type_id + from WORKER_TYPE_T + where code = 'C'; + exception + when OTHERS then + raise_application_error(-20002, SQLERRM|| + ' on select WORKER_TYPE_T'|| + ' in filename insert_with_plsql_detection.sql'); + end; + + -- Next, let's get the gender_id for a male + begin + select gender_id + into n_gender_id + from GENDER_T + where code = 'M'; + exception + when OTHERS then + raise_application_error(-20004, SQLERRM|| + ' on select GENDER_T'|| + ' in filename insert_with_plsql_detection.sql'); + end; + + -- Detect any existing entries with the unique + -- combination of columns as in this constraint: + -- constraint WORKER_T_UK2 + -- unique ( + -- name, + -- birth_date, + -- gender_id ) + begin + select count(1) + into n_count + from WORKER_T + where name = v_name + and birth_date = d_birth_date + and gender_id = n_gender_id; + exception + when OTHERS then + raise_application_error(-20005, SQLERRM|| + ' on select WORKER_T_T'|| + ' in filename insert_with_plsql_detection.sql'); + end; + + -- Conditionally insert the row + if n_count = 0 then + -- Now, let's get the next id sequence + begin + select WORKER_ID_SEQ.nextval + into n_id + from SYS.DUAL; + exception + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select WORKER_ID_SEQ.nextval'|| + ' in filename insert_with_plsql_detection.sql'); + end; + + -- And then, let's get the next external_id sequence + begin + select lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0') + into v_external_id + from SYS.DUAL; + exception + when OTHERS then + raise_application_error(-20003, SQLERRM|| + ' on select EXTERNAL_ID_SEQ.nextval'|| + ' in filename insert_with_plsql_detection.sql'); + end; + + -- Now that we have all the necessary ID values + -- we can finally insert a row! + begin + insert into WORKER_T ( + id, + worker_type_id, + external_id, + first_name, + middle_name, + last_name, + name, + birth_date, + gender_id ) + values ( + n_id, + n_worker_type_id, + v_external_id, + v_first_name, + v_middle_name, + v_last_name, + v_name, + d_birth_date, + n_gender_id ); + + n_count := sql%rowcount; + exception + when OTHERS then + raise_application_error(-20006, SQLERRM|| + ' on insert WORKER_T'|| + ' in filename insert_with_plsql_detection.sql'); + end; + else + n_count := 0; + end if; + + pl(to_char(n_count)||' row(s) inserted.'); +end; +/ + +commit; diff --git a/Chapter04/insert_with_plsql_detection_for_update.sql b/Chapter04/insert_with_plsql_detection_for_update.sql new file mode 100644 index 0000000..801b30d --- /dev/null +++ b/Chapter04/insert_with_plsql_detection_for_update.sql @@ -0,0 +1,162 @@ +rem insert_with_plsql_detection_for_update.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to insert +rem values using PL/SQL literals and variables + +set serveroutput on size 1000000; + +declare + +-- I declared these variables so I can get +-- the required ID values before I insert. +n_id WORKER_T.id%TYPE; +n_worker_type_id WORKER_T.worker_type_id%TYPE; +v_external_id WORKER_T.external_id%TYPE; +v_first_name WORKER_T.first_name%TYPE; +v_middle_name WORKER_T.middle_name%TYPE; +v_last_name WORKER_T.last_name%TYPE; +v_name WORKER_T.name%TYPE; +d_birth_date WORKER_T.birth_date%TYPE; +n_gender_id WORKER_T.gender_id%TYPE; + +-- I'll use these variables to hold the result +-- of the SQL insert and update statements. +n_inserted number := 0; +n_updated number := 0; + +begin + v_first_name := 'JOHN'; + v_middle_name := 'J.'; + v_last_name := 'DOE'; + v_name := + rtrim(v_last_name||', '||v_first_name||' '||v_middle_name); + d_birth_date := + to_date('19800101', 'YYYYMMDD'); -- I'm guessing + + -- First, let's get the worker_type_id for a contractor + begin + select worker_type_id + into n_worker_type_id + from WORKER_TYPE_T + where code = 'C'; + exception + when OTHERS then + raise_application_error(-20002, SQLERRM|| + ' on select WORKER_TYPE_T'|| + ' in filename insert_with_plsql_detection_for_update.sql'); + end; + + -- Next, let's get the gender_id for a male + begin + select gender_id + into n_gender_id + from GENDER_T + where code = 'M'; + exception + when OTHERS then + raise_application_error(-20004, SQLERRM|| + ' on select GENDER_T'|| + ' in filename insert_with_plsql_detection_for_update.sql'); + end; + + -- Detect any existing entries with the unique + -- combination of columns as in this constraint: + -- constraint WORKER_T_UK2 + -- unique ( + -- name, + -- birth_date, + -- gender_id ) + begin + select id + into n_id + from WORKER_T + where name = v_name + and birth_date = d_birth_date + and gender_id = n_gender_id; + exception + when NO_DATA_FOUND then + n_id := NULL; -- Is this really needed? + when OTHERS then + raise_application_error(-20003, SQLERRM|| + ' on select WORKER_T_T'|| + ' in filename insert_with_plsql_detection_for_update.sql'); + end; + + -- Conditionally insert the row + if n_id is NULL then + -- Now, let's get the next id sequence + begin + select WORKER_ID_SEQ.nextval + into n_id + from SYS.DUAL; + exception + when OTHERS then + raise_application_error(-20004, SQLERRM|| + ' on select WORKER_ID_SEQ.nextval'|| + ' in filename insert_with_plsql_detection_for_update.sql'); + end; + + -- And then, let's get the next external_id sequence + begin + select lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0') + into v_external_id + from SYS.DUAL; + exception + when OTHERS then + raise_application_error(-20005, SQLERRM|| + ' on select EXTERNAL_ID_SEQ.nextval'|| + ' in filename insert_with_plsql_detection_for_update.sql'); + end; + + -- Now that we have all the necessary ID values + -- we can finally insert a row! + begin + insert into WORKER_T ( + id, + worker_type_id, + external_id, + first_name, + middle_name, + last_name, + name, + birth_date, + gender_id ) + values ( + n_id, + n_worker_type_id, + v_external_id, + v_first_name, + v_middle_name, + v_last_name, + v_name, + d_birth_date, + n_gender_id ); + + n_inserted := sql%rowcount; + exception + when OTHERS then + raise_application_error(-20006, SQLERRM|| + ' on insert WORKER_T'|| + ' in filename insert_with_plsql_detection_for_update.sql'); + end; + else + begin + update WORKER_T + set worker_type_id = n_worker_type_id + where id = n_id; + + n_updated := sql%rowcount; + exception + when OTHERS then + raise_application_error(-20007, SQLERRM|| + ' on update WORKER_T'|| + ' in filename insert_with_plsql_detection_for_update.sql'); + end; + end if; + + pl(to_char(n_inserted)||' row(s) inserted.'); + pl(to_char(n_updated)||' row(s) updated.'); +end; +/ + +commit; diff --git a/Chapter04/insert_with_sql_detection.sql b/Chapter04/insert_with_sql_detection.sql new file mode 100644 index 0000000..5c7ad8a --- /dev/null +++ b/Chapter04/insert_with_sql_detection.sql @@ -0,0 +1,75 @@ +rem insert_with_sql_detection.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to insert +rem values using PL/SQL literals and variables + +set serveroutput on size 1000000; + +declare + +v_first_name WORKER_T.first_name%TYPE; +v_middle_name WORKER_T.middle_name%TYPE; +v_last_name WORKER_T.last_name%TYPE; +v_name WORKER_T.name%TYPE; +d_birth_date WORKER_T.birth_date%TYPE; + +-- I'll use this variable to hold the result +-- of the SQL insert statement. +n_count number; + +begin + -- Since I use these values more than once, + -- I set them here, and then use the variables + v_first_name := 'JOHN'; + v_middle_name := 'J.'; + v_last_name := 'DOE'; + v_name := + rtrim(v_last_name||', '||v_first_name||' '||v_middle_name); + d_birth_date := + to_date('19800101', 'YYYYMMDD'); -- I'm guessing + + -- Now I can just let SQL do all the work. Who needs PL/SQL! + begin + insert into WORKER_T ( + id, + worker_type_id, + external_id, + first_name, + middle_name, + last_name, + name, + birth_date, + gender_id ) + select WORKER_ID_SEQ.nextval, + c1.worker_type_id, + lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0'), + v_first_name, + v_middle_name, + v_last_name, + v_name, + d_birth_date, + c2.gender_id + from WORKER_TYPE_T c1, + GENDER_T c2 + where c1.code = 'C' + and c2.code = 'M' + and not exists ( + select 1 + from WORKER_T x + where x.name = v_name + and x.birth_date = d_birth_date + and x.gender_id = c2.gender_id ); + + n_count := sql%rowcount; + exception + when OTHERS then + raise_application_error(-20006, SQLERRM|| + ' on insert WORKER_T'|| + ' in filename insert_with_sql_detection.sql'); + end; + + pl(to_char(n_count)||' row(s) inserted.'); +end; +/ + +commit; diff --git a/Chapter04/login.sql b/Chapter04/login.sql new file mode 100644 index 0000000..839e26f --- /dev/null +++ b/Chapter04/login.sql @@ -0,0 +1,10 @@ +rem login.sql +rem by Donald J. Bales on 12/15/2006 +rem Set my default SQL*Plus environment +set linesize 1000; +set newpage 1; +set pagesize 32767; +set serveroutput on size 1000000; +set trimspool on; +alter session set nls_date_format = 'SYYYYMMDD HH24MISS'; +prompt BPS' default settings loaded successfully! diff --git a/Chapter04/pe.sql b/Chapter04/pe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter04/pe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter04/pl.sql b/Chapter04/pl.sql new file mode 100644 index 0000000..08b13fc --- /dev/null +++ b/Chapter04/pl.sql @@ -0,0 +1,10 @@ +rem pl.sql +rem by Donald J. Bales on 12/15/2006 +rem pl's test unit + +prompt 'Test a line <= 255'; -- 20 21 22 23 24 25 +exec pl('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345'); +prompt 'Test a line > 255'; +exec pl('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); +prompt 'Test a multi-line'; +exec pl('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||chr(10)||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||chr(10)||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); diff --git a/Chapter04/se.sql b/Chapter04/se.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter04/se.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter04/select_no_data_found.sql b/Chapter04/select_no_data_found.sql new file mode 100644 index 0000000..5635de8 --- /dev/null +++ b/Chapter04/select_no_data_found.sql @@ -0,0 +1,62 @@ +rem select_no_data_found.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to select +rem values using PL/SQL literals and variables + +set serveroutput on size 1000000; + +declare + +d_birth_date WORKER_T.birth_date%TYPE; +n_gender_id WORKER_T.gender_id%TYPE; +n_selected number := -1; +n_id WORKER_T.id%TYPE; +v_first_name WORKER_T.first_name%TYPE; +v_last_name WORKER_T.last_name%TYPE; +v_middle_name WORKER_T.middle_name%TYPE; +v_name WORKER_T.name%TYPE; + +begin + v_first_name := 'JOHN'; + v_middle_name := 'J.'; + v_last_name := 'DOUGH'; -- Wrong DOE, this will raise an exception + v_name := + rtrim(v_last_name||', '||v_first_name||' '||v_middle_name); + d_birth_date := + to_date('19800101', 'YYYYMMDD'); -- I'm guessing + + begin + select gender_id + into n_gender_id + from GENDER_T + where code = 'M'; + exception + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select GENDER_T'|| + ' in filename select_no_data_found.sql'); + end; + + begin + select id + into n_id + from WORKER_T + where name = v_name + and birth_date = d_birth_date + and gender_id = n_gender_id; + + n_selected := sql%rowcount; + exception + when NO_DATA_FOUND then + n_selected := sql%rowcount; + pl('Caught raised exception NO_DATA_FOUND'); + when OTHERS then + raise_application_error(-20002, SQLERRM|| + ' on select WORKER_T'|| + ' in filename select_no_data_found.sql'); + end; + + pl(to_char(n_selected)||' row(s) selected.'); +end; +/ + diff --git a/Chapter04/select_too_many_rows.sql b/Chapter04/select_too_many_rows.sql new file mode 100644 index 0000000..f71c549 --- /dev/null +++ b/Chapter04/select_too_many_rows.sql @@ -0,0 +1,65 @@ +rem select_too_many_rows.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to select +rem values using PL/SQL literals and variables + +set serveroutput on size 1000000; + +declare + +d_birth_date WORKER_T.birth_date%TYPE; +n_gender_id WORKER_T.gender_id%TYPE; +n_selected number := -1; +n_id WORKER_T.id%TYPE; +v_first_name WORKER_T.first_name%TYPE; +v_last_name WORKER_T.last_name%TYPE; +v_middle_name WORKER_T.middle_name%TYPE; +v_name WORKER_T.name%TYPE; + +begin + v_first_name := 'JOHN'; + v_middle_name := 'J.'; + v_last_name := 'DOE'; -- Wrong DOE, this will raise an exception + v_name := + rtrim(v_last_name||', '||v_first_name||' '||v_middle_name); + d_birth_date := + to_date('19800101', 'YYYYMMDD'); -- I'm guessing + + begin + select gender_id + into n_gender_id + from GENDER_T + where code = 'M'; + exception + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select GENDER_T'|| + ' in filename select_too_many_rows.sql'); + end; + + begin + select id + into n_id + from WORKER_T; +-- Let's comment the WHERE clause so I get all the rows +-- where name = v_name +-- and birth_date = d_birth_date +-- and gender_id = n_gender_id; + n_selected := sql%rowcount; + exception + when NO_DATA_FOUND then + n_selected := sql%rowcount; + pl('Caught raised exception NO_DATA_FOUND'); + when TOO_MANY_ROWS then + n_selected := sql%rowcount; + pl('Caught raised exception TOO_MANY_ROWS'); + when OTHERS then + raise_application_error(-20002, SQLERRM|| + ' on select WORKER_T'|| + ' in filename select_too_many_rows.sql'); + end; + + pl(to_char(n_selected)||' row(s) selected.'); +end; +/ + diff --git a/Chapter04/solutions/insert_the_doe_family.sql b/Chapter04/solutions/insert_the_doe_family.sql new file mode 100644 index 0000000..f2bbb37 --- /dev/null +++ b/Chapter04/solutions/insert_the_doe_family.sql @@ -0,0 +1,89 @@ +rem insert_the_doe_family.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to insert +rem values using PL/SQL literals and variables + +set serveroutput on size 1000000; + +declare + +-- I'll use this variable to hold the result +-- of the SQL insert statement. +n_count number := 0; + +-- I've declare this local (or embedded) function to +-- do the actual work of inserting values. It uses +-- SQL detection to prevent DUP_VAL_ON_INDEX exceptions. +FUNCTION add_worker( +aiv_first_name WORKER_T.first_name%TYPE, +aiv_middle_name WORKER_T.middle_name%TYPE, +aiv_last_name WORKER_T.last_name%TYPE, +aid_birth_date WORKER_T.birth_date%TYPE, +aiv_gender_code GENDER_T.code%TYPE, +aiv_worker_type_code WORKER_TYPE_T.code%TYPE) +return number is + +v_name WORKER_T.name%TYPE; + +begin + v_name := + rtrim(aiv_last_name||', '||aiv_first_name||' '||aiv_middle_name); + + -- Now I can just let SQL do all the work. Who needs PL/SQL! + begin + insert into WORKER_T ( + id, + worker_type_id, + external_id, + first_name, + middle_name, + last_name, + name, + birth_date, + gender_id ) + select WORKER_ID_SEQ.nextval, + c1.worker_type_id, + lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0'), + aiv_first_name, + aiv_middle_name, + aiv_last_name, + v_name, + aid_birth_date, + c2.gender_id + from WORKER_TYPE_T c1, + GENDER_T c2 + where c1.code = aiv_worker_type_code + and c2.code = aiv_gender_code + and not exists ( + select 1 + from WORKER_T x + where x.name = v_name + and x.birth_date = aid_birth_date + and x.gender_id = c2.gender_id ); + + return sql%rowcount; + exception + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on insert WORKER_T'|| + ' in add_worker'); + end; +end add_worker; + +begin + -- All I have to do now, is call the add_worker function + -- four times with each Doe family member's values. + n_count := n_count + add_worker( + 'JOHN', 'J.', 'DOE', to_date('19800101', 'YYYYMMDD'), 'M', 'C'); + n_count := n_count + add_worker( + 'JANE', 'J.', 'DOE', to_date('19800101', 'YYYYMMDD'), 'F', 'E'); + n_count := n_count + add_worker( + 'JOHNNY', 'E.', 'DOE', to_date('19980101', 'YYYYMMDD'), 'M', 'E'); + n_count := n_count + add_worker( + 'JANIE', 'E.', 'DOE', to_date('19980101', 'YYYYMMDD'), 'F', 'E'); + + pl(to_char(n_count)||' row(s) inserted.'); +end; +/ + +commit; diff --git a/Chapter04/solutions/select_the_doe_family.sql b/Chapter04/solutions/select_the_doe_family.sql new file mode 100644 index 0000000..640a873 --- /dev/null +++ b/Chapter04/solutions/select_the_doe_family.sql @@ -0,0 +1,62 @@ +rem select_the_doe_family.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to select +rem the first names for the Doe family from +rem the Worker table. + +set serveroutput on size 1000000; + +declare + +v_first_name WORKER_T.first_name%TYPE; +n_id WORKER_T.id%TYPE; + +-- A local function that will be called over-and-over again +-- to find the next first_name for the specified id +-- and last_name. +FUNCTION get_first_name( +aion_id in out WORKER_T.id%TYPE, +aiv_last_name in WORKER_T.last_name%TYPE) +return WORKER_T.first_name%TYPE is + +v_first_name WORKER_T.first_name%TYPE; + +begin + -- Use SQL pseudo-column rownum in order + -- to limit the SELECT to the first row + select id, + first_name + into aion_id, + v_first_name + from WORKER_T + where id > aion_id + and last_name like aiv_last_name||'%' + and rownum = 1; + + return v_first_name; +exception + when NO_DATA_FOUND then + return v_first_name; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select WORKER_T'|| + ' in show_worker'); +end get_first_name; + +begin + -- Keep track of the primary key so you + -- only retrieve the SELECTed row once + n_id := 0; + -- Loop until there's NO_DATA_FOUND + loop + -- get the first name from the local function + v_first_name := get_first_name(n_id, 'DOE'); + -- detect NO_DATA_FOUND + if v_first_name is NULL then + exit; -- Exit the loop + end if; + -- show the first_name + pl(v_first_name); + end loop; +end; +/ diff --git a/Chapter04/update_multiple.sql b/Chapter04/update_multiple.sql new file mode 100644 index 0000000..8489631 --- /dev/null +++ b/Chapter04/update_multiple.sql @@ -0,0 +1,8 @@ +update WORKER_T u +set ( u.worker_type_id, u.gender_id ) = ( +select c1.worker_type_id, c2.gender_id +from WORKER_TYPE_T c1, + GENDER_T c2 +where c1.code = decode(instr(u.first_name, 'JOHN'), 0, 'E', 'C') +and c2.code = decode(instr(u.first_name, 'JOHN'), 0, 'F', 'M') ) +where u.last_name = 'DOE'; diff --git a/Chapter05/README.txt b/Chapter05/README.txt new file mode 100644 index 0000000..6fe65c5 --- /dev/null +++ b/Chapter05/README.txt @@ -0,0 +1,86 @@ +README.txt for Chapter 5 +by Donald J. Bales on 4/15/2007 + +OBJECT NAME DESCRIPTION +--------------------------------------- ------------------------------------- +a_thru_z.ins Insert letters A - Z into A_THRU_Z + +a_thru_z.tab Create table A_THRU_Z + +be.sql Show package body compilation errors + +bulk_collect_the_doe_family.sql Query the Doe family of workers + using bulk collect + +ci.sql Compile invalid objects + +cursor_bulk_collect_the_doe_family.sql Query the Doe family of workers + using bulk collect with a cursor + +cursor_for_loop_the_doe_family.sql Query the Doe family of workers + using a cursor for loop + +cursor_the_doe_family.sql Query the Doe family of workers + using a manual loop + +dates.pkb Create utility package DATES' body + +dates.pks Create utility package DATES' + specification + +desc.sql Describe an object + +fe.sql Show function compilation errors + +insert_with_modularity.sql Insert worker John J Doe with + modularity + +insert_with_plsql_cursor_detection_for_ Insert worker John J Doe with PL/SQL +update.sql cursor detection + +login.sql Set my SQL*Plus defaults + +pe.sql Show procedure compilation errors + +pl.sql Don's handy-dandy "put_line" + procedure + +se.sql Show package specification + compilation errors + +top_100_first_name.ins Insert the top 100 first names into + TOP_100_FIRST_NAME + +top_100_first_name.tab Create table TOP_100_FIRST_NAME + +top_100_last_name.ins Insert the top 100 last names into + TOP_100_LAST_NAME + +top_100_last_name.tab Create table TOP_100_LAST_NAME + +worker_t.ins Populate the worker table using the + top 100 first and last names with an + SQL statement + +worker_t_bulk_collect.ins Populate the worker table using the + top 100 first and last names with + bulk collect + +worker_t_cursor_for_loop.ins Populate the worker table using the + top 100 first and last names with a + cursor for loop + +worker_t_forall.ins Populate the worker table using the + top 100 first and last names with + buld collect paired with forall + +worker_ts.pkb Create table package WORKER_TS' body + +worker_ts.pks Create table package WORKER_TS' + specification + +worker_type_ts.pkb Create table package WORKER_TYPE_TS' + body + +worker_type_ts.pks Create table package WORKER_TYPE_TS' + specification diff --git a/Chapter05/a_thru_z.ins b/Chapter05/a_thru_z.ins new file mode 100644 index 0000000..5b5db07 --- /dev/null +++ b/Chapter05/a_thru_z.ins @@ -0,0 +1,18 @@ +rem a_thru_z.ins +rem by Donald J. Bales on 12/15/2006 +rem The letters A through Z + +declare + +begin + for i in ascii('A')..ascii('Z') loop + insert into A_THRU_Z ( + letter ) + values ( + chr(i)); + end loop; + commit; +end; +/ + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'A_THRU_Z'); diff --git a/Chapter05/a_thru_z.tab b/Chapter05/a_thru_z.tab new file mode 100644 index 0000000..1068f13 --- /dev/null +++ b/Chapter05/a_thru_z.tab @@ -0,0 +1,15 @@ +rem a_thru_z.tab +rem by Donald J. Bales on 12/15/2006 +rem The letters A through Z + +execute drop_if_exists('table','A_THRU_Z'); +create table A_THRU_Z ( +letter varchar2(1)); + +alter table A_THRU_Z add +constraint A_THRU_Z_PK +primary key ( +letter ) +using index; + +@a_thru_z.ins diff --git a/Chapter05/be.sql b/Chapter05/be.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter05/be.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter05/bulk_collect_the_doe_family.sql b/Chapter05/bulk_collect_the_doe_family.sql new file mode 100644 index 0000000..0904f19 --- /dev/null +++ b/Chapter05/bulk_collect_the_doe_family.sql @@ -0,0 +1,28 @@ +rem bulk_collect_the_doe_family.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to select +rem the first names for the Doe family from +rem the Worker table. + +set serveroutput on size 1000000; + +declare + +TYPE worker_table is table of WORKER_T.first_name%TYPE +index by binary_integer; + +t_worker worker_table; + +begin + select first_name + BULK COLLECT + into t_worker + from WORKER_T + where last_name like 'DOE%' + order by id; + + for i in t_worker.first..t_worker.last loop + pl(t_worker(i)); + end loop; +end; +/ diff --git a/Chapter05/ci.sql b/Chapter05/ci.sql new file mode 100644 index 0000000..6dcc7e7 --- /dev/null +++ b/Chapter05/ci.sql @@ -0,0 +1,50 @@ +rem ci.sql +rem by Donald J. Bales on 12/15/2006 +rem Compile my invalid objects + +set feedback off; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +set serveroutput on size 1000000; + +spool ci.txt; +declare + +cursor c1 is +select object_type, + object_name +from SYS.USER_OBJECTS +where status = 'INVALID' +order by 1, 2; + +v_sql varchar2(100); + +begin + for r1 in c1 loop + begin + if r1.object_type = 'PACKAGE BODY' then + v_sql := 'alter PACKAGE '||r1.object_name||' compile BODY'; + elsif r1.object_type = 'TYPE BODY' then + v_sql := 'alter TYPE '||r1.object_name||' compile BODY'; + else + v_sql := 'alter '||r1.object_type||' '||r1.object_name||' compile'; + end if; + execute immediate v_sql; + pl(r1.object_type||' '||r1.object_name||' compiled successfully'); + exception + when OTHERS then + pl(SQLERRM||' on '||v_sql); + end; + end loop; +end; +/ + +spool off; + +set feedback on; + + + + \ No newline at end of file diff --git a/Chapter05/ci.txt b/Chapter05/ci.txt new file mode 100644 index 0000000..e69de29 diff --git a/Chapter05/compile_all.sql b/Chapter05/compile_all.sql new file mode 100644 index 0000000..7319655 --- /dev/null +++ b/Chapter05/compile_all.sql @@ -0,0 +1,35 @@ +set echo on; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +spool compile_all.txt; +@a_thru_z.tab +@top_100_first_name.tab +@top_100_last_name.tab +@dates.pks +@gender_ts.pks +@worker_type_ts.pks +@worker_ts.pks +@dates.pkb +@gender_ts.pkb +@worker_type_ts.pkb +@worker_ts.pkb +@.\solutions\worker_ts.pks +@.\solutions\worker_ts.pkb +delete worker_t; +commit; +@.\solutions\worker_t_cursor_for_loop.ins +delete worker_t; +commit; +@.\solutions\worker_t_bulk_collect.ins +delete worker_t; +commit; +@worker_t_forall.ins +delete worker_t; +commit; +@worker_t.ins +spool off; +set echo off; +@ci.sql +@ci.sql diff --git a/Chapter05/cursor_bulk_collect_the_doe_family.sql b/Chapter05/cursor_bulk_collect_the_doe_family.sql new file mode 100644 index 0000000..84fce49 --- /dev/null +++ b/Chapter05/cursor_bulk_collect_the_doe_family.sql @@ -0,0 +1,35 @@ +rem cursor_bulk_collect_the_doe_family.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to select +rem the first names for the Doe family from +rem the Worker table. + +set serveroutput on size 1000000; + +declare + +cursor c_worker( +aiv_last_name in WORKER_T.last_name%TYPE) is +select first_name +from WORKER_T +where last_name like aiv_last_name||'%' +order by id; + +TYPE c_worker_table is table of c_worker%ROWTYPE +index by binary_integer; + +t_worker c_worker_table; + +begin + open c_worker('DOE'); + loop + fetch c_worker bulk collect into t_worker limit 2; + + exit when t_worker.count = 0; + + for i in t_worker.first..t_worker.last loop + pl(t_worker(i).first_name); + end loop; + end loop; +end; +/ diff --git a/Chapter05/cursor_for_loop_the_doe_family.sql b/Chapter05/cursor_for_loop_the_doe_family.sql new file mode 100644 index 0000000..b067fb5 --- /dev/null +++ b/Chapter05/cursor_for_loop_the_doe_family.sql @@ -0,0 +1,23 @@ +rem cursor_for_loop_the_doe_family.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to select +rem the first names for the Doe family from +rem the Worker table. + +set serveroutput on size 1000000; + +declare + +cursor c_worker( +aiv_last_name in WORKER_T.last_name%TYPE) is +select first_name +from WORKER_T +where last_name like aiv_last_name||'%' +order by id; + +begin + for r_worker in c_worker('DOE') loop + pl(r_worker.first_name); + end loop; +end; +/ diff --git a/Chapter05/cursor_the_doe_family.sql b/Chapter05/cursor_the_doe_family.sql new file mode 100644 index 0000000..2c26905 --- /dev/null +++ b/Chapter05/cursor_the_doe_family.sql @@ -0,0 +1,33 @@ +rem cursor_the_doe_family.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to select +rem the first names for the Doe family from +rem the Worker table. + +set serveroutput on size 1000000; + +declare + +cursor c_worker( +aiv_last_name in WORKER_T.last_name%TYPE) is +select first_name +from WORKER_T +where last_name like aiv_last_name||'%' +order by id; + +v_first_name WORKER_T.first_name%TYPE; + +begin + open c_worker('DOE'); + loop + fetch c_worker into v_first_name; + + if c_worker%notfound then + close c_worker; + exit; + end if; + + pl(v_first_name); + end loop; +end; +/ diff --git a/Chapter05/dates.pkb b/Chapter05/dates.pkb new file mode 100644 index 0000000..5cc6a63 --- /dev/null +++ b/Chapter05/dates.pkb @@ -0,0 +1,192 @@ +create or replace package body DATES as +/* +dates.pkb +by Donald J. Bales on 12/15/2006 +Additional DATE data type methods +*/ + + +FUNCTION end_of_day( +aid_date in date ) +return date is + +begin + return to_date(to_char(aid_date, 'SYYYYMMDD')||'235959', 'SYYYYMMDDHH24MISS'); +end end_of_day; + + +FUNCTION get_max +return date is + +begin + return d_MAX; +end get_max; + + +FUNCTION get_min +return date is + +begin + return d_MIN; +end get_min; + + +FUNCTION random( +ain_starting_year in number, +ain_ending_year in number ) +return date is + +d_random date; +n_day number; +n_month number; +n_year number; + +begin + n_year := round(DBMS_RANDOM.value(ain_starting_year, ain_ending_year), 0); + --pl('n_year='||n_year); + loop + n_month := round(DBMS_RANDOM.value(1, 12), 0); + --pl('n_month='||n_month); + n_day := round(DBMS_RANDOM.value(1, 31), 0); + --pl('n_day='||n_day); + begin + d_random := to_date(lpad(to_char(n_year), 4, '0')|| + lpad(to_char(n_month), 2, '0')|| + lpad(to_char(n_day), 2, '0'), + 'YYYYMMDD'); + exit; + exception + when OTHERS then + if SQLCODE <> -1839 then + pl(SQLERRM); + --else + -- pl('29-31'); + end if; + end; + end loop; + return d_random; +end random; + + +FUNCTION start_of_day( +aid_date in date ) +return date is + +begin + return trunc(aid_date); +end start_of_day; + + +-- Write up the help text here in this help method +PROCEDURE help is + +begin +-- 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('DATES'); + pl(chr(9)); + pl('----------------------------------- CONSTANTS ----------------------------------'); + pl(chr(9)); + pl('d_MAX'); + pl(chr(9)||'Represents the maximum value for the DATE data type.'); + pl('d_MIN'); + pl(chr(9)||'Represents the minimum value for the DATE data type.'); + pl(chr(9)); + pl('----------------------------------- FUNCTIONS ----------------------------------'); + pl(chr(9)); + pl('DATES.end_of_day('); + pl('aid_date in date)'); + pl('return date;'); + pl(chr(9)||'Returns the passed date with the time portion set to the end of the day:'); + pl(chr(9)||'23:59:59 (HH24:MI:SS).'); + pl(chr(9)); + pl('DATES.get_max( )'); + pl('return date;'); + pl(chr(9)||'Returns the constant DATES.d_MAX.'); + pl(chr(9)); + pl('DATES.get_mim( )'); + pl('return date;'); + pl(chr(9)||'Returns the constant DATES.d_MIN.'); + pl(chr(9)); + pl('DATES.random('); + pl('ain_starting_year in number,'); + pl('ain_ending_year in number)'); + pl('return date;'); + pl(chr(9)||'Returns a random date that exists between the specified years.'); + pl(chr(9)); + pl('DATES.start_of_day('); + pl('aid_date in date)'); + pl('return date;'); + pl(chr(9)||'Returns the passed date with the time portion set to the start of the day:'); + pl(chr(9)||'00:00:00 (HH24:MI:SS).'); + pl(chr(9)); + pl('----------------------------------- PROCEDURES ---------------------------------'); + pl(chr(9)); + pl('DATES.help( );'); + pl(chr(9)||'Displays this help text if set serveroutput is on.'); + pl(chr(9)); + pl('DATES.test( );'); + pl(chr(9)||'Built-in test unit. It will report success or error for each test if set'); + pl(chr(9)||'serveroutput is on.'); + pl(chr(9)); +end help; + + +-- Write up the test plan here in this test unit method +PROCEDURE test is + +d_date date; + +begin + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('DATES'); + pl(chr(9)); + pl('1. Testing constants d_MIN and d_MAX'); + if d_MIN < d_MAX then + pl('SUCCESS'); + else + pl('ERROR: d_MIN is not less than d_MAX'); + end if; + + pl('2. Testing end_of_day()'); + if to_char(end_of_day(SYSDATE), 'HH24MISS') = '235959' then + pl('SUCCESS'); + else + pl('ERROR: end_of_day is not 23:59:59'); + end if; + + pl('3. Testing get_max()'); + if get_max() = d_MAX then + pl('SUCCESS'); + else + pl('ERROR: get_max() is not equal to d_MAX'); + end if; + + pl('4. Testing get_min()'); + if get_min() = d_MIN then + pl('SUCCESS'); + else + pl('ERROR: get_min() is not equal to d_MIN'); + end if; + + pl('5. Testing random() 1000 times'); + for i in 1..1000 loop + d_date := random(1, 9999); + --pl(to_char(d_date, 'YYYY-MM-DD HH24:MI:SS')); + end loop; + pl('SUCCESS'); + + pl('6. Testing start_of_day()'); + if to_char(start_of_day(SYSDATE), 'HH24MISS') = '000000' then + pl('SUCCESS'); + else + pl('ERROR: start_of_day is not 00:00:00'); + end if; +end test; + + +end DATES; +/ +@be.sql DATES diff --git a/Chapter05/dates.pks b/Chapter05/dates.pks new file mode 100644 index 0000000..9103fe4 --- /dev/null +++ b/Chapter05/dates.pks @@ -0,0 +1,60 @@ +create or replace package DATES as +/* +dates.pks +by Donald J. Bales on 12/15/2006 +Additional DATE data type methods. +*/ + +-- The maximum and minimum dates values. + +d_MAX constant date := to_date('99991231235959', 'YYYYMMDDHH24MISS'); +d_MIN constant date := to_date('-47120101', 'SYYYYMMDD'); + + +-- Returns the specified date with the time set to 23:59:59, therefore, the end of the day. + +FUNCTION end_of_day( +aid_date in date ) +return date; + + +-- Returns constant d_MAX. This is useful in SQL statements where the constant DATES.d_MAX is not accessible. + +FUNCTION get_max +return date; + + +-- Returns constant d_MIN. This is useful in SQL statements where the constant DATES.d_MIN is not accessible. + +FUNCTION get_min +return date; + + +-- Text-based help for this package. "set serveroutput on" in SQL*Plus. + +PROCEDURE help; + + +-- Returns a randomly generated date that exists between the years specified. + +FUNCTION random( +ain_starting_year in number, +ain_ending_year in number ) +return date; + + +-- Returns the specified date with the time set to 00:00:00, therefore, the start of the day. + +FUNCTION start_of_day( +aid_date in date ) +return date; + + +-- Test unit for this package. + +PROCEDURE test; + + +end DATES; +/ +@se.sql DATES diff --git a/Chapter05/desc.sql b/Chapter05/desc.sql new file mode 100644 index 0000000..45206dc --- /dev/null +++ b/Chapter05/desc.sql @@ -0,0 +1,6 @@ +define table_name="&1"; +set linesize 78; +prompt &table_name +desc &table_name +set linesize 1000; +undefine table_name \ No newline at end of file diff --git a/Chapter05/drop_if_exists.prc b/Chapter05/drop_if_exists.prc new file mode 100644 index 0000000..f6e3017 --- /dev/null +++ b/Chapter05/drop_if_exists.prc @@ -0,0 +1,56 @@ +create or replace PROCEDURE drop_if_exists( +aiv_object_type in varchar2, +aiv_object_name in varchar2) is +/* +drop_if_exists.prc +by Donald J. Bales on 12/15/2006 +Drop the object if it exists +*/ + +cursor c_constraint( +aiv_table_name in varchar2) is +select f.table_name, + f.constraint_name +from SYS.USER_CONSTRAINTS f, + SYS.USER_CONSTRAINTS p +where f.constraint_type = 'R' +and f.r_owner = p.owner +and f.r_constraint_name = p.constraint_name +and p.table_name = aiv_table_name; + +n_count number; +v_sql varchar2(100); + +begin + select count(1) + into n_count + from SYS.USER_OBJECTS + where object_type = upper(aiv_object_type) + and object_name = upper(aiv_object_name); + + if n_count > 0 then + if upper(aiv_object_type) = 'TABLE' then + for r_constraint in c_constraint(upper(aiv_object_name)) loop + v_sql := 'alter table '|| + r_constraint.table_name|| + ' drop constraint '|| + r_constraint.constraint_name; + begin + execute immediate v_sql; + exception + when OTHERS then + pl(SQLERRM||': '||v_sql); + end; + end loop; + end if; + v_sql := 'drop '||aiv_object_type||' '||aiv_object_name; + begin + execute immediate v_sql; + exception + when OTHERS then + pl(SQLERRM||': '||v_sql); + end; + end if; +end drop_if_exists; +/ +@pe.sql diff --git a/Chapter05/fe.sql b/Chapter05/fe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter05/fe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter05/gender_ts.pkb b/Chapter05/gender_ts.pkb new file mode 100644 index 0000000..4cbce95 --- /dev/null +++ b/Chapter05/gender_ts.pkb @@ -0,0 +1,177 @@ +create or replace PACKAGE BODY GENDER_TS as +/* +gender_ts.pkb +by Don Bales on 12/15/2006 +Table GENDER_T's methods +*/ + + +-- FUNCTIONS + +FUNCTION get_id +return GENDER_T.id%TYPE is + +n_id GENDER_T.id%TYPE; + +begin + select GENDER_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_id( +aiv_code in GENDER_T.code%TYPE ) +return GENDER_T.id%TYPE is + +n_id GENDER_T.id%TYPE; + +begin + select id + into n_id + from GENDER_T + where code = aiv_code; + + return n_id; +end get_id; + + +-- PROCEDURES + +PROCEDURE get_code_descr( +ain_id in GENDER_T.id%TYPE, +aov_code out GENDER_T.code%TYPE, +aov_description out GENDER_T.description%TYPE ) is + +begin + select code, + description + into aov_code, + aov_description + from GENDER_T + where id = ain_id; +end get_code_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE, +aid_on in GENDER_T.active_date%TYPE ) is + +v_code GENDER_T.code%TYPE; + +begin + select id, + description + into aon_id, + aov_description + from GENDER_T + where code = aiov_code + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); +exception + when NO_DATA_FOUND then + select id, + code, + description + into aon_id, + v_code, + aov_description + from GENDER_T + where code like aiov_code||'%' + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); + + aiov_code := v_code; +end get_code_id_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE ) is + +begin + get_code_id_descr( + aiov_code, + aon_id, + aov_description, + SYSDATE ); +end get_code_id_descr; + + +PROCEDURE help is + +begin +-- 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('GENDER_TS'); + pl(chr(9)); + pl('----------------------------------- FUNCTIONS ----------------------------------'); + pl(chr(9)); + pl('GENDER_TS.get_id'); + pl('return GENDER_T.id%TYPE;'); + pl(chr(9)||'Returns a newly allocated sequence value for id.'); + pl(chr(9)); + pl('GENDER_TS.get_id('); + pl('aiv_code in GENDER_T.code%TYPE )'); + pl('return GENDER_T.id%TYPE;'); + pl(chr(9)||'Returns the corresponding id for the specified code.'); + pl(chr(9)); + pl('----------------------------------- PROCEDURES ---------------------------------'); + pl(chr(9)); + pl('GENDER_TS.get_code_descr('); + pl('ain_id in GENDER_T.id%TYPE,'); + pl('aov_code out GENDER_T.code%TYPE,'); + pl('aov_description out GENDER_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding code and description for the specified'); + pl(chr(9)||'id.'); + pl(chr(9)); + pl('GENDER_TS.get_code_id_descr('); + pl('aiov_code in out GENDER_T.code%TYPE,'); + pl('aon_id out GENDER_T.id%TYPE,'); + pl('aov_description out GENDER_T.description%TYPE,'); + pl('aid_on in GENDER_T.active_date%TYPE );'); + pl(chr(9)||'Gets the corresponding code, id, and description for'); + pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified code and point in time.'); + pl(chr(9)); + pl('GENDER_TS.get_code_id_descr('); + pl('aiov_code in out GENDER_T.code%TYPE,'); + pl('aon_id out GENDER_T.id%TYPE,'); + pl('aov_description out GENDER_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding code, id, and description for'); + pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified code at the current point in time.'); + pl(chr(9)); + pl('GENDER_TS.help( );'); + pl(chr(9)||'Displays this help text if set serveroutput is on.'); + pl(chr(9)); + pl('GENDER_TS.test( );'); + pl(chr(9)||'Built-in test unit. It will report success or error for each test if set'); + pl(chr(9)||'serveroutput is on.'); + pl(chr(9)); +end help; + + +PROCEDURE test is + +begin + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('GENDER_TS'); + pl(chr(9)); + pl(chr(9)||'No tests coded at this time'); +end test; + + +end GENDER_TS; +/ +@be.sql GENDER_TS + diff --git a/Chapter05/gender_ts.pks b/Chapter05/gender_ts.pks new file mode 100644 index 0000000..6a39757 --- /dev/null +++ b/Chapter05/gender_ts.pks @@ -0,0 +1,58 @@ +create or replace PACKAGE GENDER_TS as +/* +gender_ts.pks +by Don Bales on 12/15/2006 +Table GENDER_T's methods. +*/ + +/* +Gets the code and decription values for the specified id. +*/ +PROCEDURE get_code_descr( +ain_id in GENDER_T.id%TYPE, +aov_code out GENDER_T.code%TYPE, +aov_description out GENDER_T.description%TYPE); + +/* +Verifies that the passed code value is an exact or like match on the date specified. +*/ +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE, +aid_on in GENDER_T.active_date%TYPE); + +/* +Verifies that the passed code value is currently an exact or like match. +*/ +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE); + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return GENDER_T.id%TYPE; + +/* +Returns the id for the specified code value. +*/ +FUNCTION get_id( +aiv_code in GENDER_T.code%TYPE) +return GENDER_T.id%TYPE; + +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + +/* +Test units for this package. +*/ +PROCEDURE test; + +end GENDER_TS; +/ +@se.sql GENDER_TS diff --git a/Chapter05/insert_with_plsql_cursor_detection_for_update.sql b/Chapter05/insert_with_plsql_cursor_detection_for_update.sql new file mode 100644 index 0000000..02b4d81 --- /dev/null +++ b/Chapter05/insert_with_plsql_cursor_detection_for_update.sql @@ -0,0 +1,208 @@ +rem insert_with_plsql_cursor_detection_for_update.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to insert +rem values using PL/SQL literals and variables + +set serveroutput on size 1000000; + +declare + +cursor c_worker_type( +aiv_code in WORKER_TYPE_T.code%TYPE) is +select id +from WORKER_TYPE_T +where code = aiv_code; + +cursor c_gender( +aiv_code in GENDER_T.code%TYPE) is +select id +from GENDER_T +where code = aiv_code; + +cursor c_worker( +aiv_name in WORKER_T.name%TYPE, +aid_birth_date in WORKER_T.birth_date%TYPE, +ain_gender_id in WORKER_T.gender_id%TYPE) is +select id +from WORKER_T +where name = aiv_name +and birth_date = aid_birth_date +and gender_id = ain_gender_id; + +cursor c_worker_id is +select WORKER_ID_SEQ.nextval worker_id +from SYS.DUAL; + +cursor c_external_id is +select lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0') external_id +from SYS.DUAL; + +-- I declared these variables so I can get +-- the required ID values before I insert. +n_id WORKER_T.id%TYPE; +n_worker_type_id WORKER_T.worker_type_id%TYPE; +v_external_id WORKER_T.external_id%TYPE; +v_first_name WORKER_T.first_name%TYPE; +v_middle_name WORKER_T.middle_name%TYPE; +v_last_name WORKER_T.last_name%TYPE; +v_name WORKER_T.name%TYPE; +d_birth_date WORKER_T.birth_date%TYPE; +n_gender_id WORKER_T.gender_id%TYPE; + +-- I'll use these variables to hold the result +-- of the SQL insert and update statements. +n_inserted number := 0; +n_updated number := 0; + +begin + v_first_name := 'JOHN'; + v_middle_name := 'J.'; + v_last_name := 'DOE'; + v_name := + rtrim(v_last_name||', '||v_first_name||' '||v_middle_name); + d_birth_date := + to_date('19800101', 'YYYYMMDD'); -- I'm guessing + + -- First, let's get the worker_type_id for a contractor + begin + open c_worker_type('C'); + fetch c_worker_type + into n_worker_type_id; + if c_worker_type%notfound then + raise_application_error(-20001, + 'Can''t find the worker type ID for Contractor.'|| + ' on select WORKER_TYPE_T'|| + ' in filename insert_with_plsql_cursor_detection_for_update.sql'); + end if; + close c_worker_type; + exception + when OTHERS then + raise_application_error(-20002, SQLERRM|| + ' on select WORKER_TYPE_T'|| + ' in filename insert_with_plsql_cursor_detection_for_update.sql'); + end; + + -- Next, let's get the gender_id for a male + begin + open c_gender('M'); + fetch c_gender + into n_gender_id; + if c_gender%notfound then + raise_application_error(-20003, + 'Can''t find the gender ID for Male.'|| + ' on select GENDER_T'|| + ' in filename insert_with_plsql_cursor_detection_for_update.sql'); + end if; + close c_gender; + exception + when OTHERS then + raise_application_error(-20004, SQLERRM|| + ' on select GENDER_T'|| + ' in filename insert_with_plsql_cursor_detection_for_update.sql'); + end; + + -- Detect any existing entries with the unique + -- combination of columns as in this constraint: + -- constraint WORKER_T_UK2 + -- unique ( + -- name, + -- birth_date, + -- gender_id ) + begin + open c_worker(v_name, d_birth_date, n_gender_id); + fetch c_worker + into n_id; + if c_worker%notfound then + n_id := NULL; + end if; + close c_worker; + exception + when OTHERS then + raise_application_error(-20005, SQLERRM|| + ' on select WORKER_T'|| + ' in filename insert_with_plsql_cursor_detection_for_update.sql'); + end; + + -- Conditionally insert the row + if n_id is NULL then + -- Now, let's get the next worker_id sequence + begin + open c_worker_id; + fetch c_worker_id + into n_id; + close c_worker_id; + exception + when OTHERS then + raise_application_error(-20006, SQLERRM|| + ' on select WORKER_ID_SEQ.nextval'|| + ' in filename insert_with_plsql_cursor_detection_for_update.sql'); + end; + + -- And then, let's get the next external_id sequence + begin + open c_external_id; + fetch c_external_id + into v_external_id; + if c_external_id%notfound then + v_external_id := NULL; + end if; + close c_external_id; + exception + when OTHERS then + raise_application_error(-20006, SQLERRM|| + ' on select EXTERNAL_ID_SEQ.nextval'|| + ' in filename insert_with_plsql_cursor_detection_for_update.sql'); + end; + + -- Now that we have all the necessary ID values + -- we can finally insert a row! + begin + insert into WORKER_T ( + id, + worker_type_id, + external_id, + first_name, + middle_name, + last_name, + name, + birth_date, + gender_id ) + values ( + n_id, + n_worker_type_id, + v_external_id, + v_first_name, + v_middle_name, + v_last_name, + v_name, + d_birth_date, + n_gender_id ); + + n_inserted := sql%rowcount; + exception + when OTHERS then + raise_application_error(-20007, SQLERRM|| + ' on insert WORKER_T'|| + ' in filename insert_with_plsql_cursor_detection_for_update.sql'); + end; + else + begin + update WORKER_T + set worker_type_id = n_worker_type_id + where id = n_id; + + n_updated := sql%rowcount; + exception + when OTHERS then + raise_application_error(-20008, SQLERRM|| + ' on update WORKER_T'|| + ' in filename insert_with_plsql_cursor_detection_for_update.sql'); + end; + end if; + + pl(to_char(n_inserted)||' row(s) inserted.'); + pl(to_char(n_updated)||' row(s) updated.'); +end; +/ + +commit; diff --git a/Chapter05/login.sql b/Chapter05/login.sql new file mode 100644 index 0000000..839e26f --- /dev/null +++ b/Chapter05/login.sql @@ -0,0 +1,10 @@ +rem login.sql +rem by Donald J. Bales on 12/15/2006 +rem Set my default SQL*Plus environment +set linesize 1000; +set newpage 1; +set pagesize 32767; +set serveroutput on size 1000000; +set trimspool on; +alter session set nls_date_format = 'SYYYYMMDD HH24MISS'; +prompt BPS' default settings loaded successfully! diff --git a/Chapter05/pe.sql b/Chapter05/pe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter05/pe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter05/pl.prc b/Chapter05/pl.prc new file mode 100644 index 0000000..10b8e34 --- /dev/null +++ b/Chapter05/pl.prc @@ -0,0 +1,14 @@ +create or replace PROCEDURE pl( +aiv_text in varchar2 ) is +/* +pl.prc +by Donald J. Bales on 12/15/2006 +A wrapper procedure for SYS.DBMS_OUTPUT.put_line() +for the lazy typist. +*/ + +begin + SYS.DBMS_OUTPUT.put_line(aiv_text); +end pl; +/ +@pe.sql pl diff --git a/Chapter05/pl.sql b/Chapter05/pl.sql new file mode 100644 index 0000000..08b13fc --- /dev/null +++ b/Chapter05/pl.sql @@ -0,0 +1,10 @@ +rem pl.sql +rem by Donald J. Bales on 12/15/2006 +rem pl's test unit + +prompt 'Test a line <= 255'; -- 20 21 22 23 24 25 +exec pl('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345'); +prompt 'Test a line > 255'; +exec pl('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); +prompt 'Test a multi-line'; +exec pl('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||chr(10)||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||chr(10)||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); diff --git a/Chapter05/se.sql b/Chapter05/se.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter05/se.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter05/solutions/insert_with_modularity.sql b/Chapter05/solutions/insert_with_modularity.sql new file mode 100644 index 0000000..d15db21 --- /dev/null +++ b/Chapter05/solutions/insert_with_modularity.sql @@ -0,0 +1,85 @@ +rem insert_with_modularity.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to insert +rem values using PL/SQL functions + +set serveroutput on size 1000000; + +declare + +-- I declared this record, so I can get +-- the required ID values before I insert. +r_worker WORKER_T%ROWTYPE; + +-- I'll use this variable to hold the result +-- of the SQL insert statement. +n_count number := 0; + +begin + r_worker.first_name := 'JOHN'; + r_worker.middle_name := 'J.'; + r_worker.last_name := 'DOE'; + -- Using the same function to get this derived value + -- from all programs will ensure its value is consistent + r_worker.name := WORKER_TS.get_formatted_name( + r_worker.first_name, r_worker.middle_name, r_worker.last_name); + r_worker.birth_date := + to_date('19800101', 'YYYYMMDD'); -- I'm guessing + + -- First, let's get the worker_type_id for a contractor + begin + r_worker.worker_type_id := WORKER_TYPE_TS.get_id('C'); + exception + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on call WORKER_TYPE_TS.get_id(''C'')'|| + ' in filename insert_with_modularity.sql'); + end; + + -- Next, let's get the gender_id for a male + begin + r_worker.gender_id := GENDER_TS.get_id('M'); + exception + when OTHERS then + raise_application_error(-20002, SQLERRM|| + ' on call GENDER_TS.get_id(''M'')'|| + ' in filename insert_with_modularity.sql'); + end; + + -- Detect any existing entries, and + -- then conditionally insert the row + if not WORKER_TS.is_duplicate( + r_worker.name, r_worker.birth_date, r_worker.gender_id) then + -- I'm not going to block the next two calls, + -- because it's highly unlikely that I could + -- ever get an error allocating a sequnce. + + -- Now, let's get the next id sequence. + -- no parameters, so no parentheses needed + r_worker.id := WORKER_TS.get_id; + + -- And then, let's get the next external_id sequence + -- no parameters, so no parentheses needed + r_worker.external_id := WORKER_TS.get_external_id; + + -- Now that we have all the necessary ID values + -- we can finally insert a row! + begin + -- Since I declared r_worker based on WORKER_T, I + -- can skip the column list and just use the record. + insert into WORKER_T values r_worker; + + n_count := sql%rowcount; + exception + when OTHERS then + raise_application_error(-20003, SQLERRM|| + ' on insert WORKER_T'|| + ' in filename insert_with_modularity.sql'); + end; + end if; + + pl(to_char(n_count)||' row(s) inserted.'); +end; +/ + +commit; diff --git a/Chapter05/solutions/worker_t_bulk_collect.ins b/Chapter05/solutions/worker_t_bulk_collect.ins new file mode 100644 index 0000000..980bf67 --- /dev/null +++ b/Chapter05/solutions/worker_t_bulk_collect.ins @@ -0,0 +1,125 @@ +rem worker_t_bulk_collect.ins +rem by Donald J. Bales on 12/15/2006 +rem Seed the Worker table with the top 100 names +rem 100 last x 100 first x 26 middle = 260,000 entries + +set serveroutput on size 1000000; + +declare + +-- Declare a type for a PL/SQL table of last names +TYPE last_name_table is table of TOP_100_LAST_NAME%ROWTYPE +index by binary_integer; + +-- Declare a type for a PL/SQL table of first names +TYPE first_name_table is table of TOP_100_FIRST_NAME%ROWTYPE +index by binary_integer; + +-- Declare a type for a PL/SQL table of middle initials +TYPE middle_name_table is table of A_THRU_Z%ROWTYPE +index by binary_integer; + +-- This is the number of seconds since midnight +-- I'll use it to profile my code's performance. +n_start number := + to_number(to_char(SYSDATE, 'SSSSS')); + +-- Here, I declare four psuedo-constants to hold the +-- ID values from the code tables, rather than look +-- them up repeatedly during the insert process. +n_G_FEMALE GENDER_T.id%TYPE; +n_G_MALE GENDER_T.id%TYPE; +n_WT_CONTRACTOR WORKER_TYPE_T.id%TYPE; +n_WT_EMPLOYEE WORKER_TYPE_T.id%TYPE; + +-- I'll use this to keep track of the number of +-- rows inserted. +n_inserted number := 0; + +-- Here, I declare a record anchored to the table so +-- I can set the column values and then insert using +-- the record. +r_worker WORKER_T%ROWTYPE; + +-- Declare the three PL/SQL tables that replace cursors +t_first first_name_table; +t_middle middle_name_table; +t_last last_name_table; + +begin + -- Get the ID values for the codes + n_G_FEMALE := GENDER_TS.get_id('F'); + n_G_MALE := GENDER_TS.get_id('M'); + n_WT_CONTRACTOR := WORKER_TYPE_TS.get_id('C'); + n_WT_EMPLOYEE := WORKER_TYPE_TS.get_id('E'); + + -- Bulk collect the tables into the PL/SQL tables + select * bulk collect into t_last from TOP_100_LAST_NAME; + select * bulk collect into t_first from TOP_100_FIRST_NAME; + select * bulk collect into t_middle from A_THRU_Z; + + -- Loop through the last names + for l in t_last.first..t_last.last loop + + -- While looping through the last names, + -- loop through the first names + for f in t_first.first..t_first.last loop + + -- While looping through the last and first names + -- loop through the 26 letters in the English + -- Alphabet in order to get middle initials + for m in t_middle.first..t_middle.last loop + + -- Initialize the record + + -- Get the PK using the table's package + r_worker.id := WORKER_TS.get_id(); + + -- Flip flop from contractor to employee and back again + if r_worker.worker_type_id = n_WT_CONTRACTOR then + r_worker.worker_type_id := n_WT_EMPLOYEE; + else + r_worker.worker_type_id := n_WT_CONTRACTOR; + end if; + + -- Get the External ID using the table's package + r_worker.external_id := WORKER_TS.get_external_id(); + + -- The first, middle, and last names come from the cursors + r_worker.first_name := t_first(f).first_name; + r_worker.middle_name := t_middle(m).letter||'.'; + r_worker.last_name := t_last(l).last_name; + + -- get the name using the table's package + r_worker.name := WORKER_TS.get_formatted_name( + r_worker.first_name, r_worker.middle_name, r_worker.last_name); + + -- get a random date for a birth date + r_worker.birth_date := DATES.random( + to_number(to_char(SYSDATE, 'YYYY')) - 65, + to_number(to_char(SYSDATE, 'YYYY')) - 18); + + -- selecrt the corresponding ID value + if t_first(f).gender_code = 'F' then + r_worker.gender_id := n_G_FEMALE; + else + r_worker.gender_id := n_G_MALE; + end if; + + -- Insert the row into the database + insert into WORKER_T values r_worker; + + -- keep track of the number of inserts + n_inserted := n_inserted + sql%rowcount; + end loop; -- t_middle + commit; -- commit every 26 rows + + end loop; -- t_first + + end loop; -- t_last + -- Display the results + pl(to_char(n_inserted)||' rows inserted in '|| + (to_number(to_char(SYSDATE, 'SSSSS')) - n_start)|| + ' seconds.'); +end; +/ diff --git a/Chapter05/solutions/worker_t_cursor_for_loop.ins b/Chapter05/solutions/worker_t_cursor_for_loop.ins new file mode 100644 index 0000000..05b9651 --- /dev/null +++ b/Chapter05/solutions/worker_t_cursor_for_loop.ins @@ -0,0 +1,123 @@ +rem worker_t_cursor_for_loop.ins +rem by Donald J. Bales on 12/15/2006 +rem Seed the Worker table with the top 100 names +rem 100 last x 100 first x 26 middle = 260,000 entries + +set serveroutput on size 1000000; + +declare + +-- This is the cursor for the last names. +cursor c_last is +select last_name +from TOP_100_LAST_NAME; + +-- This is the cursor for the first names. +cursor c_first is +select first_name, + gender_code +from TOP_100_FIRST_NAME; + +-- This is the cursor for the middle initials. +cursor c_middle is +select letter +from A_THRU_Z; + +-- This is the number of seconds since midnight +-- I'll use it to profile my code's performance. +n_start number := + to_number(to_char(SYSDATE, 'SSSSS')); + +-- Here, I declare four psuedo-constants to hold the +-- ID values from the code tables, rather than look +-- them up repeatedly during the insert process. +n_G_FEMALE GENDER_T.id%TYPE; +n_G_MALE GENDER_T.id%TYPE; +n_WT_CONTRACTOR WORKER_TYPE_T.id%TYPE; +n_WT_EMPLOYEE WORKER_TYPE_T.id%TYPE; + +-- I'll use this to keep track of the number of +-- rows inserted. +n_inserted number := 0; + +-- Here, I declare a record anchored to the table so +-- I can set the column values and then insert using +-- the record. +r_worker WORKER_T%ROWTYPE; + +begin + -- Get the ID values for the codes + n_G_FEMALE := GENDER_TS.get_id('F'); + n_G_MALE := GENDER_TS.get_id('M'); + n_WT_CONTRACTOR := WORKER_TYPE_TS.get_id('C'); + n_WT_EMPLOYEE := WORKER_TYPE_TS.get_id('E'); + + -- Loop through the last names + for r_last in c_last loop + + -- While looping through the last names, + -- loop through the first names + for r_first in c_first loop + + -- While looping through the last and first names + -- loop through the 26 letters in the English + -- Alphabet in order to get middle initials + -- As an alternative, I could have used a FOR LOOP: +-- for i in ascii('A')..ascii('Z') loop + for r_middle in c_middle loop + + -- Initialize the record + + -- Get the PK using the table's package + r_worker.id := WORKER_TS.get_id(); + + -- Flip flop from contractor to employee and back again + if r_worker.worker_type_id = n_WT_CONTRACTOR then + r_worker.worker_type_id := n_WT_EMPLOYEE; + else + r_worker.worker_type_id := n_WT_CONTRACTOR; + end if; + + -- Get the External ID using the table's package + r_worker.external_id := WORKER_TS.get_external_id(); + + -- The first, middle, and last names come from the cursors + r_worker.first_name := r_first.first_name; +-- r_worker.middle_name := chr(i)||'.'; + r_worker.middle_name := r_middle.letter||'.'; + r_worker.last_name := r_last.last_name; + + -- get the name using the table's package + r_worker.name := WORKER_TS.get_formatted_name( + r_worker.first_name, r_worker.middle_name, r_worker.last_name); + + -- get a random date for a birth date + r_worker.birth_date := DATES.random( + to_number(to_char(SYSDATE, 'YYYY')) - 65, + to_number(to_char(SYSDATE, 'YYYY')) - 18); + + -- selecrt the corresponding ID value + if r_first.gender_code = 'F' then + r_worker.gender_id := n_G_FEMALE; + else + r_worker.gender_id := n_G_MALE; + end if; + + -- Insert the row into the database + insert into WORKER_T values r_worker; + + -- keep track of the number of inserts + n_inserted := n_inserted + sql%rowcount; + end loop; -- c_middle +-- end loop; -- for i + commit; -- commit every 26 rows + + end loop; -- c_first + + end loop; -- c_last + -- Display the results + pl(to_char(n_inserted)||' rows inserted in '|| + (to_number(to_char(SYSDATE, 'SSSSS')) - n_start)|| + ' seconds.'); +end; +/ diff --git a/Chapter05/solutions/worker_ts.pkb b/Chapter05/solutions/worker_ts.pkb new file mode 100644 index 0000000..1688f9b --- /dev/null +++ b/Chapter05/solutions/worker_ts.pkb @@ -0,0 +1,88 @@ +create or replace PACKAGE BODY WORKER_TS as +/* +worker_ts.pkb +by Don Bales on 12/15/2006 +Table WORKER_T's methods +*/ + + +FUNCTION get_external_id +return WORKER_T.external_id%TYPE is + +v_external_id WORKER_T.external_id%TYPE; + +begin + select lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0') + into v_external_id + from SYS.DUAL; + + return v_external_id; +end get_external_id; + + +FUNCTION get_id +return WORKER_T.id%TYPE is + +n_id WORKER_T.id%TYPE; + +begin + select WORKER_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_formatted_name( +aiv_first_name in WORKER_T.first_name%TYPE, +aiv_middle_name in WORKER_T.middle_name%TYPE, +aiv_last_name in WORKER_T.last_name%TYPE) +return WORKER_T.name%TYPE is + +begin + return aiv_last_name||', '||aiv_first_name||' '||aiv_middle_name; +end get_formatted_name; + + +FUNCTION get_unformatted_name( +aiv_first_name in WORKER_T.first_name%TYPE, +aiv_middle_name in WORKER_T.middle_name%TYPE, +aiv_last_name in WORKER_T.last_name%TYPE) +return WORKER_T.name%TYPE is + +begin + return upper(replace(replace(replace(replace(replace( + aiv_last_name||aiv_first_name||aiv_middle_name, + '''', NULL), ',', NULL), '-', NULL), '.', NULL), ' ', NULL)); +end get_unformatted_name; + + +FUNCTION is_duplicate( +aiv_name in WORKER_T.name%TYPE, +aid_birth_date in WORKER_T.birth_date%TYPE, +ain_gender_id in WORKER_T.gender_id%TYPE) +return boolean is + +n_selected number; + +begin + select count(1) + into n_selected + from WORKER_T + where name = aiv_name + and birth_date = aid_birth_date + and gender_id = ain_gender_id; + + if nvl(n_selected, 0) > 0 then + return TRUE; + else + return FALSE; + end if; +end is_duplicate; + + +end WORKER_TS; +/ +@be.sql WORKER_TS + diff --git a/Chapter05/solutions/worker_ts.pks b/Chapter05/solutions/worker_ts.pks new file mode 100644 index 0000000..63a8a6e --- /dev/null +++ b/Chapter05/solutions/worker_ts.pks @@ -0,0 +1,41 @@ +create or replace PACKAGE WORKER_TS as +/* +worker_ts.pks +by Don Bales on 12/15/2006 +Table WORKER_T's methods +*/ + + +FUNCTION get_external_id +return WORKER_T.external_id%TYPE; + + +FUNCTION get_id +return WORKER_T.id%TYPE; + + +FUNCTION get_formatted_name( +aiv_first_name in WORKER_T.first_name%TYPE, +aiv_middle_name in WORKER_T.middle_name%TYPE, +aiv_last_name in WORKER_T.last_name%TYPE) +return WORKER_T.name%TYPE; + + +FUNCTION get_unformatted_name( +aiv_first_name in WORKER_T.first_name%TYPE, +aiv_middle_name in WORKER_T.middle_name%TYPE, +aiv_last_name in WORKER_T.last_name%TYPE) +return WORKER_T.name%TYPE; + + +FUNCTION is_duplicate( +aiv_name in WORKER_T.name%TYPE, +aid_birth_date in WORKER_T.birth_date%TYPE, +ain_gender_id in WORKER_T.gender_id%TYPE) +return boolean; + + +end WORKER_TS; +/ +@se.sql WORKER_TS + diff --git a/Chapter05/sqlnet.log b/Chapter05/sqlnet.log new file mode 100644 index 0000000..c583c2b --- /dev/null +++ b/Chapter05/sqlnet.log @@ -0,0 +1,36 @@ + + +*********************************************************************** +Fatal NI connect error 12514, connecting to: + (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xp1.donaldbales.com)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ora1020)(CID=(PROGRAM=C:\oracle\product\10.2.0\db_1\BIN\sqlplusw.exe)(HOST=XP1)(USER=balesd)))) + + VERSION INFORMATION: + TNS for 32-bit Windows: Version 10.2.0.1.0 - Production + Windows NT TCP/IP NT Protocol Adapter for 32-bit Windows: Version 10.2.0.1.0 - Production + Time: 07-JUN-2007 22:08:22 + Tracing not turned on. + Tns error struct: + ns main err code: 12564 + TNS-12564: TNS:connection refused + ns secondary err code: 0 + nt main err code: 0 + nt secondary err code: 0 + nt OS err code: 0 + + +*********************************************************************** +Fatal NI connect error 12514, connecting to: + (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xp1.donaldbales.com)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ora1020)(CID=(PROGRAM=C:\oracle\product\10.2.0\db_1\BIN\sqlplusw.exe)(HOST=XP1)(USER=balesd)))) + + VERSION INFORMATION: + TNS for 32-bit Windows: Version 10.2.0.1.0 - Production + Windows NT TCP/IP NT Protocol Adapter for 32-bit Windows: Version 10.2.0.1.0 - Production + Time: 07-JUN-2007 22:08:51 + Tracing not turned on. + Tns error struct: + ns main err code: 12564 + TNS-12564: TNS:connection refused + ns secondary err code: 0 + nt main err code: 0 + nt secondary err code: 0 + nt OS err code: 0 diff --git a/Chapter05/top_100_first_name.ins b/Chapter05/top_100_first_name.ins new file mode 100644 index 0000000..6490fb6 --- /dev/null +++ b/Chapter05/top_100_first_name.ins @@ -0,0 +1,108 @@ +rem top_100_first_name.ins +rem by Don Bales on 12/15/2006 +rem Top 100 first names from www.namestatistics.com + +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ALICE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('AMANDA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('AMY', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANDREW', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANGELA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANN', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANNA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ANTHONY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('BARBARA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('BETTY', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('BRENDA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('BRIAN', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CARL', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CAROL', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CAROLYN', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CATHERINE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CHARLES', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CHRISTINE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CHRISTOPHER', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('CYNTHIA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DANIEL', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DAVID', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DEBORAH', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DEBRA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DENNIS', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DIANE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DONALD', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DONNA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DOROTHY', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('DOUGLAS', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('EDWARD', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ELIZABETH', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ERIC', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('FRANCES', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('FRANK', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('GARY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('GEORGE', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('GREGORY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('HAROLD', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('HEATHER', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('HELEN', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('HENRY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JAMES', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JANET', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JASON', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JEFFREY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JENNIFER', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JERRY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JESSICA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOHN', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOSE', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOSEPH', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOSHUA', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JOYCE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('JULIE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KAREN', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KATHLEEN', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KENNETH', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KEVIN', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('KIMBERLY', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('LARRY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('LAURA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('LINDA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('LISA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARGARET', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARIA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARIE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARK', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARTHA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MARY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MATTHEW', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MELISSA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MICHAEL', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('MICHELLE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('NANCY', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PAMELA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PATRICIA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PATRICK', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PAUL', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('PETER', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('RAYMOND', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('REBECCA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('RICHARD', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('ROBERT', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('RONALD', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('RUTH', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SANDRA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SARAH', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SCOTT', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SHARON', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SHIRLEY', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('STEPHANIE', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('STEPHEN', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('STEVEN', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('SUSAN', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('THOMAS', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('TIMOTHY', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('VIRGINIA', 'F'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('WALTER', 'M'); +insert into TOP_100_FIRST_NAME (first_name, gender_code) values ('WILLIAM', 'M'); + +commit; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'TOP_100_FIRST_NAME'); diff --git a/Chapter05/top_100_first_name.tab b/Chapter05/top_100_first_name.tab new file mode 100644 index 0000000..4b69869 --- /dev/null +++ b/Chapter05/top_100_first_name.tab @@ -0,0 +1,17 @@ +rem top_100_first_name.tab +rem by Donald J. Bales on 12/15/2006 +rem Top 100 first names from www.namestatistics.com + +execute drop_if_exists('table','TOP_100_FIRST_NAME'); +create table TOP_100_FIRST_NAME ( +first_name varchar2(30) not null, +gender_code varchar2(1) not null); + +alter table TOP_100_FIRST_NAME add +constraint TOP_100_FIRST_NAME_PK +primary key ( +first_name, +gender_code ) +using index; + +@top_100_first_name.ins diff --git a/Chapter05/top_100_last_name.ins b/Chapter05/top_100_last_name.ins new file mode 100644 index 0000000..958bad9 --- /dev/null +++ b/Chapter05/top_100_last_name.ins @@ -0,0 +1,108 @@ +rem top_100_last_name.ins +rem by Don Bales on 12/15/2006 +rem Top 100 last names from www.namestatistics.com + +insert into TOP_100_LAST_NAME (last_name) values ('ADAMS'); +insert into TOP_100_LAST_NAME (last_name) values ('ALEXANDER'); +insert into TOP_100_LAST_NAME (last_name) values ('ALLEN'); +insert into TOP_100_LAST_NAME (last_name) values ('ANDERSON'); +insert into TOP_100_LAST_NAME (last_name) values ('BAILEY'); +insert into TOP_100_LAST_NAME (last_name) values ('BAKER'); +insert into TOP_100_LAST_NAME (last_name) values ('BARNES'); +insert into TOP_100_LAST_NAME (last_name) values ('BELL'); +insert into TOP_100_LAST_NAME (last_name) values ('BENNETT'); +insert into TOP_100_LAST_NAME (last_name) values ('BROOKS'); +insert into TOP_100_LAST_NAME (last_name) values ('BROWN'); +insert into TOP_100_LAST_NAME (last_name) values ('BRYANT'); +insert into TOP_100_LAST_NAME (last_name) values ('BUTLER'); +insert into TOP_100_LAST_NAME (last_name) values ('CAMPBELL'); +insert into TOP_100_LAST_NAME (last_name) values ('CARTER'); +insert into TOP_100_LAST_NAME (last_name) values ('CLARK'); +insert into TOP_100_LAST_NAME (last_name) values ('COLEMAN'); +insert into TOP_100_LAST_NAME (last_name) values ('COLLINS'); +insert into TOP_100_LAST_NAME (last_name) values ('COOK'); +insert into TOP_100_LAST_NAME (last_name) values ('COOPER'); +insert into TOP_100_LAST_NAME (last_name) values ('COX'); +insert into TOP_100_LAST_NAME (last_name) values ('DAVIS'); +insert into TOP_100_LAST_NAME (last_name) values ('DIAZ'); +insert into TOP_100_LAST_NAME (last_name) values ('EDWARDS'); +insert into TOP_100_LAST_NAME (last_name) values ('EVANS'); +insert into TOP_100_LAST_NAME (last_name) values ('FLORES'); +insert into TOP_100_LAST_NAME (last_name) values ('FOSTER'); +insert into TOP_100_LAST_NAME (last_name) values ('GARCIA'); +insert into TOP_100_LAST_NAME (last_name) values ('GONZALES'); +insert into TOP_100_LAST_NAME (last_name) values ('GONZALEZ'); +insert into TOP_100_LAST_NAME (last_name) values ('GRAY'); +insert into TOP_100_LAST_NAME (last_name) values ('GREEN'); +insert into TOP_100_LAST_NAME (last_name) values ('GRIFFIN'); +insert into TOP_100_LAST_NAME (last_name) values ('HALL'); +insert into TOP_100_LAST_NAME (last_name) values ('HARRIS'); +insert into TOP_100_LAST_NAME (last_name) values ('HAYES'); +insert into TOP_100_LAST_NAME (last_name) values ('HENDERSON'); +insert into TOP_100_LAST_NAME (last_name) values ('HERNANDEZ'); +insert into TOP_100_LAST_NAME (last_name) values ('HILL'); +insert into TOP_100_LAST_NAME (last_name) values ('HOWARD'); +insert into TOP_100_LAST_NAME (last_name) values ('HUGHES'); +insert into TOP_100_LAST_NAME (last_name) values ('JACKSON'); +insert into TOP_100_LAST_NAME (last_name) values ('JAMES'); +insert into TOP_100_LAST_NAME (last_name) values ('JENKINS'); +insert into TOP_100_LAST_NAME (last_name) values ('JOHNSON'); +insert into TOP_100_LAST_NAME (last_name) values ('JONES'); +insert into TOP_100_LAST_NAME (last_name) values ('KELLY'); +insert into TOP_100_LAST_NAME (last_name) values ('KING'); +insert into TOP_100_LAST_NAME (last_name) values ('LEE'); +insert into TOP_100_LAST_NAME (last_name) values ('LEWIS'); +insert into TOP_100_LAST_NAME (last_name) values ('LONG'); +insert into TOP_100_LAST_NAME (last_name) values ('LOPEZ'); +insert into TOP_100_LAST_NAME (last_name) values ('MARTIN'); +insert into TOP_100_LAST_NAME (last_name) values ('MARTINEZ'); +insert into TOP_100_LAST_NAME (last_name) values ('MILLER'); +insert into TOP_100_LAST_NAME (last_name) values ('MITCHELL'); +insert into TOP_100_LAST_NAME (last_name) values ('MOORE'); +insert into TOP_100_LAST_NAME (last_name) values ('MORGAN'); +insert into TOP_100_LAST_NAME (last_name) values ('MORRIS'); +insert into TOP_100_LAST_NAME (last_name) values ('MURPHY'); +insert into TOP_100_LAST_NAME (last_name) values ('NELSON'); +insert into TOP_100_LAST_NAME (last_name) values ('PARKER'); +insert into TOP_100_LAST_NAME (last_name) values ('PATTERSON'); +insert into TOP_100_LAST_NAME (last_name) values ('PEREZ'); +insert into TOP_100_LAST_NAME (last_name) values ('PERRY'); +insert into TOP_100_LAST_NAME (last_name) values ('PETERSON'); +insert into TOP_100_LAST_NAME (last_name) values ('PHILLIPS'); +insert into TOP_100_LAST_NAME (last_name) values ('POWELL'); +insert into TOP_100_LAST_NAME (last_name) values ('PRICE'); +insert into TOP_100_LAST_NAME (last_name) values ('RAMIREZ'); +insert into TOP_100_LAST_NAME (last_name) values ('REED'); +insert into TOP_100_LAST_NAME (last_name) values ('RICHARDSON'); +insert into TOP_100_LAST_NAME (last_name) values ('RIVERA'); +insert into TOP_100_LAST_NAME (last_name) values ('ROBERTS'); +insert into TOP_100_LAST_NAME (last_name) values ('ROBINSON'); +insert into TOP_100_LAST_NAME (last_name) values ('RODRIGUEZ'); +insert into TOP_100_LAST_NAME (last_name) values ('ROGERS'); +insert into TOP_100_LAST_NAME (last_name) values ('ROSS'); +insert into TOP_100_LAST_NAME (last_name) values ('RUSSELL'); +insert into TOP_100_LAST_NAME (last_name) values ('SANCHEZ'); +insert into TOP_100_LAST_NAME (last_name) values ('SANDERS'); +insert into TOP_100_LAST_NAME (last_name) values ('SCOTT'); +insert into TOP_100_LAST_NAME (last_name) values ('SIMMONS'); +insert into TOP_100_LAST_NAME (last_name) values ('SMITH'); +insert into TOP_100_LAST_NAME (last_name) values ('STEWART'); +insert into TOP_100_LAST_NAME (last_name) values ('TAYLOR'); +insert into TOP_100_LAST_NAME (last_name) values ('THOMAS'); +insert into TOP_100_LAST_NAME (last_name) values ('THOMPSON'); +insert into TOP_100_LAST_NAME (last_name) values ('TORRES'); +insert into TOP_100_LAST_NAME (last_name) values ('TURNER'); +insert into TOP_100_LAST_NAME (last_name) values ('WALKER'); +insert into TOP_100_LAST_NAME (last_name) values ('WARD'); +insert into TOP_100_LAST_NAME (last_name) values ('WASHINGTON'); +insert into TOP_100_LAST_NAME (last_name) values ('WATSON'); +insert into TOP_100_LAST_NAME (last_name) values ('WHITE'); +insert into TOP_100_LAST_NAME (last_name) values ('WILLIAMS'); +insert into TOP_100_LAST_NAME (last_name) values ('WILSON'); +insert into TOP_100_LAST_NAME (last_name) values ('WOOD'); +insert into TOP_100_LAST_NAME (last_name) values ('WRIGHT'); +insert into TOP_100_LAST_NAME (last_name) values ('YOUNG'); + +commit; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'TOP_100_LAST_NAME'); diff --git a/Chapter05/top_100_last_name.tab b/Chapter05/top_100_last_name.tab new file mode 100644 index 0000000..9f92125 --- /dev/null +++ b/Chapter05/top_100_last_name.tab @@ -0,0 +1,15 @@ +rem top_100_last_name.tab +rem by Donald J. Bales on 12/15/2006 +rem Top 100 last names from www.namestatistics.com + +execute drop_if_exists('table','TOP_100_LAST_NAME'); +create table TOP_100_LAST_NAME ( +last_name varchar2(30)); + +alter table TOP_100_LAST_NAME add +constraint TOP_100_LAST_NAME_PK +primary key ( +last_name) +using index; + +@top_100_last_name.ins diff --git a/Chapter05/worker_t.ins b/Chapter05/worker_t.ins new file mode 100644 index 0000000..023ec8b --- /dev/null +++ b/Chapter05/worker_t.ins @@ -0,0 +1,70 @@ +rem worker_t.ins +rem by Donald J. Bales on 12/15/2006 +rem Seed the Worker table with the top 100 names +rem 100 last x 100 first x 26 middle = 260,000 entries + +set serveroutput on size 1000000; + +declare + +-- This is the number of seconds since midnight +-- I'll use it to profile my code's performance. +n_start number := + to_number(to_char(SYSDATE, 'SSSSS')); + +-- Here, I declare four psuedo-constants to hold the +-- ID values from the code tables, rather than look +-- them up repeatedly during the insert process. +n_G_FEMALE GENDER_T.id%TYPE; +n_G_MALE GENDER_T.id%TYPE; +n_WT_CONTRACTOR WORKER_TYPE_T.id%TYPE; +n_WT_EMPLOYEE WORKER_TYPE_T.id%TYPE; + +-- I'll use this to keep track of the number of +-- rows inserted. +n_inserted number := 0; + +begin + -- Get the ID values for the codes + n_G_FEMALE := GENDER_TS.get_id('F'); + n_G_MALE := GENDER_TS.get_id('M'); + n_WT_CONTRACTOR := WORKER_TYPE_TS.get_id('C'); + n_WT_EMPLOYEE := WORKER_TYPE_TS.get_id('E'); + + -- Use an INSERT INTO SELECT SQL statement + insert into WORKER_T ( + id, + worker_type_id, + external_id, + first_name, + middle_name, + last_name, + name, + birth_date, + gender_id) + select WORKER_ID_SEQ.nextval, + decode(mod(WORKER_ID_SEQ.currval, 2), + 0, n_WT_EMPLOYEE, n_WT_CONTRACTOR), + lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0'), + first_name, + letter||'.', + last_name, + WORKER_TS.get_formatted_name( + first_name, letter||'.', last_name), + DATES.random( + to_number(to_char(SYSDATE, 'YYYY')) - 65, + to_number(to_char(SYSDATE, 'YYYY')) - 18), + decode(gender_code, 'F', n_G_FEMALE, n_G_MALE) + from TOP_100_LAST_NAME, + TOP_100_FIRST_NAME, + A_THRU_Z; + + n_inserted := n_inserted + sql%rowcount; + + commit; + + pl(to_char(n_inserted)||' rows inserted in '|| + (to_number(to_char(SYSDATE, 'SSSSS')) - n_start)|| + ' seconds.'); +end; +/ diff --git a/Chapter05/worker_t_forall.ins b/Chapter05/worker_t_forall.ins new file mode 100644 index 0000000..41989eb --- /dev/null +++ b/Chapter05/worker_t_forall.ins @@ -0,0 +1,129 @@ +rem worker_t_forall.ins +rem by Donald J. Bales on 12/15/2006 +rem Seed the Worker table with the top 100 names +rem 100 last x 100 first x 26 middle = 260,000 entries + +set serveroutput on size 1000000; + +declare + +-- Declare a type for a PL/SQL table of last names +TYPE last_name_table is table of TOP_100_LAST_NAME%ROWTYPE +index by binary_integer; + +-- Declare a type for a PL/SQL table of first names +TYPE first_name_table is table of TOP_100_FIRST_NAME%ROWTYPE +index by binary_integer; + +-- Declare a type for a PL/SQL table of middle initials +TYPE middle_name_table is table of A_THRU_Z%ROWTYPE +index by binary_integer; + +-- Declare a type for a PL/SQL table of workers +TYPE worker_table is table of WORKER_T%ROWTYPE +index by binary_integer; + +-- This is the number of seconds since midnight +-- I'll use it to profile my code's performance. +n_start number := + to_number(to_char(SYSDATE, 'SSSSS')); + +-- Here, I declare four psuedo-constants to hold the +-- ID values from the code tables, rather than look +-- them up repeatedly during the insert process. +n_G_FEMALE GENDER_T.id%TYPE; +n_G_MALE GENDER_T.id%TYPE; +n_WT_CONTRACTOR WORKER_TYPE_T.id%TYPE; +n_WT_EMPLOYEE WORKER_TYPE_T.id%TYPE; + +-- I'll use this to keep track of the number of +-- rows inserted. +n_inserted number := 0; + +-- Declare the four PL/SQL tables that replace cursors +-- and the worker record +t_first first_name_table; +t_middle middle_name_table; +t_last last_name_table; +t_worker worker_table; + +begin + -- Get the ID values for the codes + n_G_FEMALE := GENDER_TS.get_id('F'); + n_G_MALE := GENDER_TS.get_id('M'); + n_WT_CONTRACTOR := WORKER_TYPE_TS.get_id('C'); + n_WT_EMPLOYEE := WORKER_TYPE_TS.get_id('E'); + + -- Bulk collect the tables into the PL/SQL tables + select * bulk collect into t_last from TOP_100_LAST_NAME; + select * bulk collect into t_first from TOP_100_FIRST_NAME; + select * bulk collect into t_middle from A_THRU_Z; + + -- Loop through the last names + for l in t_last.first..t_last.last loop + + -- While looping through the last names, + -- loop through the first names + for f in t_first.first..t_first.last loop + + -- While looping through the last and first names + -- loop through the 26 letters in the English + -- Alphabet in order to get middle initials + for m in t_middle.first..t_middle.last loop + + -- Initialize the table's rows + + -- Get the PK using the table's package + t_worker(m).id := WORKER_TS.get_id(); + + -- Flip flop from contractor to employee and back again + if t_worker(m).worker_type_id = n_WT_CONTRACTOR then + t_worker(m).worker_type_id := n_WT_EMPLOYEE; + else + t_worker(m).worker_type_id := n_WT_CONTRACTOR; + end if; + + -- Get the External ID using the table's package + t_worker(m).external_id := WORKER_TS.get_external_id(); + + -- The first, middle, and last names come from the cursors + t_worker(m).first_name := t_first(f).first_name; + t_worker(m).middle_name := t_middle(m).letter||'.'; + t_worker(m).last_name := t_last(l).last_name; + + -- get the name using the table's package + t_worker(m).name := WORKER_TS.get_formatted_name( + t_worker(m).first_name, + t_worker(m).middle_name, + t_worker(m).last_name); + + -- get a random date for a birth date + t_worker(m).birth_date := DATES.random( + to_number(to_char(SYSDATE, 'YYYY')) - 65, + to_number(to_char(SYSDATE, 'YYYY')) - 18); + + -- selecrt the corresponding ID value + if t_first(f).gender_code = 'F' then + t_worker(m).gender_id := n_G_FEMALE; + else + t_worker(m).gender_id := n_G_MALE; + end if; + + end loop; -- t_middle + + -- Now bulk bind the 26 insert statements + forall i in t_worker.first..t_worker.last + insert into WORKER_T values t_worker(i); + + n_inserted := n_inserted + sql%rowcount; + + end loop; -- t_first + + end loop; -- t_last + commit; + -- Display the results + pl(to_char(n_inserted)||' rows inserted in '|| + (to_number(to_char(SYSDATE, 'SSSSS')) - n_start)|| + ' seconds.'); +end; +/ diff --git a/Chapter05/worker_ts.pkb b/Chapter05/worker_ts.pkb new file mode 100644 index 0000000..01538cc --- /dev/null +++ b/Chapter05/worker_ts.pkb @@ -0,0 +1,27 @@ +create or replace PACKAGE BODY WORKER_TS as +/* +worker_ts.pkb +by Don Bales on 12/15/2006 +Table WORKER_T's methods +*/ + + +-- FUNCTIONS + +FUNCTION get_id +return WORKER_T.id%TYPE is + +n_id WORKER_T.id%TYPE; + +begin + select WORKER_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +end WORKER_TS; +/ +@be.sql WORKER_TS diff --git a/Chapter05/worker_ts.pks b/Chapter05/worker_ts.pks new file mode 100644 index 0000000..236e71e --- /dev/null +++ b/Chapter05/worker_ts.pks @@ -0,0 +1,18 @@ +create or replace PACKAGE WORKER_TS as +/* +worker_ts.pks +by Don Bales on 12/15/2006 +Table WORKER_T's methods. +*/ + + +-- Return the next ID sequence value + +FUNCTION get_id +return WORKER_T.id%TYPE; + + +end WORKER_TS; +/ +@se.sql WORKER_TS + diff --git a/Chapter05/worker_type_ts.pkb b/Chapter05/worker_type_ts.pkb new file mode 100644 index 0000000..6844df6 --- /dev/null +++ b/Chapter05/worker_type_ts.pkb @@ -0,0 +1,30 @@ +create or replace PACKAGE BODY WORKER_TYPE_TS as +/* +worker_type_ts.pkb +by Don Bales on 12/15/2006 +Table WORKER_TYPE_T's methods +*/ + + +-- FUNCTIONS + +FUNCTION get_id( +aiv_code in WORKER_TYPE_T.code%TYPE ) +return WORKER_TYPE_T.id%TYPE is + +n_id WORKER_TYPE_T.id%TYPE; + +begin + select id + into n_id + from WORKER_TYPE_T + where code = aiv_code; + + return n_id; +end get_id; + + +end WORKER_TYPE_TS; +/ +@be.sql WORKER_TYPE_TS + diff --git a/Chapter05/worker_type_ts.pks b/Chapter05/worker_type_ts.pks new file mode 100644 index 0000000..31cf479 --- /dev/null +++ b/Chapter05/worker_type_ts.pks @@ -0,0 +1,19 @@ +create or replace PACKAGE WORKER_TYPE_TS as +/* +worker_type_ts.pks +by Don Bales on 12/15/2006 +Code Table WORKER_TYPE_T's methods. +*/ + + +-- Returns the id for the specified code value. + +FUNCTION get_id( +aiv_code in WORKER_TYPE_T.code%TYPE ) +return WORKER_TYPE_T.id%TYPE; + + +end WORKER_TYPE_TS; +/ +@se.sql WORKER_TYPE_TS + diff --git a/Chapter06/README.txt b/Chapter06/README.txt new file mode 100644 index 0000000..a958506 --- /dev/null +++ b/Chapter06/README.txt @@ -0,0 +1,81 @@ +README.txt for Chapter 6 +by Donald J. Bales on 4/15/2007 + +OBJECT NAME DESCRIPTION +--------------------------------------- ------------------------------------- +be.sql Show package body compilation errors + +ci.sql Compile invalid objects + +desc.sql Describe an object + +fe.sql Show function compilation errors + +gender_o.tpb Create TYPE GENDER_O's body + +gender_o.tps Create TYPE GENDER_O's specification + +gender_ot.ins Add code value entries to GENDER_OT + +gender_ot.tab Create object table GENDER_OT + +gender_ov.sql Test units for object view GENDER_OV + +gender_ov.vw Create object view GENDER_OV + +gender_ts.pkb Create table package GENDER_TS' body + +gender_ts.pks Create table package GENDER_TS' + specification + +login.sql Set my SQL*Plus defaults + +pe.sql Show procedure compilation errors + +pl.sql Don's handy-dandy "put_line" + procedure + +se.sql Show package specification + compilation errors + +solutions\worker_o.sql Test units for TYPE WORKER_O + +solutions\worker_o.tpb Create TYPE WORKER_O's body + +solutions\worker_o.tps Create TYPE WORKER_O's specification + +solutions\worker_ot.ins Populate object table WORKER_OT + +solutions\worker_ot.tab Create object table WORKER_OT + +worker_ts.pkb Create table package WORKER_TS' body + +worker_ts.pks Create table package WORKER_TS' + specification + +solutions\worker_type_o.sql Test units for TYPE WORKER_TYPE_O + +solutions\worker_type_o.tpb Create TYPE WORKER_TYPE_O's body + +solutions\worker_type_o.tps Create TYPE WORKER_TYPE_O's + specification + +solutions\worker_type_ot.ins Add code value entries to + WORKER_TYPE_OT + +solutions\worker_type_ot.sql Test units for object table + WORKER_TYPE_OT + +solutions\worker_type_ot.tab Create object table WORKER_TYPE_OT + +solutions\worker_type_ov.sql Test units for object view + WORKER_TYPE_OV + +solutions\worker_type_ov.vw Create object view WORKER_TYPE_OV + +worker_type_ts.pkb Create table package WORKER_TYPE_TS' + body + +worker_type_ts.pks Create table package WORKER_TYPE_TS' + specification + \ No newline at end of file diff --git a/Chapter06/be.sql b/Chapter06/be.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter06/be.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter06/ci.sql b/Chapter06/ci.sql new file mode 100644 index 0000000..6dcc7e7 --- /dev/null +++ b/Chapter06/ci.sql @@ -0,0 +1,50 @@ +rem ci.sql +rem by Donald J. Bales on 12/15/2006 +rem Compile my invalid objects + +set feedback off; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +set serveroutput on size 1000000; + +spool ci.txt; +declare + +cursor c1 is +select object_type, + object_name +from SYS.USER_OBJECTS +where status = 'INVALID' +order by 1, 2; + +v_sql varchar2(100); + +begin + for r1 in c1 loop + begin + if r1.object_type = 'PACKAGE BODY' then + v_sql := 'alter PACKAGE '||r1.object_name||' compile BODY'; + elsif r1.object_type = 'TYPE BODY' then + v_sql := 'alter TYPE '||r1.object_name||' compile BODY'; + else + v_sql := 'alter '||r1.object_type||' '||r1.object_name||' compile'; + end if; + execute immediate v_sql; + pl(r1.object_type||' '||r1.object_name||' compiled successfully'); + exception + when OTHERS then + pl(SQLERRM||' on '||v_sql); + end; + end loop; +end; +/ + +spool off; + +set feedback on; + + + + \ No newline at end of file diff --git a/Chapter06/ci.txt b/Chapter06/ci.txt new file mode 100644 index 0000000..e69de29 diff --git a/Chapter06/compile_all.sql b/Chapter06/compile_all.sql new file mode 100644 index 0000000..a76b4bb --- /dev/null +++ b/Chapter06/compile_all.sql @@ -0,0 +1,30 @@ +set echo on; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +spool compile_all.txt; +@gender_o.tps +@gender_ov.vw +@gender_ot.tab +@gender_o.tpb +@gender_ot.ins +@gender_ts.pks +@worker_type_ts.pks +@worker_ts.pks +@gender_ts.pkb +@worker_type_ts.pkb +@worker_ts.pkb +@.\solutions\worker_type_o.tps +@.\solutions\worker_type_ov.vw +@.\solutions\worker_type_ot.tab +@.\solutions\worker_type_o.tpb +@.\solutions\worker_type_ot.ins +@.\solutions\worker_o.tps +@.\solutions\worker_ot.tab +@.\solutions\worker_o.tpb +@.\solutions\worker_ot.ins +spool off; +set echo off; +@ci.sql +@ci.sql diff --git a/Chapter06/desc.sql b/Chapter06/desc.sql new file mode 100644 index 0000000..45206dc --- /dev/null +++ b/Chapter06/desc.sql @@ -0,0 +1,6 @@ +define table_name="&1"; +set linesize 78; +prompt &table_name +desc &table_name +set linesize 1000; +undefine table_name \ No newline at end of file diff --git a/Chapter06/fe.sql b/Chapter06/fe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter06/fe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter06/gender_o.tpb b/Chapter06/gender_o.tpb new file mode 100644 index 0000000..54c99f6 --- /dev/null +++ b/Chapter06/gender_o.tpb @@ -0,0 +1,152 @@ +create or replace TYPE BODY gender_o as +/* +gender_o.tpb +by Don Bales on 12/15/2006 +Type GENDER_O's attributes and methods +*/ + +CONSTRUCTOR FUNCTION gender_o( +self in out gender_o) +return self as result is + +begin + id := NULL; + code := NULL; + description := NULL; + active_date := NULL; + inactive_date := NULL; + return; +end gender_o; + + +CONSTRUCTOR FUNCTION gender_o( +self in out gender_o, +aiv_code varchar2, +aiv_description varchar2) +return self as result is + +begin + id := get_id(); + code := aiv_code; + description := aiv_description; + active_date := SYSDATE; + inactive_date := NULL; + return; +end gender_o; + + +STATIC PROCEDURE get_code_descr( +ain_id in number, +aov_code out varchar2, +aov_description out varchar2 ) is + +begin + select code, + description + into aov_code, + aov_description + from GENDER_OT + where id = ain_id; +end get_code_descr; + + +STATIC PROCEDURE get_code_id_descr( +aiov_code in out varchar2, +aon_id out number, +aov_description out varchar2, +aid_on in date ) is + +v_code varchar2(30); + +begin + select id, + description + into aon_id, + aov_description + from GENDER_OT + where code = aiov_code + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); +exception + when NO_DATA_FOUND then + select id, + code, + description + into aon_id, + v_code, + aov_description + from GENDER_OT + where code like aiov_code||'%' + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); + aiov_code := v_code; +end get_code_id_descr; + + +STATIC PROCEDURE get_code_id_descr( +aiov_code in out varchar2, +aon_id out number, +aov_description out varchar2 ) is + +begin + get_code_id_descr( + aiov_code, + aon_id, + aov_description, + SYSDATE ); +end get_code_id_descr; + + +MEMBER FUNCTION get_id +return number is + +n_id number; + +begin + select GENDER_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +STATIC FUNCTION get_id( +aiv_code in varchar2 ) +return number is + +n_id number; + +begin + select id + into n_id + from GENDER_OT + where code = aiv_code; + + return n_id; +end get_id; + + +STATIC PROCEDURE help is + +begin + pl('No help at this time.'); +end help; + + +STATIC PROCEDURE test is + +begin + pl('No tests coded at this time'); +end test; + + +MAP MEMBER FUNCTION to_varchar2 +return varchar2 is + +begin + return description||to_char(active_date, 'YYYYMMDDHH24MISS'); +end to_varchar2; + + +end; +/ +@be.sql GENDER_O diff --git a/Chapter06/gender_o.tps b/Chapter06/gender_o.tps new file mode 100644 index 0000000..f075864 --- /dev/null +++ b/Chapter06/gender_o.tps @@ -0,0 +1,79 @@ +execute drop_if_exists('table','GENDER_OT'); +execute drop_if_exists('view','GENDER_OV'); +execute drop_if_exists('type','GENDER_O'); +create TYPE GENDER_O as object ( +/* +gender_o.tps +by Don Bales on 12/15/2006 +Type GENDER's attributes and methods. +*/ +id number, +code varchar2(30), +description varchar2(80), +active_date date, +inactive_date date, +/* +A constructor for creating a new instance of type GENDER_O with NULL +values. +*/ +CONSTRUCTOR FUNCTION gender_o( +self in out gender_o) +return self as result, +/* +A constructor for creating a new instance of type GENDER_O for insert. +*/ +CONSTRUCTOR FUNCTION gender_o( +self in out gender_o, +aiv_code varchar2, +aiv_description varchar2) +return self as result, +/* +Gets the code and decription values for the specified id. +*/ +STATIC PROCEDURE get_code_descr( +ain_id in number, +aov_code out varchar2, +aov_description out varchar2), +/* +Verifies that the passed code value is an exact or like match on the +date specified. +*/ +STATIC PROCEDURE get_code_id_descr( +aiov_code in out varchar2, +aon_id out number, +aov_description out varchar2, +aid_on in date), +/* +Verifies that the passed code value is currently an exact or like match. +*/ +STATIC PROCEDURE get_code_id_descr( +aiov_code in out varchar2, +aon_id out number, +aov_description out varchar2), +/* +Returns a new primary key id value for a row. +*/ +MEMBER FUNCTION get_id +return number, +/* +Returns the id for the specified code value. +*/ +STATIC FUNCTION get_id( +aiv_code in varchar2) +return number, +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +STATIC PROCEDURE help, +/* +Test units for this package. +*/ +STATIC PROCEDURE test, +/* +A MAP function for sorting at the object level. +*/ +MAP MEMBER FUNCTION to_varchar2 +return varchar2 +); +/ +@se.sql GENDER_O diff --git a/Chapter06/gender_ot.ins b/Chapter06/gender_ot.ins new file mode 100644 index 0000000..ebbc3a3 --- /dev/null +++ b/Chapter06/gender_ot.ins @@ -0,0 +1,10 @@ +rem gender_ot.ins +rem copyright by Donald J. Bales on 12/15/2006 +rem + +insert into GENDER_OT values ( gender_o( 'F', 'Female' ) ); +insert into GENDER_OT values ( gender_o( 'M', 'Male' ) ); +insert into GENDER_OT values ( gender_o( 'U', 'Unknown' ) ); +commit; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'GENDER_OT'); diff --git a/Chapter06/gender_ot.tab b/Chapter06/gender_ot.tab new file mode 100644 index 0000000..14fe261 --- /dev/null +++ b/Chapter06/gender_ot.tab @@ -0,0 +1,28 @@ +rem gender_ot.tab +rem by Donald J. Bales on 12/15/2006 +rem Create an object table for the Gender codes + +--drop table GENDER_OT; +create table GENDER_OT of GENDER_O +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence GENDER_ID_SEQ; +--create sequence GENDER_ID_SEQ +--start with 1; + +alter table GENDER_OT add +constraint GENDER_OT_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table GENDER_OT add +constraint GENDER_OT_UK +unique ( code ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'GENDER_OT'); diff --git a/Chapter06/gender_ov.sql b/Chapter06/gender_ov.sql new file mode 100644 index 0000000..cc1833a --- /dev/null +++ b/Chapter06/gender_ov.sql @@ -0,0 +1,65 @@ +rem gender_ov.sql +rem by Donald J. Bales on 12/15/2006 +rem test unit for object view GENDER_OV + +declare +-- Declare a variable of the user-define type +o_gender GENDER_O; +-- Declare a variable for t6he under-lying table +r_gender GENDER_T%ROWTYPE; + +begin + -- Insert a test object using the convenience constructor + insert into GENDER_OV + values ( GENDER_O( 'T', 'Test') ); + + -- Now update the inactive date on the object + update GENDER_OV + set inactive_date = SYSDATE + where code = 'T'; + + -- Retrieve the object in order to show its values + select value(g) + into o_gender + from GENDER_OV g + where code = 'T'; + + -- Show the object's values + pl('o_gender.id = '||o_gender.id); + pl('o_gender.code = '||o_gender.code); + pl('o_gender.description = '||o_gender.description); + pl('o_gender.active_date = '||o_gender.active_date); + pl('o_gender.inactive_date = '||o_gender.inactive_date); + + -- Delete the test object + delete GENDER_OV + where code = 'T'; + + -- This time insert the test object using the instance variable + insert into GENDER_OV + values ( o_gender ); + + -- Now, select the values from the under-lying relational table + select * + into r_gender + from GENDER_T + where code = 'T'; + + -- Show the record's values + pl('r_gender.id = '||r_gender.id); + pl('r_gender.code = '||r_gender.code); + pl('r_gender.description = '||r_gender.description); + pl('r_gender.active_date = '||r_gender.active_date); + pl('r_gender.inactive_date = '||r_gender.inactive_date); + + -- Last, delete the object from the relational table + delete GENDER_T + where code = 'T'; + + -- Commit all these operations + commit; + + -- Confirm that the test completed successfully + pl('Test completed successfully.'); +end; +/ diff --git a/Chapter06/gender_ov.vw b/Chapter06/gender_ov.vw new file mode 100644 index 0000000..dfec5b6 --- /dev/null +++ b/Chapter06/gender_ov.vw @@ -0,0 +1,12 @@ +rem gender_ov.vw +rem by Donald J. Bales on 12/15/2006 +rem Create an object view for table GENDER_T + +create view GENDER_OV of GENDER_O +with object identifier (id) as +select id, + code, + description, + active_date, + inactive_date +from GENDER_T; diff --git a/Chapter06/gender_ts.pkb b/Chapter06/gender_ts.pkb new file mode 100644 index 0000000..4cbce95 --- /dev/null +++ b/Chapter06/gender_ts.pkb @@ -0,0 +1,177 @@ +create or replace PACKAGE BODY GENDER_TS as +/* +gender_ts.pkb +by Don Bales on 12/15/2006 +Table GENDER_T's methods +*/ + + +-- FUNCTIONS + +FUNCTION get_id +return GENDER_T.id%TYPE is + +n_id GENDER_T.id%TYPE; + +begin + select GENDER_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_id( +aiv_code in GENDER_T.code%TYPE ) +return GENDER_T.id%TYPE is + +n_id GENDER_T.id%TYPE; + +begin + select id + into n_id + from GENDER_T + where code = aiv_code; + + return n_id; +end get_id; + + +-- PROCEDURES + +PROCEDURE get_code_descr( +ain_id in GENDER_T.id%TYPE, +aov_code out GENDER_T.code%TYPE, +aov_description out GENDER_T.description%TYPE ) is + +begin + select code, + description + into aov_code, + aov_description + from GENDER_T + where id = ain_id; +end get_code_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE, +aid_on in GENDER_T.active_date%TYPE ) is + +v_code GENDER_T.code%TYPE; + +begin + select id, + description + into aon_id, + aov_description + from GENDER_T + where code = aiov_code + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); +exception + when NO_DATA_FOUND then + select id, + code, + description + into aon_id, + v_code, + aov_description + from GENDER_T + where code like aiov_code||'%' + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); + + aiov_code := v_code; +end get_code_id_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE ) is + +begin + get_code_id_descr( + aiov_code, + aon_id, + aov_description, + SYSDATE ); +end get_code_id_descr; + + +PROCEDURE help is + +begin +-- 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('GENDER_TS'); + pl(chr(9)); + pl('----------------------------------- FUNCTIONS ----------------------------------'); + pl(chr(9)); + pl('GENDER_TS.get_id'); + pl('return GENDER_T.id%TYPE;'); + pl(chr(9)||'Returns a newly allocated sequence value for id.'); + pl(chr(9)); + pl('GENDER_TS.get_id('); + pl('aiv_code in GENDER_T.code%TYPE )'); + pl('return GENDER_T.id%TYPE;'); + pl(chr(9)||'Returns the corresponding id for the specified code.'); + pl(chr(9)); + pl('----------------------------------- PROCEDURES ---------------------------------'); + pl(chr(9)); + pl('GENDER_TS.get_code_descr('); + pl('ain_id in GENDER_T.id%TYPE,'); + pl('aov_code out GENDER_T.code%TYPE,'); + pl('aov_description out GENDER_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding code and description for the specified'); + pl(chr(9)||'id.'); + pl(chr(9)); + pl('GENDER_TS.get_code_id_descr('); + pl('aiov_code in out GENDER_T.code%TYPE,'); + pl('aon_id out GENDER_T.id%TYPE,'); + pl('aov_description out GENDER_T.description%TYPE,'); + pl('aid_on in GENDER_T.active_date%TYPE );'); + pl(chr(9)||'Gets the corresponding code, id, and description for'); + pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified code and point in time.'); + pl(chr(9)); + pl('GENDER_TS.get_code_id_descr('); + pl('aiov_code in out GENDER_T.code%TYPE,'); + pl('aon_id out GENDER_T.id%TYPE,'); + pl('aov_description out GENDER_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding code, id, and description for'); + pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified code at the current point in time.'); + pl(chr(9)); + pl('GENDER_TS.help( );'); + pl(chr(9)||'Displays this help text if set serveroutput is on.'); + pl(chr(9)); + pl('GENDER_TS.test( );'); + pl(chr(9)||'Built-in test unit. It will report success or error for each test if set'); + pl(chr(9)||'serveroutput is on.'); + pl(chr(9)); +end help; + + +PROCEDURE test is + +begin + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('GENDER_TS'); + pl(chr(9)); + pl(chr(9)||'No tests coded at this time'); +end test; + + +end GENDER_TS; +/ +@be.sql GENDER_TS + diff --git a/Chapter06/gender_ts.pks b/Chapter06/gender_ts.pks new file mode 100644 index 0000000..6a39757 --- /dev/null +++ b/Chapter06/gender_ts.pks @@ -0,0 +1,58 @@ +create or replace PACKAGE GENDER_TS as +/* +gender_ts.pks +by Don Bales on 12/15/2006 +Table GENDER_T's methods. +*/ + +/* +Gets the code and decription values for the specified id. +*/ +PROCEDURE get_code_descr( +ain_id in GENDER_T.id%TYPE, +aov_code out GENDER_T.code%TYPE, +aov_description out GENDER_T.description%TYPE); + +/* +Verifies that the passed code value is an exact or like match on the date specified. +*/ +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE, +aid_on in GENDER_T.active_date%TYPE); + +/* +Verifies that the passed code value is currently an exact or like match. +*/ +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE); + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return GENDER_T.id%TYPE; + +/* +Returns the id for the specified code value. +*/ +FUNCTION get_id( +aiv_code in GENDER_T.code%TYPE) +return GENDER_T.id%TYPE; + +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + +/* +Test units for this package. +*/ +PROCEDURE test; + +end GENDER_TS; +/ +@se.sql GENDER_TS diff --git a/Chapter06/login.sql b/Chapter06/login.sql new file mode 100644 index 0000000..839e26f --- /dev/null +++ b/Chapter06/login.sql @@ -0,0 +1,10 @@ +rem login.sql +rem by Donald J. Bales on 12/15/2006 +rem Set my default SQL*Plus environment +set linesize 1000; +set newpage 1; +set pagesize 32767; +set serveroutput on size 1000000; +set trimspool on; +alter session set nls_date_format = 'SYYYYMMDD HH24MISS'; +prompt BPS' default settings loaded successfully! diff --git a/Chapter06/pe.sql b/Chapter06/pe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter06/pe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter06/pl.sql b/Chapter06/pl.sql new file mode 100644 index 0000000..08b13fc --- /dev/null +++ b/Chapter06/pl.sql @@ -0,0 +1,10 @@ +rem pl.sql +rem by Donald J. Bales on 12/15/2006 +rem pl's test unit + +prompt 'Test a line <= 255'; -- 20 21 22 23 24 25 +exec pl('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345'); +prompt 'Test a line > 255'; +exec pl('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); +prompt 'Test a multi-line'; +exec pl('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||chr(10)||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'||chr(10)||'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'); diff --git a/Chapter06/se.sql b/Chapter06/se.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter06/se.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter06/solutions/worker_o.sql b/Chapter06/solutions/worker_o.sql new file mode 100644 index 0000000..02b6f1f --- /dev/null +++ b/Chapter06/solutions/worker_o.sql @@ -0,0 +1,20 @@ +declare + +o_worker worker_o; + +begin + o_worker := new worker_o(); + o_worker.first_name := 'JOHN'; + o_worker.middle_name := 'J.'; + o_worker.last_name := 'DOE'; + o_worker.name := worker_o.get_formatted_name( + o_worker.first_name, + o_worker.middle_name, + o_worker.last_name ); + o_worker.birth_date := trunc(SYSDATE - (40*365.25)); + + pl(o_worker.to_varchar2); + + o_worker.test(); +end; +/ diff --git a/Chapter06/solutions/worker_o.tpb b/Chapter06/solutions/worker_o.tpb new file mode 100644 index 0000000..fca1f3d --- /dev/null +++ b/Chapter06/solutions/worker_o.tpb @@ -0,0 +1,451 @@ +create or replace type body WORKER_O as +/* +worker_o.tpb +by Don Bales on 12/15/2006 +TYPE WORKER's methods +*/ + +MEMBER FUNCTION get_age( +aid_on in date) +return number is + +begin + return WORKER_O.get_age(birth_date, aid_on); +end get_age; + + +MEMBER FUNCTION get_age +return number is + +begin + return WORKER_O.get_age(birth_date, SYSDATE); +end get_age; + + +STATIC FUNCTION get_age( +aid_birth_date in date, +aid_on in date) +return number is + +begin + if aid_birth_date is not NULL and + aid_on is not NULL then + return trunc(months_between(aid_on, aid_birth_date) / 12); + else + return NULL; + end if; +exception + when OTHERS then + return NULL; +end get_age; + + +STATIC FUNCTION get_age( +aid_birth_date in date) +return number is + +begin + return WORKER_O.get_age(aid_birth_date, SYSDATE); +end get_age; + + +STATIC FUNCTION get_age( +ain_id in number, +aid_on in date) +return number is + +begin + return WORKER_O.get_age(WORKER_O.get_birth_date(ain_id), aid_on); +end get_age; + + +STATIC FUNCTION get_age( +ain_id in number) +return number is + +begin + return WORKER_O.get_age(WORKER_O.get_birth_date(ain_id)); +end get_age; + + +STATIC FUNCTION get_birth_date( +ain_id in number) +return date is + +d_birth_date date; + +begin + select birth_date + into d_birth_date + from WORKER_T + where id = ain_id; + + return d_birth_date; +end get_birth_date; + + +STATIC FUNCTION get_external_id +return varchar2 is + +v_external_id varchar2(30); + +begin + select lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0') + into v_external_id + from SYS.DUAL; + + return v_external_id; +end get_external_id; + + +STATIC FUNCTION get_id +return number is + +n_id number; + +begin + select WORKER_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +STATIC FUNCTION get_id( +aiv_external_id in varchar2) +return number is + +n_id number; + +begin + select id + into n_id + from WORKER_T + where external_id = aiv_external_id; + + return n_id; +end get_id; + + +STATIC FUNCTION get_formatted_name( +aiv_first_name in varchar2, +aiv_middle_name in varchar2, +aiv_last_name in varchar2) +return varchar2 is + +begin + return aiv_last_name||', '||aiv_first_name||' '||aiv_middle_name; +end get_formatted_name; + + +STATIC FUNCTION get_formatted_name( +ain_id in number) +return varchar2 is + +v_first_name varchar2(30); +v_middle_name varchar2(30); +v_last_name varchar2(30); + +begin + select first_name, + middle_name, + last_name + into v_first_name, + v_middle_name, + v_last_name + from WORKER_OT + where id = ain_id; + + return get_formatted_name( + v_first_name, + v_middle_name, + v_last_name); +end get_formatted_name; + + +STATIC FUNCTION get_row( +aio_worker in WORKER_O) +return WORKER_O is + +o_worker WORKER_O; + +begin + if aio_worker.id is not NULL then + -- retrieve the row by the primary key + select value(w) + into o_worker + from WORKER_OT w + where id = aio_worker.id; + elsif aio_worker.external_id is not NULL then + -- retrieve the row by the external unique key + select value(w) + into o_worker + from WORKER_OT w + where external_id = aio_worker.external_id; + else + -- retrieve the row by the name, birth_date, and gender + select value(w) + into o_worker + from WORKER_OT w + where name = worker_o.get_formatted_name( + aio_worker.first_name, + aio_worker.middle_name, + aio_worker.last_name) + and birth_date = aio_worker.birth_date + and gender_id = aio_worker.gender_id; + end if; + return o_worker; +exception + when NO_DATA_FOUND then + raise; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select WORKER_OT'|| + ' in WORKER_O.get_row()'); +end get_row; + + +STATIC FUNCTION get_unformatted_name( +aiv_first_name in varchar2, +aiv_middle_name in varchar2, +aiv_last_name in varchar2) +return varchar2 is + +begin + return upper(replace(replace(replace(replace(replace( + aiv_last_name||aiv_first_name||aiv_middle_name, + '''', NULL), ',', NULL), '-', NULL), '.', NULL), ' ', NULL)); +end get_unformatted_name; + + +STATIC FUNCTION is_duplicate( +aiv_name in varchar2, +aid_birth_date in varchar2, +ain_gender_id in varchar2) +return boolean is + +n_selected number; + +begin + execute immediate + 'select count(1) + from WORKER_OT + where name = aiv_name + and birth_date = aid_birth_date + and gender_id = ain_gender_id' + into n_selected + using in aiv_name, + in aid_birth_date, + in ain_gender_id; + + if nvl(n_selected, 0) > 0 then + return TRUE; + else + return FALSE; + end if; +end is_duplicate; + + +MEMBER PROCEDURE help is + +begin +-- 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('WORKER_TS'); + pl(chr(9)); + pl('----------------------------------- FUNCTIONS ----------------------------------'); + pl(chr(9)); + pl('YOU GOTTA CODE THIS BUDDY WORKER_TS.get_id'); + pl('return number;'); + pl(chr(9)||'Returns a newly allocated sequence value for id.'); + pl(chr(9)); + pl('WORKER_TS.get_id('); + pl('aiv_external_id in varchar2 )'); + pl('return number;'); + pl(chr(9)||'Returns the corresponding id for the specified external_id.'); + pl(chr(9)); + pl('----------------------------------- PROCEDURES ---------------------------------'); + pl(chr(9)); + pl('WORKER_TS.get_external_id_descr('); + pl('ain_id in number,'); + pl('aov_external_id out varchar2,'); + pl('aov_description out WORKER_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding external_id and description for the specified'); + pl(chr(9)||'id.'); + pl(chr(9)); + pl('WORKER_TS.get_external_id_id_descr('); + pl('aiov_external_id in out varchar2,'); + pl('aon_id out number,'); + pl('aov_description out WORKER_T.description%TYPE,'); + pl('aid_on in WORKER_T.active%TYPE );'); + pl(chr(9)||'Gets the corresponding external_id, id, and description for'); + pl(chr(9)||'the specified external_id. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified external_id and point in time.'); + pl(chr(9)); + pl('WORKER_TS.get_external_id_id_descr('); + pl('aiov_external_id in out varchar2,'); + pl('aon_id out number,'); + pl('aov_description out WORKER_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding external_id, id, and description for'); + pl(chr(9)||'the specified external_id. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified external_id at the current point in time.'); + pl(chr(9)); + pl('WORKER_TS.help( );'); + pl(chr(9)||'Displays this help text if set serveroutput is on.'); + pl(chr(9)); + pl('WORKER_TS.test( );'); + pl(chr(9)||'Built-in test unit. It will report success or error for each test if set'); + pl(chr(9)||'serveroutput is on.'); + pl(chr(9)); +end help; + + +STATIC PROCEDURE set_row( +aioo_worker in out WORKER_O) is + +d_null constant date := DATES.d_MIN; +n_null constant number := 0; +v_null constant varchar2(1) := ' '; +o_worker WORKER_O; + +begin + -- set the formatted name + aioo_worker.name := worker_o.get_formatted_name( + aioo_worker.first_name, + aioo_worker.middle_name, + aioo_worker.last_name); + -- get the existing row + begin + o_worker := get_row(aioo_worker); + exception + when NO_DATA_FOUND then + o_worker := NULL; + end; + -- if a row exists, update it if needed + if o_worker is not NULL then + aioo_worker.id := o_worker.id; + if nvl(o_worker.worker_type_id, n_null) <> + nvl(aioo_worker.worker_type_id, n_null) or + nvl(o_worker.external_id, n_null) <> + nvl(aioo_worker.external_id, n_null) or + nvl(o_worker.first_name, v_null) <> + nvl(aioo_worker.first_name, v_null) or + nvl(o_worker.middle_name, v_null) <> + nvl(aioo_worker.middle_name, v_null) or + nvl(o_worker.last_name, v_null) <> + nvl(aioo_worker.last_name, v_null) or + nvl(o_worker.birth_date, d_null) <> + nvl(aioo_worker.birth_date, d_null) or + nvl(o_worker.gender_id, n_null) <> + nvl(aioo_worker.gender_id, n_null) then + begin + update WORKER_OT + set worker_type_id = aioo_worker.worker_type_id, + external_id = aioo_worker.external_id, + first_name = aioo_worker.first_name, + middle_name = aioo_worker.middle_name, + last_name = aioo_worker.last_name, + name = aioo_worker.name, + birth_date = aioo_worker.birth_date, + gender_id = aioo_worker.gender_id + where id = aioo_worker.id; + +-- n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20002, SQLERRM|| + ' on update WORKER_OT'|| + ' in WORKER_TS.set_row()' ); + end; + end if; + else + -- add the row if it does not exist + begin + aioo_worker.id := get_id(); + insert into WORKER_OT + values ( aioo_worker ); + +-- n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20003, SQLERRM|| + ' on insert WORKER_OT'|| + ' in WORKER_O.set_row()' ); + end; + end if; +end set_row; + + +MEMBER PROCEDURE test( +self in out nocopy worker_o) is + +begin + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('WORKER_TS'); + pl(chr(9)); + pl(chr(9)||'No tests for WORKER_TS at this time'); +end test; + + +MAP MEMBER FUNCTION to_varchar2 +return varchar2 is + +begin + return rtrim(name||to_char(birth_date, 'YYYYMMDDHH24MISS')); +end to_varchar2; + + +CONSTRUCTOR FUNCTION worker_o( +self in out worker_o, +ain_worker_type_id in number, +aiv_first_name in varchar2, +aiv_middle_name in varchar2, +aiv_last_name in varchar2, +aid_birth_date in date, +ain_gender_id in number) +return self as result is + +begin + id := WORKER_O.get_id(); + worker_type_id := ain_worker_type_id; + external_id := WORKER_O.get_external_id(); + first_name := aiv_first_name; + middle_name := aiv_middle_name; + last_name := aiv_last_name; + name := WORKER_O.get_formatted_name( + first_name, middle_name, last_name); + birth_date := aid_birth_date; + gender_id := ain_gender_id; + return; +end worker_o; + + +CONSTRUCTOR FUNCTION worker_o( +self in out worker_o) +return self as result is + +begin + id := NULL; + worker_type_id := NULL; + external_id := NULL; + first_name := NULL; + middle_name := NULL; + last_name := NULL; + name := NULL; + birth_date := NULL; + gender_id := NULL; + return; +end worker_o; + + +end; --WORKER; +/ +@be.sql WORKER + diff --git a/Chapter06/solutions/worker_o.tps b/Chapter06/solutions/worker_o.tps new file mode 100644 index 0000000..087372d --- /dev/null +++ b/Chapter06/solutions/worker_o.tps @@ -0,0 +1,154 @@ +execute drop_if_exists('table','WORKER_OT'); +execute drop_if_exists('view','WORKER_OV'); +execute drop_if_exists('type','WORKER_O'); +create type WORKER_O as object ( +/* +worker_o.tps +by Don Bales on 12/15/2006 +Type WORKER_O's attributes and methods. +*/ +id number, +worker_type_id number, +external_id varchar2(30), +first_name varchar2(30), +middle_name varchar2(30), +last_name varchar2(30), +name varchar2(100), +birth_date date, +gender_id number, +/* +Get the worker's current age. +*/ +MEMBER FUNCTION get_age +return number, +/* +Get the worker's age on the specified date. +*/ +MEMBER FUNCTION get_age( +aid_on date) +return number, +/* +Calculate a worker's age for the given birth date +and point in time. +*/ +STATIC FUNCTION get_age( +aid_birth_date in date, +aid_on in date) +return number, +/* +Calculate a worker's current age for the given bith date. +*/ +STATIC FUNCTION get_age( +aid_birth_date in date) +return number, +/* +Get the specified worker's age at the given point in time. +*/ +STATIC FUNCTION get_age( +ain_id in number, +aid_on in date) +return number, +/* +Get the specified worker's current age. +*/ +STATIC FUNCTION get_age( +ain_id in number) +return number, +/* +Get the specified worker's birth date. +*/ +STATIC FUNCTION get_birth_date( +ain_id in number) +return date, +/* +Get the specified worker's external ID. +*/ +STATIC FUNCTION get_external_id +return varchar2, +/* +Calculate the locale specific formatted name. +*/ +STATIC FUNCTION get_formatted_name( +aiv_first_name in varchar2, +aiv_middle_name in varchar2, +aiv_last_name in varchar2) +return varchar2, +/* +Get the specified worker's formatted name. +*/ +STATIC FUNCTION get_formatted_name( +ain_id in number) +return varchar2, +/* +Get the next primary key value for the table. +*/ +STATIC FUNCTION get_id +return number, +/* +Get the specified worker's internal ID. +*/ +STATIC FUNCTION get_id( +aiv_external_id in varchar2) +return number, +/* +Get the specified worker's row object. +*/ +STATIC FUNCTION get_row( +aio_worker in WORKER_O) +return WORKER_O, +/* +Calculate the non-locale specific unformmated name. +*/ +STATIC FUNCTION get_unformatted_name( +aiv_first_name in varchar2, +aiv_middle_name in varchar2, +aiv_last_name in varchar2) +return varchar2, +/* +Display the help text for this TYPE. +*/ +MEMBER PROCEDURE help, +/* +Check to see if a worker with the same name, birth_date and +gender already exists in the database. +*/ +STATIC FUNCTION is_duplicate( +aiv_name in varchar2, +aid_birth_date in varchar2, +ain_gender_id in varchar2) +return boolean, +/* +Set the specified worker's row object. +*/ +STATIC PROCEDURE set_row( +aioo_worker in out WORKER_O), +/* +Execute the test unit for this TYPE. +*/ +MEMBER PROCEDURE test, +/* +The MAP function for this TYPE. +*/ +MAP MEMBER FUNCTION to_varchar2 +return varchar2, +/* +A convenience constructor for this TYPE. +*/ +CONSTRUCTOR FUNCTION worker_o( +self in out worker_o, +ain_worker_type_id in number, +aiv_first_name in varchar2, +aiv_middle_name in varchar2, +aiv_last_name in varchar2, +aid_birth_date in date, +ain_gender_id in number) +return self as result, +/* +A NULL values constructor for this TYPE. +*/ +CONSTRUCTOR FUNCTION worker_o( +self in out worker_o) +return self as result +); +/ +@se.sql diff --git a/Chapter06/solutions/worker_ot.ins b/Chapter06/solutions/worker_ot.ins new file mode 100644 index 0000000..69188f6 --- /dev/null +++ b/Chapter06/solutions/worker_ot.ins @@ -0,0 +1,64 @@ +rem worker_ot.ins +rem by Donald J. Bales on 12/15/2006 +rem Seed the Worker table with the top 100 names +rem 100 last x 100 first x 26 middle = 260,000 entries + +set serveroutput on size 1000000; + +declare + +-- This is the number of seconds since midnight +-- I'll use it to profile my code's performance. +n_start number := + to_number(to_char(SYSDATE, 'SSSSS')); + +-- Here, I declare four psuedo-constants to hold the +-- ID values from the code tables, rather than look +-- them up repeatedly during the insert process. +n_G_FEMALE GENDER_OT.id%TYPE; +n_G_MALE GENDER_OT.id%TYPE; +n_WT_CONTRACTOR WORKER_TYPE_OT.id%TYPE; +n_WT_EMPLOYEE WORKER_TYPE_OT.id%TYPE; + +-- I'll use this to keep track of the number of +-- rows inserted. +n_inserted number := 0; + +begin + -- Get the ID values for the codes + n_G_FEMALE := GENDER_O.get_id('F'); + n_G_MALE := GENDER_O.get_id('M'); + n_WT_CONTRACTOR := WORKER_TYPE_O.get_id('C'); + n_WT_EMPLOYEE := WORKER_TYPE_O.get_id('E'); + + -- Use an INSERT INTO SELECT SQL statement + insert into WORKER_OT + select WORKER_O( + WORKER_ID_SEQ.nextval, + decode(mod(WORKER_ID_SEQ.currval, 2), + 0, n_WT_EMPLOYEE, n_WT_CONTRACTOR), + lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0'), + first_name, + letter||'.', + last_name, + WORKER_O.get_formatted_name( + first_name, letter||'.', last_name), + DATES.random( + to_number(to_char(SYSDATE, 'YYYY')) - 65, + to_number(to_char(SYSDATE, 'YYYY')) - 18), + decode(gender_code, 'F', n_G_FEMALE, n_G_MALE)) + from TOP_100_LAST_NAME, + TOP_100_FIRST_NAME, + A_THRU_Z; + + n_inserted := n_inserted + sql%rowcount; + + commit; + + pl(to_char(n_inserted)||' rows inserted in '|| + (to_number(to_char(SYSDATE, 'SSSSS')) - n_start)|| + ' seconds.'); +end; +/ + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKER_OT'); diff --git a/Chapter06/solutions/worker_ot.tab b/Chapter06/solutions/worker_ot.tab new file mode 100644 index 0000000..e8f2bec --- /dev/null +++ b/Chapter06/solutions/worker_ot.tab @@ -0,0 +1,52 @@ +rem worker_ot.tab +rem by Donald J. Bales on 12/15/2006 +rem Create an object table for Workers + +--drop table WORKER_OT; +create table WORKER_OT of WORKER_O +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence WORKER_ID_SEQ; +--create sequence WORKER_ID_SEQ +--start with 1; + +--drop sequence EXTERNAL_ID_SEQ; +--create sequence EXTERNAL_ID_SEQ +--start with 100000000 order; + +alter table WORKER_OT add +constraint WORKER_OT_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKER_OT add +constraint WORKER_OT_UK1 +unique ( external_id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKER_OT add +constraint WORKER_OT_UK2 +unique ( +name, +birth_date, +gender_id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKER_OT add +constraint WORKER_OT_FK1 +foreign key ( worker_type_id ) +references WORKER_TYPE_OT ( id ); + +alter table WORKER_OT add +constraint WORKER_OT_FK2 +foreign key ( gender_id ) +references GENDER_OT ( id ); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKER_OT'); diff --git a/Chapter06/solutions/worker_type_o.sql b/Chapter06/solutions/worker_type_o.sql new file mode 100644 index 0000000..0f0afba --- /dev/null +++ b/Chapter06/solutions/worker_type_o.sql @@ -0,0 +1,19 @@ +declare +-- Declare a worker_type_o variable +o_worker_type WORKER_TYPE_O; + +begin + -- Now use the default constructor to create a new instance + -- of the object + o_worker_type := new WORKER_TYPE_O( + NULL, 'H', 'A hard worker', SYSDATE, NULL); + -- Now allocate a new ID using the member function get_id() + o_worker_type.id := o_worker_type.get_id(); + -- Now show the values of the attributes in the instance + pl('o_worker_type.id = '||o_worker_type.id); + pl('o_worker_type.code = '||o_worker_type.code); + pl('o_worker_type.description = '||o_worker_type.description); + pl('o_worker_type.active_date = '||o_worker_type.active_date); + pl('o_worker_type.inactive_date = '||o_worker_type.inactive_date); +end; +/ diff --git a/Chapter06/solutions/worker_type_o.tpb b/Chapter06/solutions/worker_type_o.tpb new file mode 100644 index 0000000..06e44a6 --- /dev/null +++ b/Chapter06/solutions/worker_type_o.tpb @@ -0,0 +1,154 @@ +create or replace TYPE BODY WORKER_TYPE_O as +/* +worker_type_o.tpb +by Don Bales on 12/15/2006 +Type WORKER_TYPE_O's methods +*/ + + +MEMBER FUNCTION get_id +return number is + +n_id number; + +begin + select WORKER_TYPE_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +STATIC FUNCTION get_id( +aiv_code in varchar2 ) +return number is + +n_id number; + +begin + select id + into n_id + from WORKER_TYPE_OT + where code = aiv_code; + + return n_id; +end get_id; + + +STATIC PROCEDURE get_code_descr( +ain_id in number, +aov_code out varchar2, +aov_description out varchar2 ) is + +begin + select code, + description + into aov_code, + aov_description + from WORKER_TYPE_OT + where id = ain_id; +end get_code_descr; + + +STATIC PROCEDURE get_code_id_descr( +aiov_code in out varchar2, +aon_id out number, +aov_description out varchar2, +aid_on in date ) is + +v_code varchar2(30); + +begin + select id, + description + into aon_id, + aov_description + from WORKER_TYPE_OT + where code = aiov_code + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); +exception + when NO_DATA_FOUND then + select id, + code, + description + into aon_id, + v_code, + aov_description + from WORKER_TYPE_OT + where code like aiov_code||'%' + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); + + aiov_code := v_code; +end get_code_id_descr; + + +STATIC PROCEDURE get_code_id_descr( +aiov_code in out varchar2, +aon_id out number, +aov_description out varchar2 ) is + +begin + get_code_id_descr( + aiov_code, + aon_id, + aov_description, + SYSDATE ); +end get_code_id_descr; + + +STATIC PROCEDURE help is + +begin + pl('No help coded at this time.'); +end help; + + +STATIC PROCEDURE test is + +begin + pl('No tests coded at this time.'); +end test; + + +MAP MEMBER FUNCTION to_varchar2 +return varchar2 is + +begin + return description||to_char(active_date, 'YYYYMMDDHH24MISS'); +end to_varchar2; + + +CONSTRUCTOR FUNCTION worker_type_o( +self in out worker_type_o) +return self as result is + +begin + id := NULL; + code := NULL; + description := NULL; + active_date := NULL; + inactive_date := NULL; + return; +end worker_type_o; + + +CONSTRUCTOR FUNCTION worker_type_o( +self in out worker_type_o, +aiv_code in varchar2, +aiv_description in varchar2) +return self as result is + +begin + id := get_id(); + code := aiv_code; + description := aiv_description; + active_date := SYSDATE; + inactive_date := NULL; + return; +end worker_type_o; + + +end; +/ +@be.sql WORKER_TYPE_O diff --git a/Chapter06/solutions/worker_type_o.tps b/Chapter06/solutions/worker_type_o.tps new file mode 100644 index 0000000..d958c18 --- /dev/null +++ b/Chapter06/solutions/worker_type_o.tps @@ -0,0 +1,60 @@ +execute drop_if_exists('table','WORKER_TYPE_OT'); +execute drop_if_exists('view','WORKER_TYPE_OV'); +execute drop_if_exists('type','WORKER_TYPE_O'); +create TYPE WORKER_TYPE_O as object ( +/* +worker_type_o.tps +by Don Bales on 12/15/2006 +Type WORKER_TYPE_O's attributes and methods. +*/ +id number, +code varchar2(30), +description varchar2(80), +active_date date, +inactive_date date, +-- Gets the code and decription values for the specified work_type_id. +STATIC PROCEDURE get_code_descr( +ain_id in number, +aov_code out varchar2, +aov_description out varchar2 ), +-- Verifies the passed aiov_code value is an exact or like match on the +-- date specified. +STATIC PROCEDURE get_code_id_descr( +aiov_code in out varchar2, +aon_id out number, +aov_description out varchar2, +aid_on in date ), +-- Verifies the passed aiov_code value is currently an exact or like match. +STATIC PROCEDURE get_code_id_descr( +aiov_code in out varchar2, +aon_id out number, +aov_description out varchar2 ), +-- Returns a newly allocated id value. +MEMBER FUNCTION get_id +return number, +-- Returns the id for the specified code value. +STATIC FUNCTION get_id( +aiv_code in varchar2 ) +return number, +-- Test-based help for this package. "set serveroutput on" in SQL*Plus. +STATIC PROCEDURE help, +-- Test units for this package. +STATIC PROCEDURE test, +-- A MAP function for sorting at the object level. +MAP MEMBER FUNCTION to_varchar2 +return varchar2, +-- A constructor for creating a new instance of type WORKER_TYPE_O +-- with NULL values. +CONSTRUCTOR FUNCTION worker_type_o( +self in out worker_type_o) +return self as result, +-- A constructor for creating a new instance of type WORKER_TYPE_O +-- for insert. +CONSTRUCTOR FUNCTION worker_type_o( +self in out worker_type_o, +aiv_code in varchar2, +aiv_description in varchar2) +return self as result +); +/ +@se.sql WORKER_TYPE_O diff --git a/Chapter06/solutions/worker_type_ot.ins b/Chapter06/solutions/worker_type_ot.ins new file mode 100644 index 0000000..68b2a9d --- /dev/null +++ b/Chapter06/solutions/worker_type_ot.ins @@ -0,0 +1,10 @@ +rem worker_type_ot.ins +rem copyright by Donald J. Bales on 12/15/2006 +rem + +insert into WORKER_TYPE_OT values ( worker_type_o( 'C', 'Contractor' ) ); +insert into WORKER_TYPE_OT values ( worker_type_o( 'E', 'Employee' ) ); +insert into WORKER_TYPE_OT values ( worker_type_o( 'U', 'Unknown' ) ); +commit; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKER_TYPE_OT'); diff --git a/Chapter06/solutions/worker_type_ot.sql b/Chapter06/solutions/worker_type_ot.sql new file mode 100644 index 0000000..94efdbc --- /dev/null +++ b/Chapter06/solutions/worker_type_ot.sql @@ -0,0 +1,50 @@ +rem worker_type_ot.sql +rem by Donald J. Bales on 12/15/2006 +rem test unit for object table WORKER_TYPE_OT + +declare +-- Declare a variable of the user-define type +o_worker_type WORKER_TYPE_O; + +begin + -- Insert a test object using the convenience constructor + insert into WORKER_TYPE_OT + values ( WORKER_TYPE_O( 'T', 'Test') ); + + -- Now update the inactive date on the object + update WORKER_TYPE_OT + set inactive_date = SYSDATE + where code = 'T'; + + -- Retrieve the object in order to show its values + select value(g) + into o_worker_type + from WORKER_TYPE_OT g + where code = 'T'; + + -- Show the object's values + pl('o_worker_type.id = '||o_worker_type.id); + pl('o_worker_type.code = '||o_worker_type.code); + pl('o_worker_type.description = '||o_worker_type.description); + pl('o_worker_type.active_date = '||o_worker_type.active_date); + pl('o_worker_type.inactive_date = '||o_worker_type.inactive_date); + + -- Delete the test object + delete WORKER_TYPE_OT + where code = 'T'; + + -- This time insert the test object using the instance variable + insert into WORKER_TYPE_OT + values ( o_worker_type ); + + -- Last, delete the object from the relational table + delete WORKER_TYPE_OT + where code = 'T'; + + -- Commit all these operations + commit; + + -- Confirm that the test completed successfully + pl('Test completed successfully.'); +end; +/ diff --git a/Chapter06/solutions/worker_type_ot.tab b/Chapter06/solutions/worker_type_ot.tab new file mode 100644 index 0000000..8a8a54e --- /dev/null +++ b/Chapter06/solutions/worker_type_ot.tab @@ -0,0 +1,28 @@ +rem worker_type_ot.tab +rem copyright by Donald J. Bales on 12/15/2006 +rem Create an object table for the Worker Type codes + +--drop table WORKER_TYPE_OT; +create table WORKER_TYPE_OT of WORKER_TYPE_O +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +--drop sequence WORKER_TYPE_ID_SEQ; +--create sequence WORKER_TYPE_ID_SEQ +--start with 1; + +alter table WORKER_TYPE_OT add +constraint WORKER_TYPE_OT_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKER_TYPE_OT add +constraint WORKER_TYPE_OT_UK +unique ( code ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKER_TYPE_OT'); diff --git a/Chapter06/solutions/worker_type_ov.sql b/Chapter06/solutions/worker_type_ov.sql new file mode 100644 index 0000000..2c6bb93 --- /dev/null +++ b/Chapter06/solutions/worker_type_ov.sql @@ -0,0 +1,65 @@ +rem worker_type_ov.sql +rem by Donald J. Bales on 12/15/2006 +rem test unit for object view WORKER_TYPE_OV + +declare +-- Declare a variable of the user-define type +o_worker_type WORKER_TYPE_O; +-- Declare a variable for t6he under-lying table +r_worker_type WORKER_TYPE_T%ROWTYPE; + +begin + -- Insert a test object using the convenience constructor + insert into WORKER_TYPE_OV + values ( WORKER_TYPE_O( 'T', 'Test') ); + + -- Now update the inactive date on the object + update WORKER_TYPE_OV + set inactive_date = SYSDATE + where code = 'T'; + + -- Retrieve the object in order to show its values + select value(g) + into o_worker_type + from WORKER_TYPE_OV g + where code = 'T'; + + -- Show the object's values + pl('o_worker_type.id = '||o_worker_type.id); + pl('o_worker_type.code = '||o_worker_type.code); + pl('o_worker_type.description = '||o_worker_type.description); + pl('o_worker_type.active_date = '||o_worker_type.active_date); + pl('o_worker_type.inactive_date = '||o_worker_type.inactive_date); + + -- Delete the test object + delete WORKER_TYPE_OV + where code = 'T'; + + -- This time insert the test object using the instance variable + insert into WORKER_TYPE_OV + values ( o_worker_type ); + + -- Now, select the values from the under-lying relational table + select * + into r_worker_type + from WORKER_TYPE_T + where code = 'T'; + + -- Show the record's values + pl('r_worker_type.id = '||r_worker_type.id); + pl('r_worker_type.code = '||r_worker_type.code); + pl('r_worker_type.description = '||r_worker_type.description); + pl('r_worker_type.active_date = '||r_worker_type.active_date); + pl('r_worker_type.inactive_date = '||r_worker_type.inactive_date); + + -- Last, delete the object from the relational table + delete WORKER_TYPE_T + where code = 'T'; + + -- Commit all these operations + commit; + + -- Confirm that the test completed successfully + pl('Test completed successfully.'); +end; +/ diff --git a/Chapter06/solutions/worker_type_ov.vw b/Chapter06/solutions/worker_type_ov.vw new file mode 100644 index 0000000..e7942b2 --- /dev/null +++ b/Chapter06/solutions/worker_type_ov.vw @@ -0,0 +1,12 @@ +rem worker_type_ov.vw +rem by Donald J. Bales on 12/15/2006 +rem Create an object view for table WORKER_TYPE_T + +create view WORKER_TYPE_OV of WORKER_TYPE_O +with object identifier (id) as +select id, + code, + description, + active_date, + inactive_date +from WORKER_TYPE_T; diff --git a/Chapter06/worker_ts.pkb b/Chapter06/worker_ts.pkb new file mode 100644 index 0000000..d165a20 --- /dev/null +++ b/Chapter06/worker_ts.pkb @@ -0,0 +1,400 @@ +create or replace PACKAGE BODY WORKER_TS as +/* +worker_ts.pkb +by Don Bales on 12/15/2006 +Table WORKER_T's methods +*/ + + +-- FUNCTIONS + +FUNCTION get_age( +aid_birth_date in WORKER_T.birth_date%TYPE, +aid_on in date) +return number is + +begin + if aid_birth_date is not NULL and + aid_on is not NULL then + return trunc(months_between(aid_on, aid_birth_date) / 12); + else + return NULL; + end if; +exception + when OTHERS then + return NULL; +end get_age; + + +FUNCTION get_age( +aid_birth_date in WORKER_T.birth_date%TYPE) +return number is + +begin + return get_age(aid_birth_date, SYSDATE); +end get_age; + + +FUNCTION get_age( +ain_id in WORKER_T.id%TYPE, +aid_on in date) +return number is + +begin + return get_age(get_birth_date(ain_id), aid_on); +end get_age; + + +FUNCTION get_age( +ain_id in WORKER_T.id%TYPE) +return number is + +begin + return get_age(get_birth_date(ain_id)); +end get_age; + + +FUNCTION get_birth_date( +ain_id in WORKER_T.id%TYPE) +return WORKER_T.birth_date%TYPE is + +d_birth_date WORKER_T.birth_date%TYPE; + +begin + select birth_date + into d_birth_date + from WORKER_T + where id = ain_id; + + return d_birth_date; +end get_birth_date; + + +FUNCTION get_external_id +return WORKER_T.external_id%TYPE is + +v_external_id WORKER_T.external_id%TYPE; + +begin + select lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0') + into v_external_id + from SYS.DUAL; + + return v_external_id; +end get_external_id; + + +FUNCTION get_id +return WORKER_T.id%TYPE is + +n_id WORKER_T.id%TYPE; + +begin + select WORKER_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_id( +aiv_external_id in WORKER_T.external_id%TYPE) +return WORKER_T.id%TYPE is + +n_id WORKER_T.id%TYPE; + +begin + select id + into n_id + from WORKER_T + where external_id = aiv_external_id; + + return n_id; +end get_id; + + +FUNCTION get_formatted_name( +aiv_first_name in WORKER_T.first_name%TYPE, +aiv_middle_name in WORKER_T.middle_name%TYPE, +aiv_last_name in WORKER_T.last_name%TYPE) +return WORKER_T.name%TYPE is + +begin + return aiv_last_name||', '||aiv_first_name||' '||aiv_middle_name; +end get_formatted_name; + + +FUNCTION get_formatted_name( +ain_id in WORKER_T.id%TYPE) +return WORKER_T.name%TYPE is + +v_first_name WORKER_T.first_name%TYPE; +v_middle_name WORKER_T.middle_name%TYPE; +v_last_name WORKER_T.last_name%TYPE; + +begin + select first_name, + middle_name, + last_name + into v_first_name, + v_middle_name, + v_last_name + from WORKER_T + where id = ain_id; + + return get_formatted_name( + v_first_name, + v_middle_name, + v_last_name); +end get_formatted_name; + + +FUNCTION get_row( +air_worker in WORKER_T%ROWTYPE) +return WORKER_T%ROWTYPE is + +r_worker WORKER_T%ROWTYPE; + +begin + if air_worker.id is not NULL then + -- retrieve the row by the primary key + select * + into r_worker + from WORKER_T + where id = air_worker.id; + elsif air_worker.external_id is not NULL then + -- retrieve the row by the external unique key + select * + into r_worker + from WORKER_T + where external_id = air_worker.external_id; + else + -- retrieve the row by the name, birth_date, and gender + select * + into r_worker + from WORKER_T + where name = get_unformatted_name( + air_worker.first_name, + air_worker.middle_name, + air_worker.last_name) + and birth_date = air_worker.birth_date + and gender_id = air_worker.gender_id; + end if; + return r_worker; +exception + when NO_DATA_FOUND then + raise; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select WORKER_T'|| + ' in WORKER_TS.get_row()'); +end get_row; + + +FUNCTION get_unformatted_name( +aiv_first_name in WORKER_T.first_name%TYPE, +aiv_middle_name in WORKER_T.middle_name%TYPE, +aiv_last_name in WORKER_T.last_name%TYPE) +return WORKER_T.name%TYPE is + +begin + return upper(replace(replace(replace(replace(replace( + aiv_last_name||aiv_first_name||aiv_middle_name, + '''', NULL), ',', NULL), '-', NULL), '.', NULL), ' ', NULL)); +end get_unformatted_name; + + +FUNCTION is_duplicate( +aiv_name in WORKER_T.name%TYPE, +aid_birth_date in WORKER_T.birth_date%TYPE, +ain_gender_id in WORKER_T.gender_id%TYPE) +return boolean is + +n_selected number; + +begin + select count(1) + into n_selected + from WORKER_T + where name = aiv_name + and birth_date = aid_birth_date + and gender_id = ain_gender_id; + + if nvl(n_selected, 0) > 0 then + return TRUE; + else + return FALSE; + end if; +end is_duplicate; + + +-- PROCEDURES + +PROCEDURE help is + +begin +-- 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('WORKER_TS'); + pl(chr(9)); + pl('----------------------------------- FUNCTIONS ----------------------------------'); + pl(chr(9)); + pl('YOU GOTTA CODE THIS BUDDY WORKER_TS.get_id'); + pl('return WORKER_T.id%TYPE;'); + pl(chr(9)||'Returns a newly allocated sequence value for id.'); + pl(chr(9)); + pl('WORKER_TS.get_id('); + pl('aiv_external_id in WORKER_T.external_id%TYPE )'); + pl('return WORKER_T.id%TYPE;'); + pl(chr(9)||'Returns the corresponding id for the specified external_id.'); + pl(chr(9)); + pl('----------------------------------- PROCEDURES ---------------------------------'); + pl(chr(9)); + pl('WORKER_TS.get_external_id_descr('); + pl('ain_id in WORKER_T.id%TYPE,'); + pl('aov_external_id out WORKER_T.external_id%TYPE,'); + pl('aov_description out WORKER_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding external_id and description for the specified'); + pl(chr(9)||'id.'); + pl(chr(9)); + pl('WORKER_TS.get_external_id_id_descr('); + pl('aiov_external_id in out WORKER_T.external_id%TYPE,'); + pl('aon_id out WORKER_T.id%TYPE,'); + pl('aov_description out WORKER_T.description%TYPE,'); + pl('aid_on in WORKER_T.active%TYPE );'); + pl(chr(9)||'Gets the corresponding external_id, id, and description for'); + pl(chr(9)||'the specified external_id. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified external_id and point in time.'); + pl(chr(9)); + pl('WORKER_TS.get_external_id_id_descr('); + pl('aiov_external_id in out WORKER_T.external_id%TYPE,'); + pl('aon_id out WORKER_T.id%TYPE,'); + pl('aov_description out WORKER_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding external_id, id, and description for'); + pl(chr(9)||'the specified external_id. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified external_id at the current point in time.'); + pl(chr(9)); + pl('WORKER_TS.help( );'); + pl(chr(9)||'Displays this help text if set serveroutput is on.'); + pl(chr(9)); + pl('WORKER_TS.test( );'); + pl(chr(9)||'Built-in test unit. It will report success or error for each test if set'); + pl(chr(9)||'serveroutput is on.'); + pl(chr(9)); +end help; + + +PROCEDURE set_row( +aior_worker in out WORKER_T%ROWTYPE) is + +d_null constant date := DATES.d_MIN; +n_null constant number := 0; +v_null constant varchar2(1) := ' '; +r_worker WORKER_T%ROWTYPE; + +begin + -- set the unformatted name + aior_worker.name := get_unformatted_name( + aior_worker.first_name, + aior_worker.middle_name, + aior_worker.last_name); + -- get the existing row + begin + r_worker := get_row(aior_worker); + exception + when NO_DATA_FOUND then + r_worker := NULL; + end; + -- if a row exists, update it if needed + if r_worker.id is not NULL then + aior_worker.id := r_worker.id; + aior_worker.external_id := r_worker.external_id; + if nvl(r_worker.worker_type_id, n_null) <> nvl(aior_worker.worker_type_id, n_null) or + nvl(r_worker.external_id, n_null) <> nvl(aior_worker.external_id, n_null) or + nvl(r_worker.first_name, v_null) <> nvl(aior_worker.first_name, v_null) or + nvl(r_worker.middle_name, v_null) <> nvl(aior_worker.middle_name, v_null) or + nvl(r_worker.last_name, v_null) <> nvl(aior_worker.last_name, v_null) or + nvl(r_worker.birth_date, d_null) <> nvl(aior_worker.birth_date, d_null) or + nvl(r_worker.gender_id, n_null) <> nvl(aior_worker.gender_id, n_null) then + begin + update WORKER_T + set worker_type_id = aior_worker.worker_type_id, + external_id = aior_worker.external_id, + first_name = aior_worker.first_name, + middle_name = aior_worker.middle_name, + last_name = aior_worker.last_name, + name = aior_worker.name, + birth_date = aior_worker.birth_date, + gender_id = aior_worker.gender_id + where id = aior_worker.id; + + n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20002, SQLERRM|| + ' on update WORKER_T'|| + ' in WORKER_TS.set_row()' ); + end; + end if; + else + -- add the row if it does not exist + begin + if aior_worker.id is NULL then + aior_worker.id := get_id(); + end if; + if aior_worker.external_id is NULL then + aior_worker.external_id := get_external_id(); + end if; + insert into WORKER_T ( + id, + worker_type_id, + external_id, + first_name, + middle_name, + last_name, + name, + birth_date, + gender_id ) + values ( + aior_worker.id, + aior_worker.worker_type_id, + aior_worker.external_id, + aior_worker.first_name, + aior_worker.middle_name, + aior_worker.last_name, + aior_worker.name, + aior_worker.birth_date, + aior_worker.gender_id ); + + n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20003, SQLERRM|| + ' on insert WORKER_T'|| + ' in WORKER_TS.set_row()' ); + end; + end if; +end set_row; + + +PROCEDURE test is + +begin + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('WORKER_TS'); + pl(chr(9)); + pl(chr(9)||'No tests for WORKER_TS at this time'); +end test; + + +end WORKER_TS; +/ +@be.sql WORKER_TS + diff --git a/Chapter06/worker_ts.pks b/Chapter06/worker_ts.pks new file mode 100644 index 0000000..1a5eb42 --- /dev/null +++ b/Chapter06/worker_ts.pks @@ -0,0 +1,100 @@ +create or replace PACKAGE WORKER_TS as +/* +worker_ts.pks +by Don Bales on 12/15/2006 +Table WORKER_T's methods. +*/ + +-- Keep track of the number of inserts and updates +n_inserted number := 0; +n_updated number := 0; + + +FUNCTION get_age( +aid_birth_date in WORKER_T.birth_date%TYPE, +aid_on in date) +return number; + + +FUNCTION get_age( +aid_birth_date in WORKER_T.birth_date%TYPE) +return number; + + +FUNCTION get_age( +ain_id in WORKER_T.id%TYPE, +aid_on in date) +return number; + + +FUNCTION get_age( +ain_id in WORKER_T.id%TYPE) +return number; + + +FUNCTION get_birth_date( +ain_id in WORKER_T.id%TYPE) +return WORKER_T.birth_date%TYPE; + + +FUNCTION get_external_id +return WORKER_T.external_id%TYPE; + + +FUNCTION get_id +return WORKER_T.id%TYPE; + + +FUNCTION get_id( +aiv_external_id in WORKER_T.external_id%TYPE) +return WORKER_T.id%TYPE; + + +FUNCTION get_formatted_name( +aiv_first_name in WORKER_T.first_name%TYPE, +aiv_middle_name in WORKER_T.middle_name%TYPE, +aiv_last_name in WORKER_T.last_name%TYPE) +return WORKER_T.name%TYPE; + + +FUNCTION get_formatted_name( +ain_id in WORKER_T.id%TYPE) +return WORKER_T.name%TYPE; + + +FUNCTION get_row( +air_worker in WORKER_T%ROWTYPE) +return WORKER_T%ROWTYPE; + + +FUNCTION get_unformatted_name( +aiv_first_name in WORKER_T.first_name%TYPE, +aiv_middle_name in WORKER_T.middle_name%TYPE, +aiv_last_name in WORKER_T.last_name%TYPE) +return WORKER_T.name%TYPE; + + +FUNCTION is_duplicate( +aiv_name in WORKER_T.name%TYPE, +aid_birth_date in WORKER_T.birth_date%TYPE, +ain_gender_id in WORKER_T.gender_id%TYPE) +return boolean; + + +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + + +PROCEDURE set_row( +aior_worker in out WORKER_T%ROWTYPE); + + +PROCEDURE test; + + +end WORKER_TS; +/ +@se.sql WORKER_TS + diff --git a/Chapter06/worker_type_ts.pkb b/Chapter06/worker_type_ts.pkb new file mode 100644 index 0000000..e5c46b8 --- /dev/null +++ b/Chapter06/worker_type_ts.pkb @@ -0,0 +1,172 @@ +create or replace PACKAGE BODY WORKER_TYPE_TS as +/* +worker_type_ts.pkb +by Don Bales on 12/15/2006 +Table WORKER_TYPE_T's methods +*/ + + +PROCEDURE get_code_descr( +ain_id in WORKER_TYPE_T.id%TYPE, +aov_code out WORKER_TYPE_T.code%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE ) is + +begin + select code, + description + into aov_code, + aov_description + from WORKER_TYPE_T + where id = ain_id; +end get_code_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out WORKER_TYPE_T.code%TYPE, +aon_id out WORKER_TYPE_T.id%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE, +aid_on in WORKER_TYPE_T.active_date%TYPE ) is + +v_code WORKER_TYPE_T.code%TYPE; + +begin + select id, + description + into aon_id, + aov_description + from WORKER_TYPE_T + where code = aiov_code + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); +exception + when NO_DATA_FOUND then + select id, + code, + description + into aon_id, + v_code, + aov_description + from WORKER_TYPE_T + where code like aiov_code||'%' + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); + + aiov_code := v_code; +end get_code_id_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out WORKER_TYPE_T.code%TYPE, +aon_id out WORKER_TYPE_T.id%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE ) is + +begin + get_code_id_descr( + aiov_code, + aon_id, + aov_description, + SYSDATE ); +end get_code_id_descr; + + +FUNCTION get_id +return WORKER_TYPE_T.id%TYPE is + +n_id WORKER_TYPE_T.id%TYPE; + +begin + select WORKER_TYPE_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_id( +aiv_code in WORKER_TYPE_T.code%TYPE ) +return WORKER_TYPE_T.id%TYPE is + +n_id WORKER_TYPE_T.id%TYPE; + +begin + select id + into n_id + from WORKER_TYPE_T + where code = aiv_code; + + return n_id; +end get_id; + + +PROCEDURE help is + +begin +-- 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('WORKER_TYPE_TS'); + pl(chr(9)); + pl('----------------------------------- FUNCTIONS ----------------------------------'); + pl(chr(9)); + pl('WORKER_TYPE_TS.get_id'); + pl('return WORKER_TYPE_T.id%TYPE;'); + pl(chr(9)||'Returns a newly allocated sequence value for id.'); + pl(chr(9)); + pl('WORKER_TYPE_TS.get_id('); + pl('aiv_code in WORKER_TYPE_T.code%TYPE )'); + pl('return WORKER_TYPE_T.id%TYPE;'); + pl(chr(9)||'Returns the corresponding id for the specified code.'); + pl(chr(9)); + pl('----------------------------------- PROCEDURES ---------------------------------'); + pl(chr(9)); + pl('WORKER_TYPE_TS.get_code_descr('); + pl('ain_id in WORKER_TYPE_T.id%TYPE,'); + pl('aov_code out WORKER_TYPE_T.code%TYPE,'); + pl('aov_description out WORKER_TYPE_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding code and description for the specified'); + pl(chr(9)||'id.'); + pl(chr(9)); + pl('WORKER_TYPE_TS.get_code_id_descr('); + pl('aiov_code in out WORKER_TYPE_T.code%TYPE,'); + pl('aon_id out WORKER_TYPE_T.id%TYPE,'); + pl('aov_description out WORKER_TYPE_T.description%TYPE,'); + pl('aid_on in WORKER_TYPE_T.active_date%TYPE );'); + pl(chr(9)||'Gets the corresponding code, id, and description for'); + pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified code and point in time.'); + pl(chr(9)); + pl('WORKER_TYPE_TS.get_code_id_descr('); + pl('aiov_code in out WORKER_TYPE_T.code%TYPE,'); + pl('aon_id out WORKER_TYPE_T.id%TYPE,'); + pl('aov_description out WORKER_TYPE_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding code, id, and description for'); + pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified code at the current point in time.'); + pl(chr(9)); + pl('WORKER_TYPE_TS.help( );'); + pl(chr(9)||'Displays this help text if set serveroutput is on.'); + pl(chr(9)); + pl('WORKER_TYPE_TS.test( );'); + pl(chr(9)||'Built-in test unit. It will report success or error for each test if set'); + pl(chr(9)||'serveroutput is on.'); + pl(chr(9)); +end help; + + +PROCEDURE test is + +begin + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('WORKER_TYPE_TS'); + pl(chr(9)); + pl(chr(9)||'No tests coded at this time'); +end test; + + +end WORKER_TYPE_TS; +/ +@be.sql WORKER_TYPE_TS diff --git a/Chapter06/worker_type_ts.pks b/Chapter06/worker_type_ts.pks new file mode 100644 index 0000000..03f5360 --- /dev/null +++ b/Chapter06/worker_type_ts.pks @@ -0,0 +1,53 @@ +create or replace PACKAGE WORKER_TYPE_TS as +/* +worker_type_ts.pks +by Don Bales on 12/15/2006 +Code Table WORKER_TYPE_T's methods. +*/ + +-- Gets the code and decription values for the specified work_type_id. + +PROCEDURE get_code_descr( +ain_id in WORKER_TYPE_T.id%TYPE, +aov_code out WORKER_TYPE_T.code%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE ); + +-- Verifies the passed aiov_code value is an exact or like match on the date specified. + +PROCEDURE get_code_id_descr( +aiov_code in out WORKER_TYPE_T.code%TYPE, +aon_id out WORKER_TYPE_T.id%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE, +aid_on in WORKER_TYPE_T.active_date%TYPE ); + +-- Verifies the passed aiov_code value is currently an exact or like match. + +PROCEDURE get_code_id_descr( +aiov_code in out WORKER_TYPE_T.code%TYPE, +aon_id out WORKER_TYPE_T.id%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE ); + +-- Returns a newly allocated id value. + +FUNCTION get_id +return WORKER_TYPE_T.id%TYPE; + +-- Returns the id for the specified code value. + +FUNCTION get_id( +aiv_code in WORKER_TYPE_T.code%TYPE ) +return WORKER_TYPE_T.id%TYPE; + +-- Test-based help for this package. "set serveroutput on" in SQL*Plus. + +PROCEDURE help; + +-- Test units for this package. + +PROCEDURE test; + + +end WORKER_TYPE_TS; +/ +@se.sql WORKER_TYPE_TS + diff --git a/Chapter07/README.txt b/Chapter07/README.txt new file mode 100644 index 0000000..2c2aa16 --- /dev/null +++ b/Chapter07/README.txt @@ -0,0 +1,142 @@ +README.txt for Chapter 7 +by Donald J. Bales on 4/15/2007 + +OBJECT NAME DESCRIPTION +--------------------------------------- ------------------------------------- +avg_profile.sql A DBMS_PROFILER report by avg desc + +be.sql Show package body compilation errors + +ci.sql Compile invalid objects + +debug_o.sql Test units for TYPE DEBUG_O + +debug_o.tpb Create TYPE DEBUG_O's body + +debug_o.tps Create TYPE DEBUG_O's specification + +debug_ot.sql Test units for object table DEBUG_OT + +debug_ot.tab Create object table DEBUG_OT + +debug_ots.pkb Create object table package + DEBUG_OTS' body + +debug_ots.pks Create object table package + DEBUG_OTS' specification + +debug_ots.sql Test units for object table package + DEBUG_OTS + +solutions\debug_t.sql Show the last set of debug data + from DEBUG_T + +solutions\debug_t.tab Create table DEBUG_T + +solutions\debug_ts.pkb Create table package DEBUG_TS' body + +solutions\debug_ts.pks Create table package DEBUG_TS' + specification + +solutions\debug_ts.sql Test unit for table package DEBUG_TS + +desc.sql Describe an object + +solutions\failure.sql A script that fails on purpose + +fe.sql Show function compilation errors + +is_profiler.sql Checks to see if the profiler is + installed and accessible + +login.sql Set my SQL*Plus defaults + +ord_profile.sql A DBMS_PROFILER report by program + unit and line number + +pe.sql Show procedure compilation errors + +pl.prc Don's handy-dandy "put_line" + procedure + +pl.sql Test units for procedure pl() + +profile.sql A DBMS_PROFILER detail report + +profiler.sql Show the DBMS_PROFILER version + +run_profile.sql Capture DBMS_PROFILER information + for the specified script + +se.sql Show package specification + compilation errors + +select_worker_ot_equalto.sql Query WORKER_OT using an equal sign + expression in the WHERE clause + +select_worker_ot_equalto.sql.pln Query WORKER_OT using an equal sign + expression in the WHERE clause's + plan + +select_worker_ot_likepct.sql Query WORKER_OT using a LIKE ||'%' + expression in the WHERE clause + +select_worker_ot_likepct.sql.pln Query WORKER_OT using a LIKE ||'%' + expression in the WHERE clause's + plan + + +select_worker_ot_pctlikepct.sql Query WORKER_OT using a LIKE '%'|| + ||'%' expression in the WHERE + clause + +select_worker_ot_pctlikepct.sql.pln Query WORKER_OT using a LIKE '%'|| + ||'%' expression in the WHERE + clause's plan + +select_worker_ot_pctlikepct2.sql Query WORKER_OT using a LIKE '%'|| + ||'%' expression in the WHERE + clause with a hint + +select_worker_ot_pctlikepct2.sql.pln Query WORKER_OT using a LIKE '%'|| + ||'%' expression in the WHERE + clause with a hint's plan + +success.sql A script with success messages + +test_o.sql Test units for TYPE TEST_O + +test_o.tpb Create TYPE TEST_O's body + +test_o.tps Create TYPE TEST_O's specification + +test_ot.tab Create object table TEST_OT + +usi.sql Show me my Unique Session Id + +worker_ot.ins Populate object table WORKER_OT + +worker_t_ins_insert.sql Insert/select statement to populate + WORKER_OT + +worker_t_ins_insert.sql.pln Insert/select statement to populate + WORKER_OT's plan + +worker_t_ins_insert_timing.sql An anonymous PL/SQL block that uses + an Insert/select statement to + populate WORKER_OT + +solutions\worker_t_ins_insert_w_codes. Insert/select statement to populate +sql WORKER_OT including 4 code tables + +solutions\worker_t_ins_insert_w_codes. Insert/select statement to populate +sql.pln WORKER_OT including 4 code tables' + plan + +solutions\worker_t_ins_insert_w_codes_ An anonymous PL/SQL block that uses +timing.sql an Insert/select statement to + populate WORKER_OT including code + tables + +xp.sql Display the execution plan for the + last executed cursor (eXplain Plan) diff --git a/Chapter07/avg_profile.sql b/Chapter07/avg_profile.sql new file mode 100644 index 0000000..bfa3172 --- /dev/null +++ b/Chapter07/avg_profile.sql @@ -0,0 +1,65 @@ +rem avg_profile.sql +rem by Donald J. Bales on 12/15/2006 +rem Create a DBMS_PROFILER report by avg desc + +define runid="&1"; + +column avg_pct format 990.99; +column line# format 9999; +column occur format 9999 +column text format a42 trunc; +column unit_name format a11; + +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +set verify off; + +spool avg_profile_&runid..txt; + +select v.unit_name, + round(v.avg_time/t.avg_time*100, 2) avg_pct, + v.occur, + v.line#, + ltrim(s.text) text +from SYS.DBA_SOURCE s, + ( select u.runid, + u.unit_owner, + u.unit_type, + u.unit_name, + d.min_time, + to_number(decode(d.total_occur, + NULL, NULL, + 0, 0, + round(d.total_time/d.total_occur))) avg_time, + d.max_time, + d.total_time, + d.total_occur occur, + d.line# + from PLSQL_PROFILER_UNITS u, + PLSQL_PROFILER_DATA d + where u.runid = d.runid + and u.unit_number = d.unit_number + and d.runid = &runid ) v, + ( select sum(to_number(decode(d.total_occur, + NULL, NULL, + 0, 0, + round(d.total_time/d.total_occur)))) avg_time + from PLSQL_PROFILER_UNITS u, + PLSQL_PROFILER_DATA d + where u.runid = d.runid + and u.unit_number = d.unit_number + and d.runid = &runid ) t +where v.unit_owner = s.owner(+) +and v.unit_type = s.type(+) +and v.unit_name = s.name(+) +and v.line# = s.line(+) +and v.avg_time > 0 +order by v.avg_time desc, + v.unit_name, + v.line#; + +spool off; + +set verify on; diff --git a/Chapter07/be.sql b/Chapter07/be.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter07/be.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter07/ci.sql b/Chapter07/ci.sql new file mode 100644 index 0000000..6dcc7e7 --- /dev/null +++ b/Chapter07/ci.sql @@ -0,0 +1,50 @@ +rem ci.sql +rem by Donald J. Bales on 12/15/2006 +rem Compile my invalid objects + +set feedback off; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +set serveroutput on size 1000000; + +spool ci.txt; +declare + +cursor c1 is +select object_type, + object_name +from SYS.USER_OBJECTS +where status = 'INVALID' +order by 1, 2; + +v_sql varchar2(100); + +begin + for r1 in c1 loop + begin + if r1.object_type = 'PACKAGE BODY' then + v_sql := 'alter PACKAGE '||r1.object_name||' compile BODY'; + elsif r1.object_type = 'TYPE BODY' then + v_sql := 'alter TYPE '||r1.object_name||' compile BODY'; + else + v_sql := 'alter '||r1.object_type||' '||r1.object_name||' compile'; + end if; + execute immediate v_sql; + pl(r1.object_type||' '||r1.object_name||' compiled successfully'); + exception + when OTHERS then + pl(SQLERRM||' on '||v_sql); + end; + end loop; +end; +/ + +spool off; + +set feedback on; + + + + \ No newline at end of file diff --git a/Chapter07/ci.txt b/Chapter07/ci.txt new file mode 100644 index 0000000..e69de29 diff --git a/Chapter07/compile_all.sql b/Chapter07/compile_all.sql new file mode 100644 index 0000000..91b02b4 --- /dev/null +++ b/Chapter07/compile_all.sql @@ -0,0 +1,19 @@ +set echo on; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +spool compile_all.txt; +@pl.prc +@debug_o.tps +@debug_ot.tab +@debug_o.tpb +@debug_ots.pks +@debug_ots.pkb +@.\solutions\debug_t.tab +@.\solutions\debug_ts.pks +@.\solutions\debug_ts.pkb +spool off; +set echo off; +@ci.sql +@ci.sql diff --git a/Chapter07/debug_o.sql b/Chapter07/debug_o.sql new file mode 100644 index 0000000..2d6cc5a --- /dev/null +++ b/Chapter07/debug_o.sql @@ -0,0 +1,16 @@ +rem debug_o.sql +rem by Donald J. Bales on 12/15/2006 +rem A test unit for type DEBUG_O + +declare + +begin + DEBUG_O.set_text('DEBUG_O.SQL', 'before the loop'); + for i in 1..10 loop + DEBUG_O.set_text('DEBUG_O.SQL', 'loop '||to_char(i)||' before sleep'); + SYS.DBMS_LOCK.sleep(3); + DEBUG_O.set_text('DEBUG_O.SQL', 'loop '||to_char(i)||' after sleep'); + end loop; + DEBUG_O.set_text('DEBUG_O.SQL:', 'after the loop'); +end; +/ diff --git a/Chapter07/debug_o.tpb b/Chapter07/debug_o.tpb new file mode 100644 index 0000000..42e504e --- /dev/null +++ b/Chapter07/debug_o.tpb @@ -0,0 +1,111 @@ +create or replace type body DEBUG_O as +/* +debug_o.tpb +by Donald Bales on 12/15/2006 +Type DEBUG_O's implementation +A type for logging debug information +*/ + +STATIC FUNCTION get_id +return number is + +n_id number; + +begin + select DEBUG_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +CONSTRUCTOR FUNCTION debug_o( +self in out nocopy debug_o) +return self as result is + +begin + pl('debug_o(zero param)'); + self.id := NULL; + self.text := NULL; + self.unique_session_id := NULL; + self.insert_user := NULL; + self.insert_date := NULL; + + return; +end debug_o; + + +CONSTRUCTOR FUNCTION debug_o( +self in out nocopy debug_o, +ain_id in number, +aiv_text in varchar2) +return self as result is + +begin + pl('debug_o(two params)'); + self.id := ain_id; + self.text := aiv_text; + self.unique_session_id := SYS.DBMS_SESSION.unique_session_id; + self.insert_user := USER; + self.insert_date := SYSDATE; + + return; +end debug_o; + + +-- Override the default constructor. To do so, you must +-- use the same attributes names for the parameter names +-- and use them in the order specified in the type spec. +CONSTRUCTOR FUNCTION debug_o( +self in out nocopy debug_o, +id in number, +text in varchar2, +unique_session_id in varchar2, +insert_user in varchar2, +insert_date in date) +return self as result is + +begin + pl('debug_o(five params)'); + self.id := id; + self.text := text; + self.unique_session_id := unique_session_id; + self.insert_user := insert_user; + self.insert_date := insert_date; + + return; +end debug_o; + + +STATIC PROCEDURE set_text( +aiv_program_unit in varchar2, +aiv_text in varchar2) is + +pragma autonomous_transaction; + +v_text varchar2(256); + +begin + v_text := substrb(aiv_program_unit||': '||aiv_text, 1, 256); + + insert into DEBUG_OT + values (DEBUG_O(DEBUG_ID_SEQ.nextval, aiv_text)); +-- A defect in SQL prevents me from using the function +-- get_id() as follows: +--values (DEBUG_O(DEBUG_O.get_id(), aiv_text)); + commit; +end set_text; + + +MAP MEMBER FUNCTION to_map +return number is + +begin + return id; +end to_map; + + +end; +/ +@be.sql DEBUG_O diff --git a/Chapter07/debug_o.tps b/Chapter07/debug_o.tps new file mode 100644 index 0000000..41995c2 --- /dev/null +++ b/Chapter07/debug_o.tps @@ -0,0 +1,47 @@ +execute drop_if_exists('table','DEBUG_OT'); +execute drop_if_exists('view','DEBUG_OV'); +execute drop_if_exists('type','DEBUG_O'); +create type DEBUG_O as object ( +/* +debug_o.tps +by Donald Bales on 12/15/2006 +Type DEBUG_O's specification: +A type for logging debug information +*/ +id number, +text varchar2(256), +unique_session_id varchar2(24), +insert_user varchar2(30), +insert_date date, +-- Get the next primary key value +STATIC FUNCTION get_id +return number, +-- A NULL values constructor +CONSTRUCTOR FUNCTION debug_o( +self in out nocopy debug_o) +return self as result, +-- A convenience constructor +CONSTRUCTOR FUNCTION debug_o( +self in out nocopy debug_o, +ain_id in number, +aiv_text in varchar2) +return self as result, +-- Override the default constructor +CONSTRUCTOR FUNCTION debug_o( +self in out nocopy debug_o, +id in number, +text in varchar2, +unique_session_id in varchar2, +insert_user in varchar2, +insert_date in date) +return self as result, +-- Write to the debug object table +STATIC PROCEDURE set_text( +aiv_program_unit in varchar2, +aiv_text in varchar2), +-- A map function +MAP MEMBER FUNCTION to_map +return number +) not final; +/ +@se.sql diff --git a/Chapter07/debug_ot.sql b/Chapter07/debug_ot.sql new file mode 100644 index 0000000..779cacd --- /dev/null +++ b/Chapter07/debug_ot.sql @@ -0,0 +1,12 @@ +rem debug_ot.sql +rem by Donald J. Bales on 12/15/2006 +rem Query DEBUG_OT the specified unique session ID + +define unique_session_id=&1; + +select id, + text +from DEBUG_OT +where unique_session_id = upper('&unique_session_id') +and insert_date > SYSDATE - (10/(24*60)) +order by id; diff --git a/Chapter07/debug_ot.tab b/Chapter07/debug_ot.tab new file mode 100644 index 0000000..7b8b284 --- /dev/null +++ b/Chapter07/debug_ot.tab @@ -0,0 +1,24 @@ +rem debug_ot.tab +rem by Donald Bales on 12/15/2006 +rem Create debugging message table + +execute drop_if_exists('table','DEBUG_OT'); +create table DEBUG_OT of DEBUG_O +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +alter table DEBUG_OT add +constraint DEBUG_OT_PK +primary key ( +id ) +using index +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +execute drop_if_exists('sequence','DEBUG_ID_SEQ'); +create sequence DEBUG_ID_SEQ +start with 1 order; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'DEBUG_OT'); + +grant all on DEBUG_OT to PUBLIC; diff --git a/Chapter07/debug_ots.pkb b/Chapter07/debug_ots.pkb new file mode 100644 index 0000000..8ea2273 --- /dev/null +++ b/Chapter07/debug_ots.pkb @@ -0,0 +1,61 @@ +create or replace package body DEBUG_OTS as +/* +debug_ots.pkb +by Donald J. Bales on 12/15/2006 +Object Table DEBUG_OT's package +*/ + +-- Declare a table type and then table to hold the +-- enabled program units +TYPE program_unit_table is table of varchar2(1) +index by varchar2(30); + +t_program_unit program_unit_table; + + +PROCEDURE disable( +aiv_program_unit in varchar2) is + +v_program_unit varchar2(30); + +begin + v_program_unit := upper(aiv_program_unit); + + if t_program_unit.exists(v_program_unit) then + t_program_unit.delete(v_program_unit); + end if; +end disable; + + +PROCEDURE enable( +aiv_program_unit in varchar2) is + +v_program_unit varchar2(30); + +begin + v_program_unit := upper(aiv_program_unit); + + if not t_program_unit.exists(v_program_unit) then + t_program_unit(v_program_unit) := NULL; + end if; +end enable; + + +PROCEDURE set_text( +aiv_program_unit in varchar2, +aiv_text in DEBUG_OT.text%TYPE) is + +v_program_unit varchar2(30); + +begin + v_program_unit := upper(aiv_program_unit); + + if t_program_unit.exists(v_program_unit) then + DEBUG_O.set_text(v_program_unit, aiv_text); + end if; +end set_text; + + +end DEBUG_OTS; +/ +@be.sql DEBUG_OTS; diff --git a/Chapter07/debug_ots.pks b/Chapter07/debug_ots.pks new file mode 100644 index 0000000..4264282 --- /dev/null +++ b/Chapter07/debug_ots.pks @@ -0,0 +1,25 @@ +create or replace package DEBUG_OTS as +/* +debug_ots.pks +by Donald J. Bales on 12/15/2006 +Object Table DEBUG_OT's package +*/ + +-- Disable debug logging for the specified program unit +PROCEDURE disable( +aiv_program_unit in varchar2); + +-- Enable debug logging for the specified program unit +PROCEDURE enable( +aiv_program_unit in varchar2); + +-- Conditionally log the debug information for the specified +-- program unit, if it is enabled +PROCEDURE set_text( +aiv_program_unit in varchar2, +aiv_text in DEBUG_OT.text%TYPE); + + +end DEBUG_OTS; +/ +@se.sql DEBUG_OTS; diff --git a/Chapter07/debug_ots.sql b/Chapter07/debug_ots.sql new file mode 100644 index 0000000..542639f --- /dev/null +++ b/Chapter07/debug_ots.sql @@ -0,0 +1,30 @@ +rem debug_ots.sql +rem by Donald J. Bales on 12/15/2006 +rem A test unit for type DEBUG_O's package + +declare + +begin + -- Enable debug output + DEBUG_OTS.enable('DEBUG_OTS.SQL'); + -- Test + DEBUG_OTS.set_text('DEBUG_OTS.SQL', 'before the loop '); + for i in 1..10 loop + DEBUG_OTS.set_text('DEBUG_OTS.SQL', 'loop '||to_char(i)||' before sleep'); + SYS.DBMS_LOCK.sleep(3); + DEBUG_OTS.set_text('DEBUG_OTS.SQL', 'loop '||to_char(i)||' after sleep'); + end loop; + DEBUG_OTS.set_text('DEBUG_OTS.SQL', 'after the loop '); + + -- Disable debug output + DEBUG_OTS.disable('DEBUG_OTS.SQL'); + -- Test + DEBUG_OTS.set_text('DEBUG_OTS.SQL', 'before the loop '); + for i in 1..10 loop + DEBUG_OTS.set_text('DEBUG_OTS.SQL', 'loop '||to_char(i)||' before sleep'); + -- SYS.DBMS_LOCK.sleep(3); + DEBUG_OTS.set_text('DEBUG_OTS.SQL', 'loop '||to_char(i)||' after sleep'); + end loop; + DEBUG_OTS.set_text('DEBUG_OTS.SQL', 'after the loop '); +end; +/ diff --git a/Chapter07/desc.sql b/Chapter07/desc.sql new file mode 100644 index 0000000..45206dc --- /dev/null +++ b/Chapter07/desc.sql @@ -0,0 +1,6 @@ +define table_name="&1"; +set linesize 78; +prompt &table_name +desc &table_name +set linesize 1000; +undefine table_name \ No newline at end of file diff --git a/Chapter07/fe.sql b/Chapter07/fe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter07/fe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter07/is_profiler.sql b/Chapter07/is_profiler.sql new file mode 100644 index 0000000..5829024 --- /dev/null +++ b/Chapter07/is_profiler.sql @@ -0,0 +1,72 @@ +rem is_profiler.sql +rem by Donaled J. Bales on 12/15/2006 +rem Check to see if the profiler is installed and accessible + +declare + +n_major number; +n_minor number; +n_package number; +n_local number; +n_global number; + +begin + select count(1) + into n_package + from SYS.ALL_OBJECTS + where object_type = 'PACKAGE' + and object_name = 'DBMS_PROFILER' + and owner = 'SYS'; + + if n_package > 0 then + SYS.DBMS_PROFILER.get_version(n_major, n_minor); + + pl('DBMS_PROFILER Version '|| + to_char(n_major)||'.'|| + to_char(n_minor)); + + pl('DBMS_PROFILER.internal_version_check = '|| + to_char(SYS.DBMS_PROFILER.internal_version_check)); + else + pl('Sorry, either the profile does not exist, or you'|| + 'don''t have access to it. Contact your DBA!'); + end if; + + select count(1) + into n_local + from SYS.ALL_OBJECTS + where object_type = 'TABLE' + and object_name in ( + 'PLSQL_PROFILER_RUNS', + 'PLSQL_PROFILER_UNITS', + 'PLSQL_PROFILER_DATA') + and owner = USER; + + if n_local = 3 then + pl('You have access to locally defined profiler tables '|| + 'for your current username: '||USER); + end if; + + select count(1) + into n_global + from SYS.ALL_OBJECTS + where object_type = 'TABLE' + and object_name in ( + 'PLSQL_PROFILER_RUNS', + 'PLSQL_PROFILER_UNITS', + 'PLSQL_PROFILER_DATA') + and owner = 'SYS'; + + if n_global = 3 then + pl('You have access to gloablly defined profiler tables '|| + 'under username SYS'); + end if; + + if n_local <> 3 and + n_global <> 3 then + pl('Sorry, either the profile tables do not exist, or you'|| + 'don''t have access to them. Contact your DBA!'); + end if; + +end; +/ diff --git a/Chapter07/login.sql b/Chapter07/login.sql new file mode 100644 index 0000000..7767015 --- /dev/null +++ b/Chapter07/login.sql @@ -0,0 +1,10 @@ +rem login.sql +rem by Donaled J. Bales on 12/15/2006 +rem Set my default SQL*Plus environment +set linesize 1000; +set newpage 1; +set pagesize 32767; +set serveroutput on size 1000000; +set trimspool on; +alter session set nls_date_format = 'SYYYYMMDD HH24MISS'; +prompt BPS' default settings loaded successfully! diff --git a/Chapter07/ord_profile.sql b/Chapter07/ord_profile.sql new file mode 100644 index 0000000..896792b --- /dev/null +++ b/Chapter07/ord_profile.sql @@ -0,0 +1,53 @@ +rem ord_profile.sql +rem by Donald J. Bales on 12/15/2006 +rem Create a DBMS_PROFILER report by program unit and line number + +define runid="&1"; + +column avg_time format 9999999; +column line# format 9999; +column occur format 9999 +column text format a40 trunc; +column unit_name format a13; + +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +set verify off; + +spool ord_profile_&runid..txt; + +select v.unit_name, + v.avg_time, + v.occur, + v.line#, + ltrim(s.text) text +from SYS.DBA_SOURCE s, + ( select u.unit_owner, + u.unit_type, + u.unit_name, + d.min_time, + to_number(decode(d.total_occur, + NULL, NULL, + 0, 0, + round(d.total_time/d.total_occur))) avg_time, + d.max_time, + d.total_time, + d.total_occur occur, + d.line# + from PLSQL_PROFILER_UNITS u, + PLSQL_PROFILER_DATA d + where u.runid = d.runid + and u.unit_number = d.unit_number + and d.runid = &runid ) v +where v.unit_owner = s.owner(+) +and v.unit_type = s.type(+) +and v.unit_name = s.name(+) +and v.line# = s.line(+) +order by v.unit_name, + v.line#; + +spool off; + +set verify on; diff --git a/Chapter07/pe.sql b/Chapter07/pe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter07/pe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter07/pl.prc b/Chapter07/pl.prc new file mode 100644 index 0000000..10b8e34 --- /dev/null +++ b/Chapter07/pl.prc @@ -0,0 +1,14 @@ +create or replace PROCEDURE pl( +aiv_text in varchar2 ) is +/* +pl.prc +by Donald J. Bales on 12/15/2006 +A wrapper procedure for SYS.DBMS_OUTPUT.put_line() +for the lazy typist. +*/ + +begin + SYS.DBMS_OUTPUT.put_line(aiv_text); +end pl; +/ +@pe.sql pl diff --git a/Chapter07/profile.sql b/Chapter07/profile.sql new file mode 100644 index 0000000..110eca9 --- /dev/null +++ b/Chapter07/profile.sql @@ -0,0 +1,34 @@ +define runid="&1"; +column text format a80 trunc; +select v.unit_name, + v.min_time, + v.avg_time, + v.max_time, + v.total_time, + v.total_occur, + v.line#, + s.text +from SYS.DBA_SOURCE s, + ( select u.unit_owner, + u.unit_type, + u.unit_name, + d.min_time, + to_number(decode(d.total_occur, + NULL, NULL, + 0, 0, + round(d.total_time/d.total_occur))) avg_time, + d.max_time, + d.total_time, + d.total_occur, + d.line# + from PLSQL_PROFILER_UNITS u, + PLSQL_PROFILER_DATA d + where u.runid = d.runid + and u.unit_number = d.unit_number + and d.runid = &runid ) v +where v.unit_owner = s.owner(+) +and v.unit_type = s.type(+) +and v.unit_name = s.name(+) +and v.line# = s.line(+) +order by 1, 2; + diff --git a/Chapter07/profiler.sql b/Chapter07/profiler.sql new file mode 100644 index 0000000..1c0684b --- /dev/null +++ b/Chapter07/profiler.sql @@ -0,0 +1,15 @@ +declare + +n_major number; +n_minor number; + +begin + DBMS_PROFILER.get_version(n_major, n_minor); + + pl('DBMS_PROFILER Version '|| + to_char(n_major)||'.'|| + to_char(n_minor)); + + pl(DBMS_PROFILER.internal_version_check); +end; +/ diff --git a/Chapter07/run_profile.sql b/Chapter07/run_profile.sql new file mode 100644 index 0000000..d0834f5 --- /dev/null +++ b/Chapter07/run_profile.sql @@ -0,0 +1,28 @@ +rem run_profile.sql +rem by Donald J. Bales on 12/15/2006 +rem Capture DBMS_PROFILER information for the specified script + +define script="&1"; + +set verify off; + +declare + +n_run_number number; + +begin + DBMS_PROFILER.start_profiler( + '&script'||' on '||to_char(SYSDATE, 'YYYYMMDD HH24MISS'), + ' ', + n_run_number); + + pl('DBMS_PROFILER run_number = '||to_char(n_run_number)); +end; +/ + +@&script + +execute DBMS_PROFILER.stop_profiler; +execute DBMS_PROFILER.flush_data; + +set verify on; diff --git a/Chapter07/se.sql b/Chapter07/se.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter07/se.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter07/select_worker_ot_equalto.sql b/Chapter07/select_worker_ot_equalto.sql new file mode 100644 index 0000000..83d4b2a --- /dev/null +++ b/Chapter07/select_worker_ot_equalto.sql @@ -0,0 +1,4 @@ +select * +from WORKER_OT +where name = 'DOE, JOHN J.' +order by 1; diff --git a/Chapter07/select_worker_ot_equalto.sql.pln b/Chapter07/select_worker_ot_equalto.sql.pln new file mode 100644 index 0000000..e890117 --- /dev/null +++ b/Chapter07/select_worker_ot_equalto.sql.pln @@ -0,0 +1,30 @@ + +Explained. + +Plan hash value: 2430037530 + +----------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | +----------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | 1 | 61 | +| 1 | SORT ORDER BY | | 1 | 61 | +| 2 | TABLE ACCESS BY INDEX ROWID| WORKER_OT | 1 | 61 | +|* 3 | INDEX RANGE SCAN | WORKER_OT_UK2 | 1 | | +----------------------------------------------------------------------- + +----------------------- +Cost (%CPU)| Time | +----------------------- + 5 (20)| 00:00:01 | + 5 (20)| 00:00:01 | + 4 (0)| 00:00:01 | + 3 (0)| 00:00:01 | +----------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("NAME"='DOE, JOHN J.') + +15 rows selected. + diff --git a/Chapter07/select_worker_ot_like.sql b/Chapter07/select_worker_ot_like.sql new file mode 100644 index 0000000..6afc9c1 --- /dev/null +++ b/Chapter07/select_worker_ot_like.sql @@ -0,0 +1,4 @@ +select * +from WORKER_OT +where name like 'DOE%' +order by 1; diff --git a/Chapter07/select_worker_ot_likepct.sql b/Chapter07/select_worker_ot_likepct.sql new file mode 100644 index 0000000..6afc9c1 --- /dev/null +++ b/Chapter07/select_worker_ot_likepct.sql @@ -0,0 +1,4 @@ +select * +from WORKER_OT +where name like 'DOE%' +order by 1; diff --git a/Chapter07/select_worker_ot_likepct.sql.pln b/Chapter07/select_worker_ot_likepct.sql.pln new file mode 100644 index 0000000..9880a47 --- /dev/null +++ b/Chapter07/select_worker_ot_likepct.sql.pln @@ -0,0 +1,31 @@ + +Explained. + +Plan hash value: 2430037530 + +----------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | +----------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | 1 | 61 | +| 1 | SORT ORDER BY | | 1 | 61 | +| 2 | TABLE ACCESS BY INDEX ROWID| WORKER_OT | 1 | 61 | +|* 3 | INDEX RANGE SCAN | WORKER_OT_UK2 | 1 | | +----------------------------------------------------------------------- + +----------------------- +Cost (%CPU)| Time | +----------------------- + 6 (17)| 00:00:01 | + 6 (17)| 00:00:01 | + 5 (0)| 00:00:01 | + 3 (0)| 00:00:01 | +----------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("NAME" LIKE 'DOE%') + filter("NAME" LIKE 'DOE%') + +16 rows selected. + diff --git a/Chapter07/select_worker_ot_pctlikepct.sql b/Chapter07/select_worker_ot_pctlikepct.sql new file mode 100644 index 0000000..391dd1b --- /dev/null +++ b/Chapter07/select_worker_ot_pctlikepct.sql @@ -0,0 +1,4 @@ +select * +from WORKER_OT +where name like '%DOE%' +order by 1; diff --git a/Chapter07/select_worker_ot_pctlikepct.sql.pln b/Chapter07/select_worker_ot_pctlikepct.sql.pln new file mode 100644 index 0000000..98029d2 --- /dev/null +++ b/Chapter07/select_worker_ot_pctlikepct.sql.pln @@ -0,0 +1,20 @@ + +Explained. + +Plan hash value: 2955220684 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | 13026 | 775K| | 1022 (3)| 00:00:13 | +| 1 | SORT ORDER BY | | 13026 | 775K| 2168K| 1022 (3)| 00:00:13 | +|* 2 | TABLE ACCESS FULL| WORKER_OT | 13026 | 775K| | 824 (4)| 00:00:10 | +---------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("NAME" LIKE '%DOE%') + +14 rows selected. + diff --git a/Chapter07/select_worker_ot_pctlikepct2.sql b/Chapter07/select_worker_ot_pctlikepct2.sql new file mode 100644 index 0000000..0ddee84 --- /dev/null +++ b/Chapter07/select_worker_ot_pctlikepct2.sql @@ -0,0 +1,5 @@ +select /*+ INDEX(WORKER_OT WORKER_OT_UK2) */ + * +from WORKER_OT +where name like '%DOE%' +order by 1; diff --git a/Chapter07/select_worker_ot_pctlikepct2.sql.pln b/Chapter07/select_worker_ot_pctlikepct2.sql.pln new file mode 100644 index 0000000..c6f9fdb --- /dev/null +++ b/Chapter07/select_worker_ot_pctlikepct2.sql.pln @@ -0,0 +1,30 @@ + +Explained. + +Plan hash value: 4066707113 + +------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes |TempSpc| +------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | 13026 | 775K| | +| 1 | SORT ORDER BY | | 13026 | 775K| 2168K| +| 2 | TABLE ACCESS BY INDEX ROWID| WORKER_OT | 13026 | 775K| | +|* 3 | INDEX FULL SCAN | WORKER_OT_UK2 | 12364 | | | +------------------------------------------------------------------------------- + +----------------------- +Cost (%CPU)| Time | +----------------------- +14877 (1)| 00:02:59 | +14877 (1)| 00:02:59 | +14679 (1)| 00:02:57 | + 1635 (1)| 00:00:20 | +----------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("NAME" LIKE '%DOE%') + +15 rows selected. + diff --git a/Chapter07/solutions/debug_t.sql b/Chapter07/solutions/debug_t.sql new file mode 100644 index 0000000..fbfd34d --- /dev/null +++ b/Chapter07/solutions/debug_t.sql @@ -0,0 +1,23 @@ +define unique_session_id=&1; + +set feedback off; + +declare + +cursor c1( +ain_id in number, +aiv_unique_session_id in varchar2) is +select id, + text +from DEBUG_T +where id > ain_id +and unique_session_id = upper(aiv_unique_session_id) +order by id; + +begin + for r1 in c1(DEBUG_TS.n_id, '&unique_session_id') loop + pl(r1.text); + DEBUG_TS.n_id := r1.id; + end loop; +end; +/ diff --git a/Chapter07/solutions/debug_t.tab b/Chapter07/solutions/debug_t.tab new file mode 100644 index 0000000..fdf7694 --- /dev/null +++ b/Chapter07/solutions/debug_t.tab @@ -0,0 +1,29 @@ +rem debug_t.tab +rem by Donald Bales on 12/15/2006 +rem Create debugging message table + +drop table DEBUG_T; +create table DEBUG_T ( +id number not null, +text varchar2(256), +unique_session_id varchar2(24) not null, +insert_user varchar2(30) default USER not null, +insert_date date default SYSDATE not null ) +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +alter table DEBUG_T add +constraint DEBUG_T_PK +primary key ( +id ) +using index +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +drop sequence DEBUG_ID_SEQ; +create sequence DEBUG_ID_SEQ +start with 1 order; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'DEBUG_T'); + +grant all on DEBUG_T to PUBLIC; diff --git a/Chapter07/solutions/debug_ts.pkb b/Chapter07/solutions/debug_ts.pkb new file mode 100644 index 0000000..7c69cf1 --- /dev/null +++ b/Chapter07/solutions/debug_ts.pkb @@ -0,0 +1,85 @@ +create or replace package body DEBUG_TS as +/* +debug_ts.pkb +by Donald J. Bales on 12/15/2006 +Table DEBUG_T's package +*/ + +-- A table to hold the list of program units for which +-- to store debug information +TYPE program_unit_table is table of varchar2(1) +index by varchar2(30); + +t_program_unit program_unit_table; + + +FUNCTION get_id +return DEBUG_T.id%TYPE is + +n_id DEBUG_T.id%TYPE; + +begin + select DEBUG_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +PROCEDURE disable( +aiv_program_unit in varchar2) is + +v_program_unit varchar2(30); + +begin + v_program_unit := upper(aiv_program_unit); + + if t_program_unit.exists(v_program_unit) then + t_program_unit.delete(v_program_unit); + end if; +end disable; + + +PROCEDURE enable( +aiv_program_unit in varchar2) is + +v_program_unit varchar2(30); + +begin + v_program_unit := upper(aiv_program_unit); + + if not t_program_unit.exists(v_program_unit) then + t_program_unit(v_program_unit) := NULL; + end if; +end enable; + + +PROCEDURE set_text( +aiv_program_unit in varchar2, +aiv_text in DEBUG_T.text%TYPE) is + +pragma autonomous_transaction; + +v_program_unit varchar2(30); + +begin + v_program_unit := upper(aiv_program_unit); + + if t_program_unit.exists(v_program_unit) then + insert into DEBUG_T ( + id, + text, + unique_session_id ) + values ( + DEBUG_TS.get_id(), + substrb(v_program_unit||': '||aiv_text, 1, 256), + SYS.DBMS_SESSION.unique_session_id); + end if; + commit; +end set_text; + + +end DEBUG_TS; +/ +@be.sql DEBUG_TS; diff --git a/Chapter07/solutions/debug_ts.pks b/Chapter07/solutions/debug_ts.pks new file mode 100644 index 0000000..98ddc30 --- /dev/null +++ b/Chapter07/solutions/debug_ts.pks @@ -0,0 +1,28 @@ +create or replace package DEBUG_TS as +/* +debug_ts.pks +by Donald J. Bales on 12/15/2006 +Table DEBUG_T's package +*/ + +-- Gets the next primary key value for the table +FUNCTION get_id +return DEBUG_T.id%TYPE; + +-- Enable debug output for the specified program unit +PROCEDURE enable( +aiv_program_unit in varchar2); + +-- Disable debug output for the specified program unit +PROCEDURE disable( +aiv_program_unit in varchar2); + +-- Log debug output if enabled for the specified program unit +PROCEDURE set_text( +aiv_program_unit in varchar2, +aiv_text in DEBUG_T.text%TYPE); + + +end DEBUG_TS; +/ +@se.sql DEBUG_TS; diff --git a/Chapter07/solutions/debug_ts.sql b/Chapter07/solutions/debug_ts.sql new file mode 100644 index 0000000..ea22335 --- /dev/null +++ b/Chapter07/solutions/debug_ts.sql @@ -0,0 +1,28 @@ +rem debug_ts.sql +rem by Donald J. Bales on 12/15/2006 +rem Test unit for package DEBUG_TS + +declare + +v_program_unit varchar2(30) := + 'debug_ts.sql'; + +begin + DEBUG_TS.enable(v_program_unit); + DEBUG_TS.set_text(v_program_unit, 'before the loop '); + for i in 1..10 loop + DEBUG_TS.set_text(v_program_unit, 'loop '||to_char(i)||' before sleep'); + SYS.DBMS_LOCK.sleep(3); + DEBUG_TS.set_text(v_program_unit, 'loop '||to_char(i)||' after sleep'); + end loop; + DEBUG_TS.set_text(v_program_unit, 'after the loop '); + DEBUG_TS.disable(v_program_unit); + DEBUG_TS.set_text(v_program_unit, 'before the loop '); + for i in 1..10 loop + DEBUG_TS.set_text(v_program_unit, 'loop '||to_char(i)||' before sleep'); + -- SYS.DBMS_LOCK.sleep(3); + DEBUG_TS.set_text(v_program_unit, 'loop '||to_char(i)||' after sleep'); + end loop; + DEBUG_TS.set_text(v_program_unit, 'after the loop '); +end; +/ diff --git a/Chapter07/solutions/failure.sql b/Chapter07/solutions/failure.sql new file mode 100644 index 0000000..340b61d --- /dev/null +++ b/Chapter07/solutions/failure.sql @@ -0,0 +1,40 @@ +rem failure.sql +rem by Donald J. Bales on 12/15/2006 +rem a script that fails on purpose + +declare + +n_number number; +v_number varchar2(30); + +begin + pl('begin'); + + pl('before n_number assignment'); + + n_number := 1; + + pl('after n_number assignment'); + + pl('before v_number assignment'); + + v_number := 'two'; + + pl('after v_number assignment'); + + pl('before addition'); + begin + pl('n_number + v_number = '||to_char(n_number + to_number(v_number))); + exception + when OTHERS then + pl('n_number = '||to_char(n_number)); + pl('v_number = '||v_number); + raise_application_error(-20000, SQLERRM|| + ' on n_number + v_number'|| + ' in failure.sql'); + end; + pl('after addition'); + + pl('end'); +end; +/ diff --git a/Chapter07/solutions/worker_t_ins_insert_w_codes.sql b/Chapter07/solutions/worker_t_ins_insert_w_codes.sql new file mode 100644 index 0000000..f0a8113 --- /dev/null +++ b/Chapter07/solutions/worker_t_ins_insert_w_codes.sql @@ -0,0 +1,34 @@ +insert into WORKER_T ( + id, + worker_type_id, + external_id, + first_name, + middle_name, + last_name, + name, + birth_date, + gender_id) +select WORKER_ID_SEQ.nextval, + decode(mod(WORKER_ID_SEQ.currval, 2), + 0, c1.worker_type_id, c2.worker_type_id), + lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0'), + first_name, + letter||'.', + last_name, + WORKER_TS.get_formatted_name( + first_name, letter||'.', last_name), + DATES.random( + to_number(to_char(SYSDATE, 'YYYY')) - 65, + to_number(to_char(SYSDATE, 'YYYY')) - 18), + decode(gender_code, 'F', c3.gender_id, c4.gender_id) +from TOP_100_LAST_NAME, + TOP_100_FIRST_NAME, + A_THRU_Z, + WORKER_TYPE_T c1, + WORKER_TYPE_T c2, + GENDER_T c3, + GENDER_T c4 +where c1.code = 'E' +and c2.code = 'C' +and c3.code = 'F' +and c4.code = 'M'; diff --git a/Chapter07/solutions/worker_t_ins_insert_w_codes.sql.pln b/Chapter07/solutions/worker_t_ins_insert_w_codes.sql.pln new file mode 100644 index 0000000..2b06b99 --- /dev/null +++ b/Chapter07/solutions/worker_t_ins_insert_w_codes.sql.pln @@ -0,0 +1,67 @@ + +Explained. + +Plan hash value: 1896089370 + +--------------------------------------------------------------------- +| Id | Operation | Name | +--------------------------------------------------------------------- +| 0 | INSERT STATEMENT | | +| 1 | SEQUENCE | WORKER_ID_SEQ | +| 2 | MERGE JOIN CARTESIAN | | +| 3 | MERGE JOIN CARTESIAN | | +| 4 | NESTED LOOPS | | +| 5 | NESTED LOOPS | | +| 6 | NESTED LOOPS | | +| 7 | NESTED LOOPS | | +| 8 | TABLE ACCESS BY INDEX ROWID| GENDER_T | +|* 9 | INDEX UNIQUE SCAN | GENDER_UK | +| 10 | TABLE ACCESS BY INDEX ROWID| GENDER_T | +|* 11 | INDEX UNIQUE SCAN | GENDER_UK | +| 12 | TABLE ACCESS BY INDEX ROWID | WORKER_TYPE_T | +|* 13 | INDEX UNIQUE SCAN | WORKER_TYPE_UK | +| 14 | TABLE ACCESS BY INDEX ROWID | WORKER_TYPE_T | +|* 15 | INDEX UNIQUE SCAN | WORKER_TYPE_UK | +| 16 | INDEX FULL SCAN | A_THRU_Z_PK | +| 17 | BUFFER SORT | | +| 18 | INDEX FAST FULL SCAN | TOP_100_LAST_NAME_PK | +| 19 | BUFFER SORT | | +| 20 | INDEX FAST FULL SCAN | TOP_100_FIRST_NAME_PK | +--------------------------------------------------------------------- + +--------------------------------------- +Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------- + 260K| 8378K| 586 (1)| 00:00:08 | + | | | | + 260K| 8378K| 586 (1)| 00:00:08 | + 2600 | 65000 | 12 (0)| 00:00:01 | + 26 | 468 | 5 (0)| 00:00:01 | + 1 | 16 | 4 (0)| 00:00:01 | + 1 | 13 | 3 (0)| 00:00:01 | + 1 | 10 | 2 (0)| 00:00:01 | + 1 | 5 | 1 (0)| 00:00:01 | + 1 | | 0 (0)| 00:00:01 | + 1 | 5 | 1 (0)| 00:00:01 | + 1 | | 0 (0)| 00:00:01 | + 1 | 3 | 1 (0)| 00:00:01 | + 1 | | 0 (0)| 00:00:01 | + 1 | 3 | 1 (0)| 00:00:01 | + 1 | | 0 (0)| 00:00:01 | + 26 | 52 | 1 (0)| 00:00:01 | + 100 | 700 | 11 (0)| 00:00:01 | + 100 | 700 | 0 (0)| 00:00:01 | + 100 | 800 | 585 (1)| 00:00:08 | + 100 | 800 | 0 (0)| 00:00:01 | +--------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 9 - access("C4"."CODE"='M') + 11 - access("C3"."CODE"='F') + 13 - access("C2"."CODE"='C') + 15 - access("C1"."CODE"='E') + +35 rows selected. + diff --git a/Chapter07/solutions/worker_t_ins_insert_w_codes_timing.sql b/Chapter07/solutions/worker_t_ins_insert_w_codes_timing.sql new file mode 100644 index 0000000..504a6df --- /dev/null +++ b/Chapter07/solutions/worker_t_ins_insert_w_codes_timing.sql @@ -0,0 +1,70 @@ +rem worker_t_ins_insert_w_codes_timing.sql +rem by Donald J. Bales on 12/15/2006 +rem Seed the Worker table with the top 100 names +rem 100 last x 100 first x 26 middle = 260,000 entries + +set serveroutput on size 1000000; + +declare + +-- This is the number of seconds since midnight +-- I'll use it to profile my code's performance. +n_start number; + +-- I'll use this to keep track of the number of +-- rows inserted. +n_inserted number := 0; + +begin + -- Delete any existing entries + delete WORKER_T; + + commit; + + -- Use an INSERT INTO SELECT SQL statement + n_start := to_number(to_char(SYSDATE, 'SSSSS')); + + insert into WORKER_T ( + id, + worker_type_id, + external_id, + first_name, + middle_name, + last_name, + name, + birth_date, + gender_id) + select WORKER_ID_SEQ.nextval, + decode(mod(WORKER_ID_SEQ.currval, 2), + 0, c1.worker_type_id, c2.worker_type_id), + lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0'), + first_name, + letter||'.', + last_name, + WORKER_TS.get_formatted_name( + first_name, letter||'.', last_name), + DATES.random( + to_number(to_char(SYSDATE, 'YYYY')) - 65, + to_number(to_char(SYSDATE, 'YYYY')) - 18), + decode(gender_code, 'F', c3.gender_id, c4.gender_id) + from TOP_100_LAST_NAME, + TOP_100_FIRST_NAME, + A_THRU_Z, + WORKER_TYPE_T c1, + WORKER_TYPE_T c2, + GENDER_T c3, + GENDER_T c4 + where c1.code = 'E' + and c2.code = 'C' + and c3.code = 'F' + and c4.code = 'M'; + + n_inserted := n_inserted + sql%rowcount; + + pl(to_char(n_inserted)||' rows inserted in '|| + (to_number(to_char(SYSDATE, 'SSSSS')) - n_start)|| + ' seconds.'); + + commit; +end; +/ diff --git a/Chapter07/success.sql b/Chapter07/success.sql new file mode 100644 index 0000000..708328d --- /dev/null +++ b/Chapter07/success.sql @@ -0,0 +1,31 @@ +rem success.sql +rem by Donald J. Bales on 12/15/2006 +rem a script with success messages + +declare + +n_number number; + +begin + pl('begin'); + + n_number := -1; + + pl('No error here!'); + + n_number := 0; + + pl('Still no error here!'); + + n_number := 'one'; + + pl('After the error.'); + + pl('end'); +exception + when OTHERS then + raise_application_error(-20000, SQLERRM|| + ' on assigning a value to n_number'|| + ' in success.sql'); +end; +/ diff --git a/Chapter07/usi.sql b/Chapter07/usi.sql new file mode 100644 index 0000000..f2929da --- /dev/null +++ b/Chapter07/usi.sql @@ -0,0 +1,5 @@ +rem usi.sql +rem by Donald J. Bales on 12/15/2007 +rem Show me my unique session ID + +execute pl('unique_session_id='||SYS.DBMS_SESSION.unique_session_id); diff --git a/Chapter07/worker_t_ins_insert.sql b/Chapter07/worker_t_ins_insert.sql new file mode 100644 index 0000000..0c9a0c4 --- /dev/null +++ b/Chapter07/worker_t_ins_insert.sql @@ -0,0 +1,26 @@ +insert into WORKER_T ( + id, + worker_type_id, + external_id, + first_name, + middle_name, + last_name, + name, + birth_date, + gender_id) +select WORKER_ID_SEQ.nextval, + decode(mod(WORKER_ID_SEQ.currval, 2), + 0, -1, -2), + lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0'), + first_name, + letter||'.', + last_name, + WORKER_TS.get_formatted_name( + first_name, letter||'.', last_name), + DATES.random( + to_number(to_char(SYSDATE, 'YYYY')) - 65, + to_number(to_char(SYSDATE, 'YYYY')) - 18), + decode(gender_code, 'F', -1, -2) +from TOP_100_LAST_NAME, + TOP_100_FIRST_NAME, + A_THRU_Z; diff --git a/Chapter07/worker_t_ins_insert.sql.pln b/Chapter07/worker_t_ins_insert.sql.pln new file mode 100644 index 0000000..51f7e73 --- /dev/null +++ b/Chapter07/worker_t_ins_insert.sql.pln @@ -0,0 +1,35 @@ + +Explained. + +Plan hash value: 2041463127 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | +--------------------------------------------------------------------------- +| 0 | INSERT STATEMENT | | 260K| 4316K| +| 1 | SEQUENCE | WORKER_ID_SEQ | | | +| 2 | MERGE JOIN CARTESIAN | | 260K| 4316K| +| 3 | MERGE JOIN CARTESIAN | | 2600 | 23400 | +| 4 | INDEX FULL SCAN | A_THRU_Z_PK | 26 | 52 | +| 5 | BUFFER SORT | | 100 | 700 | +| 6 | INDEX FAST FULL SCAN| TOP_100_LAST_NAME_PK | 100 | 700 | +| 7 | BUFFER SORT | | 100 | 800 | +| 8 | INDEX FAST FULL SCAN | TOP_100_FIRST_NAME_PK | 100 | 800 | +--------------------------------------------------------------------------- + +----------------------- +Cost (%CPU)| Time | +----------------------- + 582 (1)| 00:00:07 | + | | + 582 (1)| 00:00:07 | + 8 (0)| 00:00:01 | + 1 (0)| 00:00:01 | + 7 (0)| 00:00:01 | + 0 (0)| 00:00:01 | + 581 (1)| 00:00:07 | + 0 (0)| 00:00:01 | +----------------------- + +15 rows selected. + diff --git a/Chapter07/worker_t_ins_insert_timing.sql b/Chapter07/worker_t_ins_insert_timing.sql new file mode 100644 index 0000000..765904f --- /dev/null +++ b/Chapter07/worker_t_ins_insert_timing.sql @@ -0,0 +1,76 @@ +rem worker_t_ins_insert_timing.sql +rem by Donald J. Bales on 12/15/2006 +rem Seed the Worker table with the top 100 names +rem 100 last x 100 first x 26 middle = 260,000 entries + +set serveroutput on size 1000000; + +declare + +-- This is the number of seconds since midnight +-- I'll use it to profile my code's performance. +n_start number; + +-- Here, I declare four psuedo-constants to hold the +-- ID values from the code tables, rather than look +-- them up repeatedly during the insert process. +n_G_FEMALE GENDER_T.gender_id%TYPE; +n_G_MALE GENDER_T.gender_id%TYPE; +n_WT_CONTRACTOR WORKER_TYPE_T.worker_type_id%TYPE; +n_WT_EMPLOYEE WORKER_TYPE_T.worker_type_id%TYPE; + +-- I'll use this to keep track of the number of +-- rows inserted. +n_inserted number := 0; + +begin + -- Get the ID values for the codes + n_G_FEMALE := GENDER_TS.get_id('F'); + n_G_MALE := GENDER_TS.get_id('M'); + n_WT_CONTRACTOR := WORKER_TYPE_TS.get_id('C'); + n_WT_EMPLOYEE := WORKER_TYPE_TS.get_id('E'); + + -- Delete any existing entries + delete WORKER_T; + + commit; + + -- Use an INSERT INTO SELECT SQL statement + n_start := to_number(to_char(SYSDATE, 'SSSSS')); + + insert into WORKER_T ( + id, + worker_type_id, + external_id, + first_name, + middle_name, + last_name, + name, + birth_date, + gender_id) + select WORKER_ID_SEQ.nextval, + decode(mod(WORKER_ID_SEQ.currval, 2), + 0, n_WT_EMPLOYEE, n_WT_CONTRACTOR), + lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0'), + first_name, + letter||'.', + last_name, + WORKER_TS.get_formatted_name( + first_name, letter||'.', last_name), + DATES.random( + to_number(to_char(SYSDATE, 'YYYY')) - 65, + to_number(to_char(SYSDATE, 'YYYY')) - 18), + decode(gender_code, 'F', n_G_FEMALE, n_G_MALE) + from TOP_100_LAST_NAME, + TOP_100_FIRST_NAME, + A_THRU_Z; + + n_inserted := n_inserted + sql%rowcount; + + pl(to_char(n_inserted)||' rows inserted in '|| + (to_number(to_char(SYSDATE, 'SSSSS')) - n_start)|| + ' seconds.'); + + commit; +end; +/ diff --git a/Chapter07/xp.sql b/Chapter07/xp.sql new file mode 100644 index 0000000..8b364aa --- /dev/null +++ b/Chapter07/xp.sql @@ -0,0 +1,28 @@ +rem xp.sql +rem by Donald J. Bales on 12/15/2006 +rem Display the execution plan for the last executed cursor + +define script="&1"; + +set linesize 1000; +set newpage 1; +set pagesize 0; +set trimspool on; +set verify off; + +EXPLAIN PLAN FOR +select 1 from DUAL; + +spool &script..pln; + +EXPLAIN PLAN FOR +@&script + +set echo off; + +select * from table(SYS.DBMS_XPLAN.DISPLAY); + +spool off; + +set pagesize 32767; +set verify on; diff --git a/Chapter08/README.txt b/Chapter08/README.txt new file mode 100644 index 0000000..fc722e9 --- /dev/null +++ b/Chapter08/README.txt @@ -0,0 +1,85 @@ +README.txt for Chapter 8 +by Donald J. Bales on 4/15/2007 + +OBJECT NAME DESCRIPTION +--------------------------------------- ------------------------------------- +be.sql Show package body compilation errors + +ci.sql Compile invalid objects + +data_length_histogram.sql Query to create a VARCHAR2 data + length histogram report + +data_length_histogram.txt A VARCHAR2 data length histogram + report + +desc.sql Describe an object + +fe.sql Show function compilation errors + +solutions\gender_ts.pkb Create table package GENDER_TS' body + +solutions\gender_ts.pks Create table package GENDER_TS' + specification + +solutions\last_test_o_results.sql Show the last test() methods' results + +solutions\last_test_o_results.txt The last test() methods' results + +last_test_results.sql Show the last test() methods' results + +last_test_results.txt The last test() methods' results + +logical_assignment_ts.pkb Create table package + LOGICAL_ASSIGNMENT_TS' body + +logical_assignment_ts.pks Create table package + LOGICAL_ASSIGNMENT_TS' specification + +logical_workplace_ts.pkb Create table package + LOGICAL_WORKPLACE_TS' body + +login.sql Set my SQL*Plus defaults + +pe.sql Show procedure compilation errors + +solutions\physical_assignment_ts.pkb Create table package + PHYSICAL_ASSIGNMENT_TS' body + +solutions\physical_assignment_ts.pks Create table package + PHYSICAL_ASSIGNMENT_TS' specification + +solutions\physical_workplace_ts.pkb Create table package + PHYSICAL_WORKPLACE_TS' body + +solutions\physical_workplace_ts.pks Create table package + PHYSICAL_WORKPLACE_TS' specification + +pl.sql Don's handy-dandy "put_line" + procedure + +se.sql Show package specification + compilation errors + +test.sql An anonymous PL/SQL block used to + execute all test() procedures in + all objects + +solutions\test_o.tpb Create TYPE TEST_O's body + +solutions\test_o.tps Create TYPE TEST_O's sepcification + +solutions\test_ot.tab Create object table TEST_OT + +test_t.tab Create table TEST_T + +test_ts.pkb Create table package TEST_TS' body + +test_ts.pks Create table package TEST_TS' + specification + +worker_type_ts.pkb Create table package WORKER_TYPE_TS' + body + +worker_type_ts.pks Create table package WORKER_TYPE_TS' + specification diff --git a/Chapter08/be.sql b/Chapter08/be.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter08/be.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter08/ci.sql b/Chapter08/ci.sql new file mode 100644 index 0000000..6dcc7e7 --- /dev/null +++ b/Chapter08/ci.sql @@ -0,0 +1,50 @@ +rem ci.sql +rem by Donald J. Bales on 12/15/2006 +rem Compile my invalid objects + +set feedback off; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +set serveroutput on size 1000000; + +spool ci.txt; +declare + +cursor c1 is +select object_type, + object_name +from SYS.USER_OBJECTS +where status = 'INVALID' +order by 1, 2; + +v_sql varchar2(100); + +begin + for r1 in c1 loop + begin + if r1.object_type = 'PACKAGE BODY' then + v_sql := 'alter PACKAGE '||r1.object_name||' compile BODY'; + elsif r1.object_type = 'TYPE BODY' then + v_sql := 'alter TYPE '||r1.object_name||' compile BODY'; + else + v_sql := 'alter '||r1.object_type||' '||r1.object_name||' compile'; + end if; + execute immediate v_sql; + pl(r1.object_type||' '||r1.object_name||' compiled successfully'); + exception + when OTHERS then + pl(SQLERRM||' on '||v_sql); + end; + end loop; +end; +/ + +spool off; + +set feedback on; + + + + \ No newline at end of file diff --git a/Chapter08/ci.txt b/Chapter08/ci.txt new file mode 100644 index 0000000..e69de29 diff --git a/Chapter08/compile_all.sql b/Chapter08/compile_all.sql new file mode 100644 index 0000000..235254f --- /dev/null +++ b/Chapter08/compile_all.sql @@ -0,0 +1,29 @@ +set echo on; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +spool compile_all.txt; +@pl.prc +@test_t.tab +@test_ts.pks +@test_ts.pkb +@logical_assignment_ts.pks +@logical_workplace_ts.pks +@worker_type_ts.pks +@logical_assignment_ts.pkb +@logical_workplace_ts.pkb +@worker_type_ts.pkb +@.\solutions\test_o.tps +@.\solutions\test_ot.tab +@.\solutions\test_o.tpb +@.\solutions\gender_ts.pks +@.\solutions\physical_assignment_ts.pks +@.\solutions\physical_workplace_ts.pks +@.\solutions\gender_ts.pkb +@.\solutions\physical_assignment_ts.pkb +@.\solutions\physical_workplace_ts.pkb +spool off; +set echo off; +@ci.sql +@ci.sql diff --git a/Chapter08/data_length_histogram.sql b/Chapter08/data_length_histogram.sql new file mode 100644 index 0000000..fe1403a --- /dev/null +++ b/Chapter08/data_length_histogram.sql @@ -0,0 +1,39 @@ +rem data_length_histogram.sql +rem by Donald J. Bales on 12/15/2006 +rem Create a histogram of VARCHAR2 data lengths in use + +column data_type format a13; + +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; + +spool data_length_histogram.txt; + +select column_name, + min(data_length) min, + avg(data_length) avg, + max(data_length) max, + count(1) occurs +from SYS.ALL_TAB_COLUMNS +where owner = USER +and data_type like 'VARCHAR%' +and table_name not in ( + 'AUTHOR', + 'AUTHOR_PUBLICATION', + 'A_THRU_Z', + 'DEBUG_OT', + 'DEBUG_T', + 'PLAN_TABLE', + 'PLSQL_PROFILER_RUNS', + 'PLSQL_PROFILER_UNITS', + 'PLSQL_PROFILER_DATA', + 'TOP_100_FIRST_NAME', + 'TOP_100_LAST_NAME' ) +group by column_name +order by max(data_length), + column_name +/ + +spool off; diff --git a/Chapter08/data_length_histogram.txt b/Chapter08/data_length_histogram.txt new file mode 100644 index 0000000..07b76c5 --- /dev/null +++ b/Chapter08/data_length_histogram.txt @@ -0,0 +1,21 @@ + +COLUMN_NAME MIN AVG MAX OCCURS +------------------------------ ---------- ---------- ---------- ---------- +LOGICAL_INDICATOR 1 1 1 1 +PHYSICAL_INDICATOR 1 1 1 1 +CAS_NUMBER 30 30 30 1 +CODE 30 30 30 10 +EXTERNAL_ID 30 30 30 2 +FIRST_NAME 30 30 30 2 +INSERT_USER 30 30 30 1 +LAST_NAME 30 30 30 2 +MIDDLE_NAME 30 30 30 2 +TEST 30 30 30 1 +DESCRIPTION 80 80 80 7 +ID_CONTEXT 100 100 100 2 +NAME 80 85.7142857 100 7 +TITLE 100 100 100 1 +NARRATIVE 2000 2000 2000 1 + +15 rows selected. + diff --git a/Chapter08/desc.sql b/Chapter08/desc.sql new file mode 100644 index 0000000..45206dc --- /dev/null +++ b/Chapter08/desc.sql @@ -0,0 +1,6 @@ +define table_name="&1"; +set linesize 78; +prompt &table_name +desc &table_name +set linesize 1000; +undefine table_name \ No newline at end of file diff --git a/Chapter08/fe.sql b/Chapter08/fe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter08/fe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter08/last_test_results.sql b/Chapter08/last_test_results.sql new file mode 100644 index 0000000..dd34dc7 --- /dev/null +++ b/Chapter08/last_test_results.sql @@ -0,0 +1,35 @@ +rem last_test_results.sql +rem by Donald J. Bales on 12/15/2006 +rem Display the last test results + +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; + +column test format a34; +column t# format 99; +column description format a27; +column result format a7; + +spool last_test_results.txt; + +select t.object_name|| + decode(substr(t.method_name, -1, 1), ')', '.', ' ')|| + t.method_name test, + t.test_number t#, + t.description, + t.result +from TEST_T t +where t.unique_session_id = SYS.DBMS_SESSION.unique_session_id +and t.object_name = ( +select e.object_name +from TEST_T e +where e.unique_session_id = SYS.DBMS_SESSION.unique_session_id +and e.id = ( +select max(x.id) +from TEST_T x +where x.unique_session_id = SYS.DBMS_SESSION.unique_session_id)) +order by t.test_id; + +spool off; diff --git a/Chapter08/last_test_results.txt b/Chapter08/last_test_results.txt new file mode 100644 index 0000000..5c9e400 --- /dev/null +++ b/Chapter08/last_test_results.txt @@ -0,0 +1,66 @@ + +TEST T# DESCRIPTION RESULT +---------------------------------- --- --------------------------- ------- +LOGICAL_ASSIGNMENT_TS DELETE 0 Delete existing test entrie OK + s from LOGICAL_ASSIGNMENT_T + +LOGICAL_ASSIGNMENT_TS DELETE 1 Delete existing test entrie OK + s from LOGICAL_WORKPLACE_T + +LOGICAL_ASSIGNMENT_TS DELETE 2 Delete existing test entrie OK + s from WORKER_T + +LOGICAL_ASSIGNMENT_TS INSERT 3 Insert WORKER_T test entrie OK + s using set_row() + +LOGICAL_ASSIGNMENT_TS INSERT 4 Insert LOGICAL_WORKPLACE_T OK + test entries using set_row( + ) + +LOGICAL_ASSIGNMENT_TS.GET_ID() 5 Allocate the next primary k OK + ey value using get_id() + +LOGICAL_ASSIGNMENT_TS.SET_ROW() 6 Insert history for v_TEST_3 OK + 0 using set_row() + +LOGICAL_ASSIGNMENT_TS.SET_ROW() 7 Insert history for V_TEST_3 OK + 0_1 using set_row() + +LOGICAL_ASSIGNMENT_TS.SET_ROW() 8 Insert history for V_TEST_3 OK + 0_2 using set_row() + +LOGICAL_ASSIGNMENT_TS.GET_LOGICAL_ 9 Get the current logical wor OK +WORKPLACE() kplace for v_TEST_30 + +LOGICAL_ASSIGNMENT_TS.GET_LOGICAL_ 10 Get the logical workplace o OK +WORKPLACE() n 6/30/1995 for v_TEST_30_1 + +LOGICAL_ASSIGNMENT_TS.GET_LOGICAL_ 11 Get the logical workplace o OK +WORKPLACE() n 6/30/1995 for v_TEST_30_2 + +LOGICAL_ASSIGNMENT_TS.HELP() 12 Test help() OK +LOGICAL_ASSIGNMENT_TS.IS_ACTIVE() 13 Is there an active assignme OK + nt on 6/30/1995 for v_TEST_ + 30? + +LOGICAL_ASSIGNMENT_TS.IS_ACTIVE() 14 Is there an active assignme OK + nt on 6/30/1995 for v_TEST_ + 30_1? + +LOGICAL_ASSIGNMENT_TS.IS_ACTIVE() 15 Is there currently an activ OK + e assignment for v_TEST_30_ + 2? + +LOGICAL_ASSIGNMENT_TS DELETE 16 Delete existing test entrie OK + s from LOGICAL_ASSIGNMENT_T + +LOGICAL_ASSIGNMENT_TS DELETE 17 Delete existing test entrie OK + s from LOGICAL_WORKPLACE_T + +LOGICAL_ASSIGNMENT_TS DELETE 18 Delete existing test entrie OK + s from WORKER_T + +LOGICAL_ASSIGNMENT_TS SUCCESS + +20 rows selected. + diff --git a/Chapter08/logical_assignment_ts.pkb b/Chapter08/logical_assignment_ts.pkb new file mode 100644 index 0000000..afc3c0d --- /dev/null +++ b/Chapter08/logical_assignment_ts.pkb @@ -0,0 +1,670 @@ +create or replace PACKAGE BODY LOGICAL_ASSIGNMENT_TS as +/* +logical_assignment_ts.pkb +by Donald J. Bales on 12/15/2006 +Table LOGICAL_ASSIGNMENT_T's methods +*/ + + +FUNCTION get_id +return LOGICAL_ASSIGNMENT_T.id%TYPE is + +n_id LOGICAL_ASSIGNMENT_T.id%TYPE; + +begin + select LOGICAL_ASSIGNMENT_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_logical_workplace( +ain_worker_id in LOGICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in LOGICAL_ASSIGNMENT_T.active_date%TYPE) +return LOGICAL_WORKPLACE_T%ROWTYPE is + +r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; + +begin + select * + into r_logical_workplace + from LOGICAL_WORKPLACE_T + where id = ( + select logical_workplace_id + from LOGICAL_ASSIGNMENT_T + where worker_id = ain_worker_id + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX) ); + + return r_logical_workplace; +end get_logical_workplace; + + +FUNCTION get_logical_workplace( +ain_worker_id in LOGICAL_ASSIGNMENT_T.worker_id%TYPE) +return LOGICAL_WORKPLACE_T%ROWTYPE is + +begin + return get_logical_workplace(ain_worker_id, SYSDATE); +end get_logical_workplace; + + +FUNCTION get_row( +air_logical_assignment in LOGICAL_ASSIGNMENT_T%ROWTYPE) +return LOGICAL_ASSIGNMENT_T%ROWTYPE is + +r_logical_assignment LOGICAL_ASSIGNMENT_T%ROWTYPE; + +begin + if air_logical_assignment.id is not NULL then + -- retrieve the row by the primary key + select * + into r_logical_assignment + from LOGICAL_ASSIGNMENT_T + where id = air_logical_assignment.id; + else + -- retrieve the row by the worker_id and active_date + select * + into r_logical_assignment + from LOGICAL_ASSIGNMENT_T + where worker_id = air_logical_assignment.worker_id + and active_date = air_logical_assignment.active_date; + end if; + return r_logical_assignment; +exception + when NO_DATA_FOUND then + raise; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select LOGICAL_ASSIGNMENT_T'|| + ' in LOGICAL_ASSIGNMENT_TS.get_row()'); +end get_row; + + +PROCEDURE help is + +begin + pl('No help yet!'); +end help; + + +FUNCTION is_active( +ain_worker_id in LOGICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in date) +return boolean is + +pragma AUTONOMOUS_TRANSACTION; + +n_count number; + +begin + select count(1) + into n_count + from LOGICAL_ASSIGNMENT_T + where worker_id = ain_worker_id + and aid_on between active_date + and nvl(inactive_date, DATES.d_MAX); + + if nvl(n_count,0) > 0 then + return TRUE; + else + return FALSE; + end if; + + commit; +end is_active; + + +FUNCTION is_active( +ain_worker_id in LOGICAL_ASSIGNMENT_T.worker_id%TYPE) +return boolean is + +begin + return is_active(ain_worker_id, SYSDATE); +end is_active; + + +PROCEDURE set_row( +aior_logical_assignment in out LOGICAL_ASSIGNMENT_T%ROWTYPE) is + +d_null constant date := DATES.d_MIN; +n_null constant number := 0; +v_null constant varchar2(1) := ' '; +r_logical_assignment LOGICAL_ASSIGNMENT_T%ROWTYPE; + +begin + -- get the existing row + begin + r_logical_assignment := get_row(aior_logical_assignment); + exception + when NO_DATA_FOUND then + r_logical_assignment := NULL; + end; + -- if a row exists, update it if needed + if r_logical_assignment.id is not NULL then + aior_logical_assignment.id := r_logical_assignment.id; + aior_logical_assignment.worker_id := r_logical_assignment.worker_id; + aior_logical_assignment.active_date := r_logical_assignment.active_date; + if nvl(r_logical_assignment.logical_workplace_id, n_null) <> nvl(aior_logical_assignment.logical_workplace_id, n_null) or + nvl(r_logical_assignment.inactive_date, d_null) <> nvl(aior_logical_assignment.inactive_date, d_null) then + begin + update LOGICAL_ASSIGNMENT_T + set logical_workplace_id = aior_logical_assignment.logical_workplace_id, + inactive_date = aior_logical_assignment.inactive_date + where id = aior_logical_assignment.id; + + n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20002, SQLERRM|| + ' on update LOGICAL_ASSIGNMENT_T'|| + ' in LOGICAL_ASSIGNMENT_TS.set_row()' ); + end; + end if; + else + -- add the row if it does not exist + begin + if aior_logical_assignment.id is NULL then + aior_logical_assignment.id := get_id(); + end if; + insert into LOGICAL_ASSIGNMENT_T ( + id, + worker_id, + logical_workplace_id, + active_date, + inactive_date ) + values ( + aior_logical_assignment.id, + aior_logical_assignment.worker_id, + aior_logical_assignment.logical_workplace_id, + aior_logical_assignment.active_date, + aior_logical_assignment.inactive_date ); + + n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20003, SQLERRM|| + ' on insert LOGICAL_ASSIGNMENT_T'|| + ' in LOGICAL_ASSIGNMENT_TS.set_row()' ); + end; + end if; +end set_row; + + +PROCEDURE test is + +n_logical_workplace_id LOGICAL_WORKPLACE_T.id%TYPE; +n_logical_workplace_id_1 LOGICAL_WORKPLACE_T.id%TYPE; +n_logical_workplace_id_2 LOGICAL_WORKPLACE_T.id%TYPE; +n_worker_id WORKER_T.id%TYPE; +n_worker_id_1 WORKER_T.id%TYPE; +n_worker_id_2 WORKER_T.id%TYPE; +r_worker WORKER_T%ROWTYPE; +r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; +r_logical_assignment LOGICAL_ASSIGNMENT_T%ROWTYPE; + +begin + pl('LOGICAL_ASSIGNMENT_TS.test()'); + + TEST_TS.clear('LOGICAL_ASSIGNMENT_TS'); + + -- In order to make entries into an Intersection table + -- you first have to have entries in the two tables + -- for which an entry will create an intersection + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'DELETE', 0, + 'Delete existing test entries from LOGICAL_ASSIGNMENT_T'); + begin + delete LOGICAL_ASSIGNMENT_T + where logical_workplace_id in ( + select logical_workplace_id + from LOGICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ) ); + + delete LOGICAL_ASSIGNMENT_T + where worker_id in ( + select worker_id + from WORKER_T + where external_id in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ) ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'DELETE', 1, + 'Delete existing test entries from LOGICAL_WORKPLACE_T'); + begin + delete LOGICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ); + + delete LOGICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30 ); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'DELETE', 2, + 'Delete existing test entries from WORKER_T'); + begin + delete WORKER_T + where external_id in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'INSERT', 3, + 'Insert WORKER_T test entries using set_row()'); + begin + r_worker.id := WORKER_TS.get_id(); + r_worker.worker_type_id := WORKER_TYPE_TS.get_id('E'); + r_worker.external_id := TEST_TS.v_TEST_30; + r_worker.first_name := TEST_TS.v_TEST_30; + r_worker.middle_name := TEST_TS.v_TEST_30; + r_worker.last_name := TEST_TS.v_TEST_30; + r_worker.name := WORKER_TS.get_formatted_name( + r_worker.first_name, + r_worker.middle_name, + r_worker.last_name); + r_worker.birth_date := to_date('19800101', 'YYYYMMDD'); + r_worker.gender_id := GENDER_TS.get_id('M'); + WORKER_TS.set_row(r_worker); + n_worker_id := r_worker.id; + + r_worker.id := WORKER_TS.get_id(); + r_worker.worker_type_id := WORKER_TYPE_TS.get_id('E'); + r_worker.external_id := TEST_TS.v_TEST_30_1; + r_worker.first_name := TEST_TS.v_TEST_30_1; + r_worker.middle_name := TEST_TS.v_TEST_30_1; + r_worker.last_name := TEST_TS.v_TEST_30_1; + r_worker.name := WORKER_TS.get_formatted_name( + r_worker.first_name, + r_worker.middle_name, + r_worker.last_name); + r_worker.birth_date := to_date('19700101', 'YYYYMMDD'); + r_worker.gender_id := GENDER_TS.get_id('F'); + WORKER_TS.set_row(r_worker); + n_worker_id_1 := r_worker.id; + + r_worker.id := WORKER_TS.get_id(); + r_worker.worker_type_id := WORKER_TYPE_TS.get_id('C'); + r_worker.external_id := TEST_TS.v_TEST_30_2; + r_worker.first_name := TEST_TS.v_TEST_30_2; + r_worker.middle_name := TEST_TS.v_TEST_30_2; + r_worker.last_name := TEST_TS.v_TEST_30_2; + r_worker.name := WORKER_TS.get_formatted_name( + r_worker.first_name, + r_worker.middle_name, + r_worker.last_name); + r_worker.birth_date := to_date('19600101', 'YYYYMMDD'); + r_worker.gender_id := GENDER_TS.get_id('M'); + WORKER_TS.set_row(r_worker); + n_worker_id_2 := r_worker.id; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'INSERT', 4, + 'Insert LOGICAL_WORKPLACE_T test entries using set_row()'); + begin + r_logical_workplace.id := + LOGICAL_WORKPLACE_TS.get_id(); + r_logical_workplace.parent_id := NULL; + r_logical_workplace.id_context := + LOGICAL_WORKPLACE_TS.create_id_context( + r_logical_workplace.parent_id, + r_logical_workplace.id); + r_logical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('C'); + r_logical_workplace.code := TEST_TS.v_TEST_30; + r_logical_workplace.name := TEST_TS.v_TEST_80; + r_logical_workplace.active_date := TEST_TS.d_TEST_19000101; + r_logical_workplace.inactive_date := NULL; + LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + n_logical_workplace_id := + r_logical_workplace.id; + + r_logical_workplace.id := + LOGICAL_WORKPLACE_TS.get_id(); + r_logical_workplace.parent_id := + n_logical_workplace_id; + r_logical_workplace.id_context := + LOGICAL_WORKPLACE_TS.create_id_context( + r_logical_workplace.parent_id, + r_logical_workplace.id); + r_logical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('B'); + r_logical_workplace.code := TEST_TS.v_TEST_30_1; + r_logical_workplace.name := TEST_TS.v_TEST_80; + r_logical_workplace.active_date := TEST_TS.d_TEST_19000101; + r_logical_workplace.inactive_date := NULL; + LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + n_logical_workplace_id_1 := + r_logical_workplace.id; + + r_logical_workplace.id := + LOGICAL_WORKPLACE_TS.get_id(); + r_logical_workplace.parent_id := + n_logical_workplace_id; + r_logical_workplace.id_context := + LOGICAL_WORKPLACE_TS.create_id_context( + r_logical_workplace.parent_id, + r_logical_workplace.id); + r_logical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('B'); + r_logical_workplace.code := TEST_TS.v_TEST_30_2; + r_logical_workplace.name := TEST_TS.v_TEST_80; + r_logical_workplace.active_date := TEST_TS.d_TEST_19000101; + r_logical_workplace.inactive_date := NULL; + LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + n_logical_workplace_id_2 := + r_logical_workplace.id; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Now that I have entries in the two tables being intersected + -- I can now start testing this package... + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'get_id()', 5, + 'Allocate the next primary key value using get_id()'); + begin + r_logical_assignment.id := + LOGICAL_ASSIGNMENT_TS.get_id(); + + if nvl(r_logical_assignment.id, 0) > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'set_row()', 6, + 'Insert history for v_TEST_30 using set_row()'); + begin + r_logical_assignment.worker_id := n_worker_id; + r_logical_assignment.logical_workplace_id := + n_logical_workplace_id_2; + r_logical_assignment.active_date := + to_date('20000101', 'YYYYMMDD'); + r_logical_assignment.inactive_date := NULL; + LOGICAL_ASSIGNMENT_TS.set_row(r_logical_assignment); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'set_row()', 7, + 'Insert history for V_TEST_30_1 using set_row()'); + begin + r_logical_assignment.id := + LOGICAL_ASSIGNMENT_TS.get_id(); + r_logical_assignment.worker_id := n_worker_id_1; + r_logical_assignment.logical_workplace_id := + n_logical_workplace_id_1; + r_logical_assignment.active_date := + to_date('19900101', 'YYYYMMDD'); + r_logical_assignment.inactive_date := + to_date('19991231', 'YYYYMMDD'); + LOGICAL_ASSIGNMENT_TS.set_row(r_logical_assignment); + + r_logical_assignment.id := + LOGICAL_ASSIGNMENT_TS.get_id(); + r_logical_assignment.worker_id := n_worker_id_1; + r_logical_assignment.logical_workplace_id := + n_logical_workplace_id_2; + r_logical_assignment.active_date := + to_date('20000101', 'YYYYMMDD'); + r_logical_assignment.inactive_date := NULL; + LOGICAL_ASSIGNMENT_TS.set_row(r_logical_assignment); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'set_row()', 8, + 'Insert history for V_TEST_30_2 using set_row()'); + begin + r_logical_assignment.id := + LOGICAL_ASSIGNMENT_TS.get_id(); + r_logical_assignment.worker_id := n_worker_id_2; + r_logical_assignment.logical_workplace_id := + n_logical_workplace_id_1; + r_logical_assignment.active_date := + to_date('19800101', 'YYYYMMDD'); + r_logical_assignment.inactive_date := + to_date('19891231', 'YYYYMMDD'); + LOGICAL_ASSIGNMENT_TS.set_row(r_logical_assignment); + + r_logical_assignment.id := + LOGICAL_ASSIGNMENT_TS.get_id(); + r_logical_assignment.worker_id := n_worker_id_2; + r_logical_assignment.logical_workplace_id := + n_logical_workplace_id_2; + r_logical_assignment.active_date := + to_date('19900101', 'YYYYMMDD'); + r_logical_assignment.inactive_date := + to_date('19901231', 'YYYYMMDD'); + LOGICAL_ASSIGNMENT_TS.set_row(r_logical_assignment); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Commit the deletes and inserts + commit; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', + 'get_logical_workplace()', 9, + 'Get the current logical workplace for v_TEST_30'); + begin + r_logical_workplace := NULL; + r_logical_workplace := get_logical_workplace(n_worker_id); + + if nvl(r_logical_workplace.id, 0) > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', + 'get_logical_workplace()', 10, + 'Get the logical workplace on 6/30/1995 for v_TEST_30_1'); + begin + r_logical_workplace := NULL; + r_logical_workplace := get_logical_workplace( + n_worker_id_1, + to_date('19950630', 'YYYYMMDD')); + + if nvl(r_logical_workplace.id, 0) > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', + 'get_logical_workplace()', 11, + 'Get the logical workplace on 6/30/1995 for v_TEST_30_2'); + begin + -- this should fail + r_logical_workplace := NULL; + r_logical_workplace := get_logical_workplace( + n_worker_id_2, + to_date('19950630', 'YYYYMMDD')); + + if nvl(r_logical_workplace.id, 0) > 0 then + TEST_TS.error(); + else + TEST_TS.ok(); + end if; + exception + when NO_DATA_FOUND then + TEST_TS.ok(); + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'help()', 12, + 'Test help()'); + begin + help(); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'is_active()', 13, + 'Is there an active assignment on 6/30/1995 for v_TEST_30?'); + -- No + begin + if is_active(n_worker_id, to_date('19950630', 'YYYYMMDD')) then + TEST_TS.error(); + else + TEST_TS.ok(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'is_active()', 14, + 'Is there an active assignment on 6/30/1995 for v_TEST_30_1?'); + -- Yes + begin + if is_active(n_worker_id_1, to_date('19950630', 'YYYYMMDD')) then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'is_active()', 15, + 'Is there currently an active assignment for v_TEST_30_2?'); + -- No + begin + if is_active(n_worker_id_2) then + TEST_TS.error(); + else + TEST_TS.ok(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Now clean up after the tests by deleting the test entries + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'DELETE', 16, + 'Delete existing test entries from LOGICAL_ASSIGNMENT_T'); + begin + delete LOGICAL_ASSIGNMENT_T + where logical_workplace_id in ( + select logical_workplace_id + from LOGICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ) ); + + delete LOGICAL_ASSIGNMENT_T + where worker_id in ( + select worker_id + from WORKER_T + where external_id in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ) ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'DELETE', 17, + 'Delete existing test entries from LOGICAL_WORKPLACE_T'); + begin + delete LOGICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ); + + delete LOGICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30 ); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'DELETE', 18, + 'Delete existing test entries from WORKER_T'); + begin + delete WORKER_T + where external_id in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + commit; + TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end LOGICAL_ASSIGNMENT_TS; +/ +@be.sql LOGICAL_ASSIGNMENT_TS diff --git a/Chapter08/logical_assignment_ts.pks b/Chapter08/logical_assignment_ts.pks new file mode 100644 index 0000000..704325c --- /dev/null +++ b/Chapter08/logical_assignment_ts.pks @@ -0,0 +1,102 @@ +create or replace PACKAGE LOGICAL_ASSIGNMENT_TS as +/* +logical_assignment_ts.pks +by Donald J. Bales on 12/15/2006 +Table LOGICAL_ASSIGNMENT_T's methods +*/ + +-- GLOBAL VARIABLES + +-- Keep track of the number of inserts and updates to made by set_row(). +n_inserted number := 0; +n_updated number := 0; + + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return LOGICAL_ASSIGNMENT_T.id%TYPE; + + +/* +Returns a the LOGICAL_WORKPLACE row for the specified worker_id and on the specified date. +*/ +FUNCTION get_logical_workplace( +ain_worker_id in LOGICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in LOGICAL_ASSIGNMENT_T.active_date%TYPE) +return LOGICAL_WORKPLACE_T%ROWTYPE; + + +/* +Returns a the current LOGICAL_WORKPLACE row for the specified worker_id. +*/ +FUNCTION get_logical_workplace( +ain_worker_id in LOGICAL_ASSIGNMENT_T.worker_id%TYPE) +return LOGICAL_WORKPLACE_T%ROWTYPE; + + +/* +Returns a LOGICAL_ASSIGNMENT row for the specified criteria. +
+There are two sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the woker_id and active_date
+
+If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_logical_assignment in LOGICAL_ASSIGNMENT_T%ROWTYPE) +return LOGICAL_ASSIGNMENT_T%ROWTYPE; + + +/* + Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + + +/* +Returns TRUE if the worker has a logical assignment on the specified date, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in LOGICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in date) +return boolean; + + +/* +Returns TRUE if the worker currently has a logical assignment, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in LOGICAL_ASSIGNMENT_T.worker_id%TYPE) +return boolean; + + +/* +Updates or inserts a row matching the passed row into table LOGICAL_WORKPLACE_T. +
+First, set_row( ) calls get_row( ) to try to find a matching row that already +exists in the database. So you need to set the id, or worked_id +and active_date appropriately in order to properly detect an existing row.
+
+Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise a new row is inserted, including the allocation of +a new primary key value. Upon inserting a new value, the id +value is updated in the passed row.
+See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_logical_assignment in out LOGICAL_ASSIGNMENT_T%ROWTYPE); + + +/* +The test unit for this package. +*/ +PROCEDURE test; + + +end LOGICAL_ASSIGNMENT_TS; +/ +@be.sql LOGICAL_ASSIGNMENT_TS diff --git a/Chapter08/logical_workplace_ts.pkb b/Chapter08/logical_workplace_ts.pkb new file mode 100644 index 0000000..69edede --- /dev/null +++ b/Chapter08/logical_workplace_ts.pkb @@ -0,0 +1,536 @@ +create or replace PACKAGE BODY LOGICAL_WORKPLACE_TS as +/* +logical_workplace_ts.pkb +by Donald J. Bales on 12/15/2006 +Table LOGICAL_WORKPLACE_T's methods +*/ + +-- FORWARD DECLARATIONS + +FUNCTION get_parent_id_context( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE) +return varchar2; + + +FUNCTION create_id_context( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +v_id_context LOGICAL_WORKPLACE_T.id_context%TYPE; + +begin + v_id_context := get_parent_id_context(ain_parent_id); + + if v_id_context is not NULL then + return substr(v_id_context||'.'||to_char(ain_id), 1, 2000); + else + return to_char(ain_id); + end if; +end create_id_context; + + +FUNCTION get_id +return LOGICAL_WORKPLACE_T.id%TYPE is + +n_id LOGICAL_WORKPLACE_T.id%TYPE; + +begin + select LOGICAL_WORKPLACE_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_code_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +cursor c_code_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) is +select upper(code) code +from LOGICAL_WORKPLACE_T +connect by prior parent_id = id +start with id = ain_id +order by level desc; + +v_code_context varchar2(2000); + +begin + for r_code_context in c_code_context(ain_id) loop + v_code_context := substr(v_code_context||'.'||r_code_context.code, 1, 2000); + end loop; + return v_code_context; +end get_code_context; + + +FUNCTION get_name_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +cursor c_name_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) is +select initcap(name) name +from LOGICAL_WORKPLACE_T +connect by prior parent_id = id +start with id = ain_id +order by level desc; + +v_name_context varchar2(2000); + +begin + for r_name_context in c_name_context(ain_id) loop + v_name_context := substr(v_name_context||'.'||r_name_context.name, 1, 2000); + end loop; + return v_name_context; +end get_name_context; + + +FUNCTION get_parent_id_context( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE) +return varchar2 is + +v_id_context LOGICAL_WORKPLACE_T.id_context%TYPE; + +begin + if ain_parent_id is not NULL then + select id_context + into v_id_context + from LOGICAL_WORKPLACE_T + where id = ain_parent_id; + end if; + + return v_id_context; +end get_parent_id_context; + + +FUNCTION get_row( +air_logical_workplace in LOGICAL_WORKPLACE_T%ROWTYPE) +return LOGICAL_WORKPLACE_T%ROWTYPE is + +r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; + +begin + if air_logical_workplace.id is not NULL then + --pl('retrieve the row by the primary key'); + select * + into r_logical_workplace + from LOGICAL_WORKPLACE_T + where id = air_logical_workplace.id; + elsif air_logical_workplace.id_context is not NULL then + --pl('retrieve the row by the id_context unique key'); + select * + into r_logical_workplace + from LOGICAL_WORKPLACE_T + where id_context = air_logical_workplace.id_context; + else + --pl('retrieve the row by the code, name, and active_date'); + select * + into r_logical_workplace + from LOGICAL_WORKPLACE_T + where code = air_logical_workplace.code + and name = air_logical_workplace.name + and active_date = air_logical_workplace.active_date; + end if; + return r_logical_workplace; +exception + when NO_DATA_FOUND then + raise; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select LOGICAL_WORKPLACE_T'|| + ' in LOGICAL_WORKPLACE_TS.get_row()'); +end get_row; + + +FUNCTION set_row( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +ain_workplace_type_id in LOGICAL_WORKPLACE_T.workplace_type_id%TYPE, +aiv_code in LOGICAL_WORKPLACE_T.code%TYPE, +aiv_name in LOGICAL_WORKPLACE_T.name%TYPE, +aid_active_date in LOGICAL_WORKPLACE_T.active_date%TYPE) +return LOGICAL_WORKPLACE_T.id%TYPE is + +r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; + +begin + r_logical_workplace.id := NULL; + r_logical_workplace.id_context := NULL; + r_logical_workplace.parent_id := ain_parent_id; + r_logical_workplace.workplace_type_id := ain_workplace_type_id; + r_logical_workplace.code := aiv_code; + r_logical_workplace.name := aiv_name; + r_logical_workplace.active_date := aid_active_date; + set_row(r_logical_workplace); + + return r_logical_workplace.id; +end set_row; + + +-- PROCEDURES + +PROCEDURE help is + +begin + pl('No help coded yet.'); +end help; + + +PROCEDURE set_row( +aior_logical_workplace in out LOGICAL_WORKPLACE_T%ROWTYPE) is + +d_null constant date := DATES.d_MIN; +n_null constant number := 0; +v_null constant varchar2(1) := ' '; +r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; + +begin + -- get the existing row + begin + r_logical_workplace := get_row(aior_logical_workplace); + exception + when NO_DATA_FOUND then + r_logical_workplace := NULL; + end; + -- if a row exists, update it if needed + if r_logical_workplace.id is not NULL then + aior_logical_workplace.id := r_logical_workplace.id; + aior_logical_workplace.parent_id := r_logical_workplace.parent_id; + aior_logical_workplace.id_context := r_logical_workplace.id_context; + if nvl(r_logical_workplace.workplace_type_id, n_null) <> nvl(aior_logical_workplace.workplace_type_id, n_null) or + nvl(r_logical_workplace.code, v_null) <> nvl(aior_logical_workplace.code, v_null) or + nvl(r_logical_workplace.name, v_null) <> nvl(aior_logical_workplace.name, v_null) or + nvl(r_logical_workplace.active_date, d_null) <> nvl(aior_logical_workplace.active_date, d_null) or + nvl(r_logical_workplace.inactive_date, d_null) <> nvl(aior_logical_workplace.inactive_date, d_null) then + begin + update LOGICAL_WORKPLACE_T + set workplace_type_id = aior_logical_workplace.workplace_type_id, + code = aior_logical_workplace.code, + name = aior_logical_workplace.name, + active_date = aior_logical_workplace.active_date, + inactive_date = aior_logical_workplace.inactive_date + where id = aior_logical_workplace.id; + + n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20002, SQLERRM|| + ' on update LOGICAL_WORKPLACE_T'|| + ' in LOGICAL_WORKPLACE_TS.set_row()' ); + end; + end if; + else + -- add the row if it does not exist + begin + if aior_logical_workplace.id is NULL then + aior_logical_workplace.id := get_id(); + end if; + aior_logical_workplace.id_context := + create_id_context( + aior_logical_workplace.parent_id, + aior_logical_workplace.id ); + insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date, + inactive_date ) + values ( + aior_logical_workplace.id, + aior_logical_workplace.parent_id, + aior_logical_workplace.id_context, + aior_logical_workplace.workplace_type_id, + aior_logical_workplace.code, + aior_logical_workplace.name, + aior_logical_workplace.active_date, + aior_logical_workplace.inactive_date ); + + n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20003, SQLERRM|| + ' on insert LOGICAL_WORKPLACE_T'|| + ' in LOGICAL_WORKPLACE_TS.set_row()' ); + end; + end if; +end set_row; + + +PROCEDURE test is + +/* +LOGICAL_WORKPLACE_T + Name Null? Type + ---------------------------------------- -------- ------------- + LOGICAL_WORKPLACE_ID NOT NULL NUMBER + PARENT_ID NUMBER + ID_CONTEXT NOT NULL VARCHAR2(100) + WORKPLACE_TYPE_ID NOT NULL NUMBER + CODE NOT NULL VARCHAR2(30) + NAME NOT NULL VARCHAR2(80) + ACTIVE_DATE NOT NULL DATE + INACTIVE_DATE DATE +*/ + +v_id_context + LOGICAL_WORKPLACE_T.id_context%TYPE; +r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; + +begin + pl('LOGICAL_WORKPLACE_TS.test()'); + + TEST_TS.clear('LOGICAL_WORKPLACE_TS'); + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'DELETE', 0, + 'Delete existing test entries'); + begin + delete LOGICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + + delete LOGICAL_WORKPLACE_T + where code = TEST_TS.v_TEST_30; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'get_id()', 1, + 'Allocate the next primary key value'); + begin + r_logical_workplace.id := get_id(); + + if r_logical_workplace.id > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', + 'create_id_context()', 2, 'Create an ID context value'); + begin + r_logical_workplace.parent_id := NULL; + r_logical_workplace.id_context := + create_id_context( + r_logical_workplace.parent_id, + r_logical_workplace.id); + + if r_logical_workplace.id_context = + to_char(r_logical_workplace.id) then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'set_row()', 3, + 'Insert parent test entry'); + begin + r_logical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('C'); + r_logical_workplace.code := + TEST_TS.v_TEST_30; + r_logical_workplace.name := + TEST_TS.v_TEST_80; + r_logical_workplace.active_date := + TEST_TS.d_TEST_19000101; + r_logical_workplace.inactive_date := NULL; + set_row(r_logical_workplace); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'set_row()', 4, + 'Insert child entries'); + begin + r_logical_workplace.parent_id := + r_logical_workplace.id; + r_logical_workplace.id := get_id(); + r_logical_workplace.id_context := + create_id_context( + r_logical_workplace.parent_id, + r_logical_workplace.id); + -- save this value for testing get_row() + v_id_context := + r_logical_workplace.id_context; + r_logical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('B'); + r_logical_workplace.code := + TEST_TS.v_TEST_30_1; + r_logical_workplace.name := + TEST_TS.v_TEST_80; + set_row(r_logical_workplace); + + + r_logical_workplace.id := get_id(); + r_logical_workplace.id_context := + create_id_context( + r_logical_workplace.parent_id, + r_logical_workplace.id); + r_logical_workplace.code := + TEST_TS.v_TEST_30_2; + set_row(r_logical_workplace); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'get_code_context()', 5, + 'Get the code context for v_TEST_30_2'); + begin + pl(get_code_context( + r_logical_workplace.id)); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'get_name_context()', 6, + 'Get the name context for v_TEST_30_2'); + begin + pl(get_name_context( + r_logical_workplace.id)); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'get_row()', 7, + 'Get the row using the id for v_TEST_30_2'); + begin +-- r_logical_workplace.id := NULL; + r_logical_workplace.parent_id := NULL; + r_logical_workplace.id_context := NULL; + r_logical_workplace.workplace_type_id := NULL; + r_logical_workplace.code := NULL; + r_logical_workplace.name := NULL; + r_logical_workplace.active_date := NULL; + r_logical_workplace.inactive_date := NULL; + + r_logical_workplace := get_row(r_logical_workplace); + + if r_logical_workplace.id_context is not NULL then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'get_row()', 8, + 'Get the row using the id_context for v_TEST_30_1'); + begin + r_logical_workplace.id := NULL; + r_logical_workplace.parent_id := NULL; + r_logical_workplace.id_context := + v_id_context; + r_logical_workplace.workplace_type_id := NULL; + r_logical_workplace.code := NULL; + r_logical_workplace.name := NULL; + r_logical_workplace.active_date := NULL; + r_logical_workplace.inactive_date := NULL; + + r_logical_workplace := get_row(r_logical_workplace); + + if r_logical_workplace.id is not NULL then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + pl('v_id_context="'||v_id_context||'"'); + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'get_row()', 9, + 'Get the row using the code for v_TEST_30'); + begin + r_logical_workplace.id := NULL; + r_logical_workplace.parent_id := NULL; + r_logical_workplace.id_context := NULL; + r_logical_workplace.workplace_type_id := NULL; + r_logical_workplace.code := + TEST_TS.v_TEST_30; + r_logical_workplace.name := + TEST_TS.v_TEST_80; + r_logical_workplace.active_date := + TEST_TS.d_TEST_19000101; + r_logical_workplace.inactive_date := NULL; + + r_logical_workplace := get_row(r_logical_workplace); + + if r_logical_workplace.id is not NULL then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'help()', 10, + 'Display the help text'); + begin + help(); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'DELETE', 11, + 'Delete test entries'); + begin + delete LOGICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + + delete LOGICAL_WORKPLACE_T + where code = TEST_TS.v_TEST_30; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + commit; + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end LOGICAL_WORKPLACE_TS; +/ +@be.sql LOGICAL_WORKPLACE_TS + diff --git a/Chapter08/logical_workplace_ts.pks b/Chapter08/logical_workplace_ts.pks new file mode 100644 index 0000000..a1a23ab --- /dev/null +++ b/Chapter08/logical_workplace_ts.pks @@ -0,0 +1,102 @@ +create or replace PACKAGE LOGICAL_WORKPLACE_TS as +/* +logical_workplace_ts.pks
+by Don Bales on 12/15/2006
+Table LOGICAL_WORKPLACE_T's methods. Contains all the supporting service +methods (functions and procedures) for table LOGICAL_WORKPLACE_T. +*/ + +-- GLOBAL VARIABLES + +-- Keep track of the number of inserts and updates to made by set_row( ). +n_inserted number := 0; +n_updated number := 0; + +/* +Returns an id_context for the specified parent_id and id. +Whatever creates a new row must also call this mehtod to create an appropriate +id_context value. Method set_row( ) does this for you. +*/ +FUNCTION create_id_context( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return LOGICAL_WORKPLACE_T.id%TYPE; + +/* +Returns the value of a context for the code values in the logical workplace assignment. +*/ +FUNCTION get_code_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns the value of a context for the name values in the logical workplace assignment. +*/ +FUNCTION get_name_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns a LOGICAL_WORKPLACE row for the specified criteria. + +There are three sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the unique id_context
+3. the code, name, and active_date
+ +If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_logical_workplace in LOGICAL_WORKPLACE_T%ROWTYPE) +return LOGICAL_WORKPLACE_T%ROWTYPE; + +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + +/* +Updates or inserts a row matching the passed parameters into table LOGICAL_WORKPLACE_T. +See PROCEDURE set_row( ). +*/ +FUNCTION set_row( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +ain_workplace_type_id in LOGICAL_WORKPLACE_T.workplace_type_id%TYPE, +aiv_code in LOGICAL_WORKPLACE_T.code%TYPE, +aiv_name in LOGICAL_WORKPLACE_T.name%TYPE, +aid_active_date in LOGICAL_WORKPLACE_T.active_date%TYPE) +return LOGICAL_WORKPLACE_T.id%TYPE; + +/* +Updates or inserts a row matching the passed row into table LOGICAL_WORKPLACE_T. + +First, set_row() calls get row to try to find a matching row that already +exists in the database. So you need to set the id, id_context, +and code, name and active_date appropriately in order to prperly detect an +existing row. + +Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise, and new row is inserted, including the allocation of +a new primary key and id_context value. Upon inserting a new value, the +id and id_context values are updated in the passed row. +See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_logical_workplace in out LOGICAL_WORKPLACE_T%ROWTYPE); + +/* +Performs unit tests for this package. +*/ +PROCEDURE test; + +end LOGICAL_WORKPLACE_TS; +/ +@se.sql LOGICAL_WORKPLACE_TS + diff --git a/Chapter08/login.sql b/Chapter08/login.sql new file mode 100644 index 0000000..b4f6eb2 --- /dev/null +++ b/Chapter08/login.sql @@ -0,0 +1,9 @@ +rem login.sql +rem by Donald J. Bales on 12/15/2006 +rem Set my default SQL*Plus environment +set newpage 1; +set pagesize 32767; +set serveroutput on size 1000000; +set trimspool on; +alter session set nls_date_format = 'SYYYYMMDD HH24MISS'; +prompt BPS' default settings loaded successfully! diff --git a/Chapter08/pe.sql b/Chapter08/pe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter08/pe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter08/pl.prc b/Chapter08/pl.prc new file mode 100644 index 0000000..10b8e34 --- /dev/null +++ b/Chapter08/pl.prc @@ -0,0 +1,14 @@ +create or replace PROCEDURE pl( +aiv_text in varchar2 ) is +/* +pl.prc +by Donald J. Bales on 12/15/2006 +A wrapper procedure for SYS.DBMS_OUTPUT.put_line() +for the lazy typist. +*/ + +begin + SYS.DBMS_OUTPUT.put_line(aiv_text); +end pl; +/ +@pe.sql pl diff --git a/Chapter08/se.sql b/Chapter08/se.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter08/se.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter08/solutions/gender_ts.pkb b/Chapter08/solutions/gender_ts.pkb new file mode 100644 index 0000000..aa5ac42 --- /dev/null +++ b/Chapter08/solutions/gender_ts.pkb @@ -0,0 +1,357 @@ +create or replace PACKAGE BODY GENDER_TS as +/* +gender_ts.pkb +by Don Bales on 12/15/2006 +Table GENDER_T's methods +*/ + + +-- FUNCTIONS + +FUNCTION get_id +return GENDER_T.id%TYPE is + +n_id GENDER_T.id%TYPE; + +begin + select GENDER_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_id( +aiv_code in GENDER_T.code%TYPE ) +return GENDER_T.id%TYPE is + +n_id GENDER_T.id%TYPE; + +begin + select id + into n_id + from GENDER_T + where code = aiv_code; + + return n_id; +end get_id; + + +-- PROCEDURES + +PROCEDURE get_code_descr( +ain_id in GENDER_T.id%TYPE, +aov_code out GENDER_T.code%TYPE, +aov_description out GENDER_T.description%TYPE ) is + +begin + select code, + description + into aov_code, + aov_description + from GENDER_T + where id = ain_id; +end get_code_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE, +aid_on in GENDER_T.active_date%TYPE ) is + +v_code GENDER_T.code%TYPE; + +begin + select id, + description + into aon_id, + aov_description + from GENDER_T + where code = aiov_code + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); +exception + when NO_DATA_FOUND then + select id, + code, + description + into aon_id, + v_code, + aov_description + from GENDER_T + where code like aiov_code||'%' + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); + + aiov_code := v_code; +end get_code_id_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE ) is + +begin + get_code_id_descr( + aiov_code, + aon_id, + aov_description, + SYSDATE ); +end get_code_id_descr; + + +PROCEDURE help is + +begin +-- 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('GENDER_TS'); + pl(chr(9)); + pl('----------------------------------- FUNCTIONS ----------------------------------'); + pl(chr(9)); + pl('GENDER_TS.get_id'); + pl('return GENDER_T.id%TYPE;'); + pl(chr(9)||'Returns a newly allocated sequence value for id.'); + pl(chr(9)); + pl('GENDER_TS.get_id('); + pl('aiv_code in GENDER_T.code%TYPE )'); + pl('return GENDER_T.id%TYPE;'); + pl(chr(9)||'Returns the corresponding id for the specified code.'); + pl(chr(9)); + pl('----------------------------------- PROCEDURES ---------------------------------'); + pl(chr(9)); + pl('GENDER_TS.get_code_descr('); + pl('ain_id in GENDER_T.id%TYPE,'); + pl('aov_code out GENDER_T.code%TYPE,'); + pl('aov_description out GENDER_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding code and description for the specified'); + pl(chr(9)||'id.'); + pl(chr(9)); + pl('GENDER_TS.get_code_id_descr('); + pl('aiov_code in out GENDER_T.code%TYPE,'); + pl('aon_id out GENDER_T.id%TYPE,'); + pl('aov_description out GENDER_T.description%TYPE,'); + pl('aid_on in GENDER_T.active_date%TYPE );'); + pl(chr(9)||'Gets the corresponding code, id, and description for'); + pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified code and point in time.'); + pl(chr(9)); + pl('GENDER_TS.get_code_id_descr('); + pl('aiov_code in out GENDER_T.code%TYPE,'); + pl('aon_id out GENDER_T.id%TYPE,'); + pl('aov_description out GENDER_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding code, id, and description for'); + pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified code at the current point in time.'); + pl(chr(9)); + pl('GENDER_TS.help( );'); + pl(chr(9)||'Displays this help text if set serveroutput is on.'); + pl(chr(9)); + pl('GENDER_TS.test( );'); + pl(chr(9)||'Built-in test unit. It will report success or error for each test if set'); + pl(chr(9)||'serveroutput is on.'); + pl(chr(9)); +end help; + + +PROCEDURE test is + +n_id GENDER_T.id%TYPE; +v_code GENDER_T.code%TYPE; +v_description GENDER_T.description%TYPE; + +begin + -- Send feedback that the test ran + pl('GENDER_TS.test()'); + + -- Clear the last set of test results + TEST_TS.clear('GENDER_TS'); + + -- First, we need some test values + + -- Let's make sure they don't already exist: DELETE + TEST_TS.set_test('GENDER_TS', 'DELETE', 0, + 'Delete test entries'); + begin + delete GENDER_T + where code in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Now let's add three test codes: INSERT + TEST_TS.set_test('GENDER_TS', 'INSERT', 1, + 'Insert 3 test entries'); + begin + insert into GENDER_T ( + id, + code, + description, + active_date, + inactive_date ) + values ( + get_id(), + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101, + NULL ); + + insert into GENDER_T ( + id, + code, + description, + active_date, + inactive_date ) + values ( + get_id(), + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101, + TEST_TS.d_TEST_19991231 ); + + insert into GENDER_T ( + id, + code, + description, + active_date, + inactive_date ) + values ( + get_id(), + TEST_TS.v_TEST_30_2, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101, + TEST_TS.d_TEST_19991231 ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Now that we have test entries, + -- let's test the package methods + TEST_TS.set_test('GENDER_TS', 'get_id()', 2, + 'Get the ID for the specified code'); + begin + n_id := get_id(TEST_TS.v_TEST_30); + + if n_id > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('GENDER_TS', 'get_code_descr()', 3, + 'Get the code and description for the specified ID'); + begin + get_code_descr( + n_id, + v_code, + v_description); + if v_code = TEST_TS.v_TEST_30 and + v_description = TEST_TS.v_TEST_80 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('GENDER_TS', 'get_code_id_descr()', 4, + 'Get the code, ID, and description for the specified code'); + begin + v_code := 'TEST'; + get_code_id_descr( + v_code, + n_id, + v_description); + if v_code = TEST_TS.v_TEST_30 and + n_id > 0 and + v_description = TEST_TS.v_TEST_80 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('GENDER_TS', 'get_code_id_descr()', 5, + 'Get the code, ID, and description for the specified date'); + begin + v_code := 'TEST'; + -- This test should raise a TOO_MANY_ROWS exception + -- because at least three duplicate values will + -- on the date specified + get_code_id_descr( + v_code, + n_id, + v_description, + TEST_TS.d_TEST_19991231); + if v_code = TEST_TS.v_TEST_30 and + n_id > 0 and + v_description = TEST_TS.v_TEST_80 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when TOO_MANY_ROWS then + TEST_TS.ok(); + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('GENDER_TS', 'help()', 6, + 'Display help'); + begin + help(); + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Let's make sure they don't already exist: DELETE + TEST_TS.set_test('GENDER_TS', 'DELETE', 7, + 'Delete test entries'); + begin + delete GENDER_T + where code in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + raise_application_error(-20001, 'Test Failed'); + + TEST_TS.set_test('GENDER_TS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end GENDER_TS; +/ +@be.sql GENDER_TS + diff --git a/Chapter08/solutions/gender_ts.pks b/Chapter08/solutions/gender_ts.pks new file mode 100644 index 0000000..24c014e --- /dev/null +++ b/Chapter08/solutions/gender_ts.pks @@ -0,0 +1,66 @@ +create or replace PACKAGE GENDER_TS as +/* +gender_ts.pks +by Don Bales on 12/15/2006 +Table GENDER_T's methods. +*/ + + +/* +Gets the code and decription values for the specified id. +*/ +PROCEDURE get_code_descr( +ain_id in GENDER_T.id%TYPE, +aov_code out GENDER_T.code%TYPE, +aov_description out GENDER_T.description%TYPE); + + +/* +Verifies that the passed code value is an exact or like match on the date specified. +*/ +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE, +aid_on in GENDER_T.active_date%TYPE); + + +/* +Verifies that the passed code value is currently an exact or like match. +*/ +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE); + + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return GENDER_T.id%TYPE; + + +/* +Returns the id for the specified code value. +*/ +FUNCTION get_id( +aiv_code in GENDER_T.code%TYPE) +return GENDER_T.id%TYPE; + + +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + + +/* +Test units for this package. +*/ +PROCEDURE test; + + +end GENDER_TS; +/ +@se.sql GENDER_TS diff --git a/Chapter08/solutions/last_test_o_results.sql b/Chapter08/solutions/last_test_o_results.sql new file mode 100644 index 0000000..32a2dee --- /dev/null +++ b/Chapter08/solutions/last_test_o_results.sql @@ -0,0 +1,35 @@ +rem last_test_o_results.sql +rem by Donald J. Bales on 12/15/2006 +rem Display the last test results + +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; + +column test format a34; +column t# format 99; +column description format a27; +column result format a7; + +spool last_test_o_results.txt; + +select t.object_name|| + decode(substr(t.method_name, -1, 1), ')', '.', ' ')|| + t.method_name test, + t.test_number t#, + t.description, + t.result +from TEST_OT t +where t.unique_session_id = SYS.DBMS_SESSION.unique_session_id +and t.object_name = ( +select e.object_name +from TEST_OT e +where e.unique_session_id = SYS.DBMS_SESSION.unique_session_id +and e.test_id = ( +select max(x.test_id) +from TEST_OT x +where x.unique_session_id = SYS.DBMS_SESSION.unique_session_id)) +order by t.test_id; + +spool off; diff --git a/Chapter08/solutions/last_test_o_results.txt b/Chapter08/solutions/last_test_o_results.txt new file mode 100644 index 0000000..51163d0 --- /dev/null +++ b/Chapter08/solutions/last_test_o_results.txt @@ -0,0 +1,3 @@ + +no rows selected + diff --git a/Chapter08/solutions/physical_assignment_ts.pkb b/Chapter08/solutions/physical_assignment_ts.pkb new file mode 100644 index 0000000..71345a8 --- /dev/null +++ b/Chapter08/solutions/physical_assignment_ts.pkb @@ -0,0 +1,678 @@ +create or replace PACKAGE BODY PHYSICAL_ASSIGNMENT_TS as +/* +physical_assignment_ts.pkb +by Donald J. Bales on 12/15/2006 +Table PHYSICAL_ASSIGNMENT_T's methods +*/ + + +FUNCTION get_id +return PHYSICAL_ASSIGNMENT_T.id%TYPE is + +n_id PHYSICAL_ASSIGNMENT_T.id%TYPE; + +begin + select PHYSICAL_ASSIGNMENT_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_physical_workplace( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in PHYSICAL_ASSIGNMENT_T.active_date%TYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE is + +r_physical_workplace PHYSICAL_WORKPLACE_T%ROWTYPE; + +begin + select * + into r_physical_workplace + from PHYSICAL_WORKPLACE_T + where id = ( + select physical_workplace_id + from PHYSICAL_ASSIGNMENT_T + where worker_id = ain_worker_id + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX) ); + + return r_physical_workplace; +end get_physical_workplace; + + +FUNCTION get_physical_workplace( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE is + +begin + return get_physical_workplace(ain_worker_id, SYSDATE); +end get_physical_workplace; + + +FUNCTION get_row( +air_physical_assignment in PHYSICAL_ASSIGNMENT_T%ROWTYPE) +return PHYSICAL_ASSIGNMENT_T%ROWTYPE is + +r_physical_assignment PHYSICAL_ASSIGNMENT_T%ROWTYPE; + +begin + if air_physical_assignment.id is not NULL then + -- retrieve the row by the primary key + select * + into r_physical_assignment + from PHYSICAL_ASSIGNMENT_T + where id = air_physical_assignment.id; + else + -- retrieve the row by the worker_id and active_date + select * + into r_physical_assignment + from PHYSICAL_ASSIGNMENT_T + where worker_id = air_physical_assignment.worker_id + and active_date = air_physical_assignment.active_date; + end if; + return r_physical_assignment; +exception + when NO_DATA_FOUND then + raise; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select PHYSICAL_ASSIGNMENT_T'|| + ' in PHYSICAL_ASSIGNMENT_TS.get_row()'); +end get_row; + + +PROCEDURE help is + +begin + pl('No help yet!'); +end help; + + +FUNCTION is_active( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in date) +return boolean is + +pragma AUTONOMOUS_TRANSACTION; + +n_count number; + +begin + select count(1) + into n_count + from PHYSICAL_ASSIGNMENT_T + where worker_id = ain_worker_id + and aid_on between active_date + and nvl(inactive_date, DATES.d_MAX); + + if nvl(n_count,0) > 0 then + return TRUE; + else + return FALSE; + end if; + + commit; +end is_active; + + +FUNCTION is_active( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE) +return boolean is + +begin + return is_active(ain_worker_id, SYSDATE); +end is_active; + + +PROCEDURE set_row( +aior_physical_assignment in out PHYSICAL_ASSIGNMENT_T%ROWTYPE) is + +d_null constant date := DATES.d_MIN; +n_null constant number := 0; +v_null constant varchar2(1) := ' '; +r_physical_assignment PHYSICAL_ASSIGNMENT_T%ROWTYPE; + +begin + -- get the existing row + begin + r_physical_assignment := get_row(aior_physical_assignment); + exception + when NO_DATA_FOUND then + r_physical_assignment := NULL; + end; + -- if a row exists, update it if needed + if r_physical_assignment.id is not NULL then + aior_physical_assignment.id := + r_physical_assignment.id; + aior_physical_assignment.worker_id := + r_physical_assignment.worker_id; + aior_physical_assignment.active_date := + r_physical_assignment.active_date; + if nvl(r_physical_assignment.physical_workplace_id, n_null) <> + nvl(aior_physical_assignment.physical_workplace_id, n_null) or + nvl(r_physical_assignment.inactive_date, d_null) <> + nvl(aior_physical_assignment.inactive_date, d_null) then + begin + update PHYSICAL_ASSIGNMENT_T + set physical_workplace_id = + aior_physical_assignment.physical_workplace_id, + inactive_date = + aior_physical_assignment.inactive_date + where id = + aior_physical_assignment.id; + + n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20002, SQLERRM|| + ' on update PHYSICAL_ASSIGNMENT_T'|| + ' in PHYSICAL_ASSIGNMENT_TS.set_row()' ); + end; + end if; + else + -- add the row if it does not exist + begin + if aior_physical_assignment.id is NULL then + aior_physical_assignment.id := get_id(); + end if; + insert into PHYSICAL_ASSIGNMENT_T ( + id, + worker_id, + physical_workplace_id, + active_date, + inactive_date ) + values ( + aior_physical_assignment.id, + aior_physical_assignment.worker_id, + aior_physical_assignment.physical_workplace_id, + aior_physical_assignment.active_date, + aior_physical_assignment.inactive_date ); + + n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20003, SQLERRM|| + ' on insert PHYSICAL_ASSIGNMENT_T'|| + ' in PHYSICAL_ASSIGNMENT_TS.set_row()' ); + end; + end if; +end set_row; + + +PROCEDURE test is + +n_physical_workplace_id PHYSICAL_WORKPLACE_T.id%TYPE; +n_physical_workplace_id_1 PHYSICAL_WORKPLACE_T.id%TYPE; +n_physical_workplace_id_2 PHYSICAL_WORKPLACE_T.id%TYPE; +n_worker_id WORKER_T.id%TYPE; +n_worker_id_1 WORKER_T.id%TYPE; +n_worker_id_2 WORKER_T.id%TYPE; +r_worker WORKER_T%ROWTYPE; +r_physical_workplace PHYSICAL_WORKPLACE_T%ROWTYPE; +r_physical_assignment PHYSICAL_ASSIGNMENT_T%ROWTYPE; + +begin + pl('PHYSICAL_ASSIGNMENT_TS.test()'); + + TEST_TS.clear('PHYSICAL_ASSIGNMENT_TS'); + + -- In order to make entries into an Intersection table + -- you first have to have entries in the two tables + -- for which an entry will create an intersection + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'DELETE', 0, + 'Delete existing test entries from PHYSICAL_ASSIGNMENT_T'); + begin + delete PHYSICAL_ASSIGNMENT_T + where physical_workplace_id in ( + select physical_workplace_id + from PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ) ); + + delete PHYSICAL_ASSIGNMENT_T + where worker_id in ( + select worker_id + from WORKER_T + where external_id in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ) ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'DELETE', 1, + 'Delete existing test entries from PHYSICAL_WORKPLACE_T'); + begin + delete PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ); + + delete PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30 ); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'DELETE', 2, + 'Delete existing test entries from WORKER_T'); + begin + delete WORKER_T + where external_id in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'INSERT', 3, + 'Insert WORKER_T test entries using set_row()'); + begin + r_worker.id := WORKER_TS.get_id(); + r_worker.worker_type_id := WORKER_TYPE_TS.get_id('E'); + r_worker.external_id := TEST_TS.v_TEST_30; + r_worker.first_name := TEST_TS.v_TEST_30; + r_worker.middle_name := TEST_TS.v_TEST_30; + r_worker.last_name := TEST_TS.v_TEST_30; + r_worker.name := WORKER_TS.get_formatted_name( + r_worker.first_name, + r_worker.middle_name, + r_worker.last_name); + r_worker.birth_date := to_date('19800101', 'YYYYMMDD'); + r_worker.gender_id := GENDER_TS.get_id('M'); + WORKER_TS.set_row(r_worker); + n_worker_id := r_worker.id; + + r_worker.id := WORKER_TS.get_id(); + r_worker.worker_type_id := WORKER_TYPE_TS.get_id('E'); + r_worker.external_id := TEST_TS.v_TEST_30_1; + r_worker.first_name := TEST_TS.v_TEST_30_1; + r_worker.middle_name := TEST_TS.v_TEST_30_1; + r_worker.last_name := TEST_TS.v_TEST_30_1; + r_worker.name := WORKER_TS.get_formatted_name( + r_worker.first_name, + r_worker.middle_name, + r_worker.last_name); + r_worker.birth_date := to_date('19700101', 'YYYYMMDD'); + r_worker.gender_id := GENDER_TS.get_id('F'); + WORKER_TS.set_row(r_worker); + n_worker_id_1 := r_worker.id; + + r_worker.id := WORKER_TS.get_id(); + r_worker.worker_type_id := WORKER_TYPE_TS.get_id('C'); + r_worker.external_id := TEST_TS.v_TEST_30_2; + r_worker.first_name := TEST_TS.v_TEST_30_2; + r_worker.middle_name := TEST_TS.v_TEST_30_2; + r_worker.last_name := TEST_TS.v_TEST_30_2; + r_worker.name := WORKER_TS.get_formatted_name( + r_worker.first_name, + r_worker.middle_name, + r_worker.last_name); + r_worker.birth_date := to_date('19600101', 'YYYYMMDD'); + r_worker.gender_id := GENDER_TS.get_id('M'); + WORKER_TS.set_row(r_worker); + n_worker_id_2 := r_worker.id; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'INSERT', 4, + 'Insert PHYSICAL_WORKPLACE_T test entries using set_row()'); + begin + r_physical_workplace.id := + PHYSICAL_WORKPLACE_TS.get_id(); + r_physical_workplace.parent_id := NULL; + r_physical_workplace.id_context := + PHYSICAL_WORKPLACE_TS.create_id_context( + r_physical_workplace.parent_id, + r_physical_workplace.id); + r_physical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('C'); + r_physical_workplace.code := TEST_TS.v_TEST_30; + r_physical_workplace.name := TEST_TS.v_TEST_80; + r_physical_workplace.active_date := TEST_TS.d_TEST_19000101; + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + n_physical_workplace_id := + r_physical_workplace.id; + + r_physical_workplace.id := + PHYSICAL_WORKPLACE_TS.get_id(); + r_physical_workplace.parent_id := + n_physical_workplace_id; + r_physical_workplace.id_context := + PHYSICAL_WORKPLACE_TS.create_id_context( + r_physical_workplace.parent_id, + r_physical_workplace.id); + r_physical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('B'); + r_physical_workplace.code := TEST_TS.v_TEST_30_1; + r_physical_workplace.name := TEST_TS.v_TEST_80; + r_physical_workplace.active_date := TEST_TS.d_TEST_19000101; + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + n_physical_workplace_id_1 := + r_physical_workplace.id; + + r_physical_workplace.id := + PHYSICAL_WORKPLACE_TS.get_id(); + r_physical_workplace.parent_id := + n_physical_workplace_id; + r_physical_workplace.id_context := + PHYSICAL_WORKPLACE_TS.create_id_context( + r_physical_workplace.parent_id, + r_physical_workplace.id); + r_physical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('B'); + r_physical_workplace.code := TEST_TS.v_TEST_30_2; + r_physical_workplace.name := TEST_TS.v_TEST_80; + r_physical_workplace.active_date := TEST_TS.d_TEST_19000101; + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + n_physical_workplace_id_2 := + r_physical_workplace.id; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Now that I have entries in the two tables being intersected + -- I can now start testing this package... + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'get_id()', 5, + 'Allocate the next primary key value using get_id()'); + begin + r_physical_assignment.id := + PHYSICAL_ASSIGNMENT_TS.get_id(); + + if nvl(r_physical_assignment.id, 0) > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'set_row()', 6, + 'Insert history for v_TEST_30 using set_row()'); + begin + r_physical_assignment.worker_id := n_worker_id; + r_physical_assignment.physical_workplace_id := + n_physical_workplace_id_2; + r_physical_assignment.active_date := + to_date('20000101', 'YYYYMMDD'); + r_physical_assignment.inactive_date := NULL; + PHYSICAL_ASSIGNMENT_TS.set_row(r_physical_assignment); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'set_row()', 7, + 'Insert history for V_TEST_30_1 using set_row()'); + begin + r_physical_assignment.id := + PHYSICAL_ASSIGNMENT_TS.get_id(); + r_physical_assignment.worker_id := n_worker_id_1; + r_physical_assignment.physical_workplace_id := + n_physical_workplace_id_1; + r_physical_assignment.active_date := + to_date('19900101', 'YYYYMMDD'); + r_physical_assignment.inactive_date := + to_date('19991231', 'YYYYMMDD'); + PHYSICAL_ASSIGNMENT_TS.set_row(r_physical_assignment); + + r_physical_assignment.id := + PHYSICAL_ASSIGNMENT_TS.get_id(); + r_physical_assignment.worker_id := n_worker_id_1; + r_physical_assignment.physical_workplace_id := + n_physical_workplace_id_2; + r_physical_assignment.active_date := + to_date('20000101', 'YYYYMMDD'); + r_physical_assignment.inactive_date := NULL; + PHYSICAL_ASSIGNMENT_TS.set_row(r_physical_assignment); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'set_row()', 8, + 'Insert history for V_TEST_30_2 using set_row()'); + begin + r_physical_assignment.id := + PHYSICAL_ASSIGNMENT_TS.get_id(); + r_physical_assignment.worker_id := n_worker_id_2; + r_physical_assignment.physical_workplace_id := + n_physical_workplace_id_1; + r_physical_assignment.active_date := + to_date('19800101', 'YYYYMMDD'); + r_physical_assignment.inactive_date := + to_date('19891231', 'YYYYMMDD'); + PHYSICAL_ASSIGNMENT_TS.set_row(r_physical_assignment); + + r_physical_assignment.id := + PHYSICAL_ASSIGNMENT_TS.get_id(); + r_physical_assignment.worker_id := n_worker_id_2; + r_physical_assignment.physical_workplace_id := + n_physical_workplace_id_2; + r_physical_assignment.active_date := + to_date('19900101', 'YYYYMMDD'); + r_physical_assignment.inactive_date := + to_date('19901231', 'YYYYMMDD'); + PHYSICAL_ASSIGNMENT_TS.set_row(r_physical_assignment); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Commit the deletes and inserts + commit; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', + 'get_physical_workplace()', 9, + 'Get the current physical workplace for v_TEST_30'); + begin + r_physical_workplace := NULL; + r_physical_workplace := get_physical_workplace(n_worker_id); + + if nvl(r_physical_workplace.id, 0) > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', + 'get_physical_workplace()', 10, + 'Get the physical workplace on 6/30/1995 for v_TEST_30_1'); + begin + r_physical_workplace := NULL; + r_physical_workplace := get_physical_workplace( + n_worker_id_1, + to_date('19950630', 'YYYYMMDD')); + + if nvl(r_physical_workplace.id, 0) > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', + 'get_physical_workplace()', 11, + 'Get the physical workplace on 6/30/1995 for v_TEST_30_2'); + begin + -- this should fail + r_physical_workplace := NULL; + r_physical_workplace := get_physical_workplace( + n_worker_id_2, + to_date('19950630', 'YYYYMMDD')); + + if nvl(r_physical_workplace.id, 0) > 0 then + TEST_TS.error(); + else + TEST_TS.ok(); + end if; + exception + when NO_DATA_FOUND then + TEST_TS.ok(); + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'help()', 12, + 'Test help()'); + begin + help(); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'is_active()', 13, + 'Is there an active assignment on 6/30/1995 for v_TEST_30?'); + -- No + begin + if is_active(n_worker_id, to_date('19950630', 'YYYYMMDD')) then + TEST_TS.error(); + else + TEST_TS.ok(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'is_active()', 14, + 'Is there an active assignment on 6/30/1995 for v_TEST_30_1?'); + -- Yes + begin + if is_active(n_worker_id_1, to_date('19950630', 'YYYYMMDD')) then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'is_active()', 15, + 'Is there currently an active assignment for v_TEST_30_2?'); + -- No + begin + if is_active(n_worker_id_2) then + TEST_TS.error(); + else + TEST_TS.ok(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Now clean up after the tests by deleting the test entries + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'DELETE', 16, + 'Delete existing test entries from PHYSICAL_ASSIGNMENT_T'); + begin + delete PHYSICAL_ASSIGNMENT_T + where physical_workplace_id in ( + select physical_workplace_id + from PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ) ); + + delete PHYSICAL_ASSIGNMENT_T + where worker_id in ( + select worker_id + from WORKER_T + where external_id in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ) ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'DELETE', 17, + 'Delete existing test entries from PHYSICAL_WORKPLACE_T'); + begin + delete PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ); + + delete PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30 ); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'DELETE', 18, + 'Delete existing test entries from WORKER_T'); + begin + delete WORKER_T + where external_id in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + commit; + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end PHYSICAL_ASSIGNMENT_TS; +/ +@be.sql PHYSICAL_ASSIGNMENT_TS diff --git a/Chapter08/solutions/physical_assignment_ts.pks b/Chapter08/solutions/physical_assignment_ts.pks new file mode 100644 index 0000000..9d94344 --- /dev/null +++ b/Chapter08/solutions/physical_assignment_ts.pks @@ -0,0 +1,92 @@ +create or replace PACKAGE PHYSICAL_ASSIGNMENT_TS as +/* +physical_assignment_ts.pks +by Donald J. Bales on 12/15/2006 +Table PHYSICAL_ASSIGNMENT_T's routines +*/ + +-- GLOBAL VARIABLES + +-- Keep track of the number of inserts and updates to made by set_row(). +n_inserted number := 0; +n_updated number := 0; + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return PHYSICAL_ASSIGNMENT_T.id%TYPE; + +/* +Returns a the PHYSICAL_WORKPLACE row for the specified worker_id and on the specified date. +*/ +FUNCTION get_physical_workplace( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in PHYSICAL_ASSIGNMENT_T.active_date%TYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE; + +/* +Returns a the current PHYSICAL_WORKPLACE row for the specified worker_id. +*/ +FUNCTION get_physical_workplace( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE; + +/* +Returns a PHYSICAL_ASSIGNMENT row for the specified criteria. +
+There are two sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the woker_id and active_date
+
+If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_physical_assignment in PHYSICAL_ASSIGNMENT_T%ROWTYPE) +return PHYSICAL_ASSIGNMENT_T%ROWTYPE; + +/* + Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + +/* +Returns TRUE if the worker has a physical assignment on the specified date, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in date) +return boolean; + +/* +Returns TRUE if the worker currently has a physical assignment, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE) +return boolean; + +/* +Updates or inserts a row matching the passed row into table PHYSICAL_WORKPLACE_T. +
+First, set_row( ) calls get_row( ) to try to find a matching row that already +exists in the database. So you need to set the id, or worked_id +and active_date appropriately in order to properly detect an existing row.
+
+Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise a new row is inserted, including the allocation of +a new primary key value. Upon inserting a new value, the id +value is updated in the passed row.
+See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_physical_assignment in out PHYSICAL_ASSIGNMENT_T%ROWTYPE); + +/* +The test unit for this package. +*/ +PROCEDURE test; + +end PHYSICAL_ASSIGNMENT_TS; +/ +@se.sql PHYSICAL_ASSIGNMENT_TS diff --git a/Chapter08/solutions/physical_workplace_ts.pkb b/Chapter08/solutions/physical_workplace_ts.pkb new file mode 100644 index 0000000..5ffb82e --- /dev/null +++ b/Chapter08/solutions/physical_workplace_ts.pkb @@ -0,0 +1,550 @@ +create or replace PACKAGE BODY PHYSICAL_WORKPLACE_TS as +/* +physical_workplace_ts.pkb +by Donald J. Bales on 12/15/2006 +Table PHYSICAL_WORKPLACE_T's methods +*/ + +-- FORWARD DECLARATIONS + +FUNCTION get_parent_id_context( +ain_parent_id in PHYSICAL_WORKPLACE_T.parent_id%TYPE) +return varchar2; + + +FUNCTION create_id_context( +ain_parent_id in PHYSICAL_WORKPLACE_T.parent_id%TYPE, +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +v_id_context PHYSICAL_WORKPLACE_T.id_context%TYPE; + +begin + v_id_context := get_parent_id_context(ain_parent_id); + + if v_id_context is not NULL then + return substr(v_id_context||'.'||to_char(ain_id), 1, 2000); + else + return to_char(ain_id); + end if; +end create_id_context; + + +FUNCTION get_id +return PHYSICAL_WORKPLACE_T.id%TYPE is + +n_id PHYSICAL_WORKPLACE_T.id%TYPE; + +begin + select PHYSICAL_WORKPLACE_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_code_context( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +cursor c_code_context( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) is +select upper(code) code +from PHYSICAL_WORKPLACE_T +connect by prior parent_id = id +start with id = ain_id +order by level desc; + +v_code_context varchar2(2000); + +begin + for r_code_context in c_code_context(ain_id) loop + v_code_context := substr(v_code_context||'.'||r_code_context.code, 1, 2000); + end loop; + return v_code_context; +end get_code_context; + + +FUNCTION get_name_context( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +cursor c_name_context( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) is +select initcap(name) name +from PHYSICAL_WORKPLACE_T +connect by prior parent_id = id +start with id = ain_id +order by level desc; + +v_name_context varchar2(2000); + +begin + for r_name_context in c_name_context(ain_id) loop + v_name_context := substr(v_name_context||'.'||r_name_context.name, 1, 2000); + end loop; + return v_name_context; +end get_name_context; + + +FUNCTION get_parent_id_context( +ain_parent_id in PHYSICAL_WORKPLACE_T.parent_id%TYPE) +return varchar2 is + +v_id_context PHYSICAL_WORKPLACE_T.id_context%TYPE; + +begin + if ain_parent_id is not NULL then + select id_context + into v_id_context + from PHYSICAL_WORKPLACE_T + where id = ain_parent_id; + end if; + + return v_id_context; +end get_parent_id_context; + + +FUNCTION get_row( +air_physical_workplace in PHYSICAL_WORKPLACE_T%ROWTYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE is + +r_physical_workplace PHYSICAL_WORKPLACE_T%ROWTYPE; + +begin + if air_physical_workplace.id is not NULL then + --pl('retrieve the row by the primary key'); + select * + into r_physical_workplace + from PHYSICAL_WORKPLACE_T + where id = air_physical_workplace.id; + elsif air_physical_workplace.id_context is not NULL then + --pl('retrieve the row by the id_context unique key'); + select * + into r_physical_workplace + from PHYSICAL_WORKPLACE_T + where id_context = air_physical_workplace.id_context; + else + --pl('retrieve the row by the code, name, and active_date'); + select * + into r_physical_workplace + from PHYSICAL_WORKPLACE_T + where code = air_physical_workplace.code + and name = air_physical_workplace.name + and active_date = air_physical_workplace.active_date; + end if; + return r_physical_workplace; +exception + when NO_DATA_FOUND then + raise; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select PHYSICAL_WORKPLACE_T'|| + ' in PHYSICAL_WORKPLACE_TS.get_row()'); +end get_row; + + +FUNCTION set_row( +ain_parent_id in PHYSICAL_WORKPLACE_T.parent_id%TYPE, +ain_workplace_type_id in PHYSICAL_WORKPLACE_T.workplace_type_id%TYPE, +aiv_code in PHYSICAL_WORKPLACE_T.code%TYPE, +aiv_name in PHYSICAL_WORKPLACE_T.name%TYPE, +aid_active_date in PHYSICAL_WORKPLACE_T.active_date%TYPE) +return PHYSICAL_WORKPLACE_T.id%TYPE is + +r_physical_workplace PHYSICAL_WORKPLACE_T%ROWTYPE; + +begin + r_physical_workplace.id := NULL; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := ain_parent_id; + r_physical_workplace.workplace_type_id := ain_workplace_type_id; + r_physical_workplace.code := aiv_code; + r_physical_workplace.name := aiv_name; + r_physical_workplace.active_date := aid_active_date; + set_row(r_physical_workplace); + + return r_physical_workplace.id; +end set_row; + + +-- PROCEDURES + +PROCEDURE help is + +begin + pl('No help coded yet.'); +end help; + + +PROCEDURE set_row( +aior_physical_workplace in out PHYSICAL_WORKPLACE_T%ROWTYPE) is + +d_null constant date := DATES.d_MIN; +n_null constant number := 0; +v_null constant varchar2(1) := ' '; +r_physical_workplace PHYSICAL_WORKPLACE_T%ROWTYPE; + +begin + -- get the existing row + begin + r_physical_workplace := get_row(aior_physical_workplace); + exception + when NO_DATA_FOUND then + r_physical_workplace := NULL; + end; + -- if a row exists, update it if needed + if r_physical_workplace.id is not NULL then + aior_physical_workplace.id := + r_physical_workplace.id; + aior_physical_workplace.parent_id := + r_physical_workplace.parent_id; + aior_physical_workplace.id_context := + r_physical_workplace.id_context; + if nvl(r_physical_workplace.workplace_type_id, n_null) <> + nvl(aior_physical_workplace.workplace_type_id, n_null) or + nvl(r_physical_workplace.code, v_null) <> + nvl(aior_physical_workplace.code, v_null) or + nvl(r_physical_workplace.name, v_null) <> + nvl(aior_physical_workplace.name, v_null) or + nvl(r_physical_workplace.active_date, d_null) <> + nvl(aior_physical_workplace.active_date, d_null) or + nvl(r_physical_workplace.inactive_date, d_null) <> + nvl(aior_physical_workplace.inactive_date, d_null) then + begin + update PHYSICAL_WORKPLACE_T + set workplace_type_id = + aior_physical_workplace.workplace_type_id, + code = + aior_physical_workplace.code, + name = + aior_physical_workplace.name, + active_date = + aior_physical_workplace.active_date, + inactive_date = + aior_physical_workplace.inactive_date + where id = + aior_physical_workplace.id; + + n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20002, SQLERRM|| + ' on update PHYSICAL_WORKPLACE_T'|| + ' in PHYSICAL_WORKPLACE_TS.set_row()' ); + end; + end if; + else + -- add the row if it does not exist + begin + if aior_physical_workplace.id is NULL then + aior_physical_workplace.id := get_id(); + end if; + aior_physical_workplace.id_context := + create_id_context( + aior_physical_workplace.parent_id, + aior_physical_workplace.id ); + insert into PHYSICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date, + inactive_date ) + values ( + aior_physical_workplace.id, + aior_physical_workplace.parent_id, + aior_physical_workplace.id_context, + aior_physical_workplace.workplace_type_id, + aior_physical_workplace.code, + aior_physical_workplace.name, + aior_physical_workplace.active_date, + aior_physical_workplace.inactive_date ); + + n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20003, SQLERRM|| + ' on insert PHYSICAL_WORKPLACE_T'|| + ' in PHYSICAL_WORKPLACE_TS.set_row()' ); + end; + end if; +end set_row; + + +PROCEDURE test is + +/* +PHYSICAL_WORKPLACE_T + Name Null? Type + ---------------------------------------- -------- ------------- + PHYSICAL_WORKPLACE_ID NOT NULL NUMBER + PARENT_ID NUMBER + ID_CONTEXT NOT NULL VARCHAR2(100) + WORKPLACE_TYPE_ID NOT NULL NUMBER + CODE NOT NULL VARCHAR2(30) + NAME NOT NULL VARCHAR2(80) + ACTIVE_DATE NOT NULL DATE + INACTIVE_DATE DATE +*/ + +v_id_context + PHYSICAL_WORKPLACE_T.id_context%TYPE; +r_physical_workplace PHYSICAL_WORKPLACE_T%ROWTYPE; + +begin + pl('PHYSICAL_WORKPLACE_TS.test()'); + + TEST_TS.clear('PHYSICAL_WORKPLACE_TS'); + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'DELETE', 0, + 'Delete existing test entries'); + begin + delete PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + + delete PHYSICAL_WORKPLACE_T + where code = TEST_TS.v_TEST_30; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'get_id()', 1, + 'Allocate the next primary key value'); + begin + r_physical_workplace.id := get_id(); + + if r_physical_workplace.id > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', + 'create_id_context()', 2, 'Create an ID context value'); + begin + r_physical_workplace.parent_id := NULL; + r_physical_workplace.id_context := + create_id_context( + r_physical_workplace.parent_id, + r_physical_workplace.id); + + if r_physical_workplace.id_context = + to_char(r_physical_workplace.id) then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'set_row()', 3, + 'Insert parent test entry'); + begin + r_physical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('C'); + r_physical_workplace.code := + TEST_TS.v_TEST_30; + r_physical_workplace.name := + TEST_TS.v_TEST_80; + r_physical_workplace.active_date := + TEST_TS.d_TEST_19000101; + r_physical_workplace.inactive_date := NULL; + set_row(r_physical_workplace); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'set_row()', 4, + 'Insert child entries'); + begin + r_physical_workplace.parent_id := + r_physical_workplace.id; + r_physical_workplace.id := get_id(); + r_physical_workplace.id_context := + create_id_context( + r_physical_workplace.parent_id, + r_physical_workplace.id); + -- save this value for testing get_row() + v_id_context := + r_physical_workplace.id_context; + r_physical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('B'); + r_physical_workplace.code := + TEST_TS.v_TEST_30_1; + r_physical_workplace.name := + TEST_TS.v_TEST_80; + set_row(r_physical_workplace); + + + r_physical_workplace.id := get_id(); + r_physical_workplace.id_context := + create_id_context( + r_physical_workplace.parent_id, + r_physical_workplace.id); + r_physical_workplace.code := + TEST_TS.v_TEST_30_2; + set_row(r_physical_workplace); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'get_code_context()', 5, + 'Get the code context for v_TEST_30_2'); + begin + pl(get_code_context( + r_physical_workplace.id)); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'get_name_context()', 6, + 'Get the name context for v_TEST_30_2'); + begin + pl(get_name_context( + r_physical_workplace.id)); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'get_row()', 7, + 'Get the row using the id for v_TEST_30_2'); + begin +-- r_physical_workplace.id := NULL; + r_physical_workplace.parent_id := NULL; + r_physical_workplace.id_context := NULL; + r_physical_workplace.workplace_type_id := NULL; + r_physical_workplace.code := NULL; + r_physical_workplace.name := NULL; + r_physical_workplace.active_date := NULL; + r_physical_workplace.inactive_date := NULL; + + r_physical_workplace := get_row(r_physical_workplace); + + if r_physical_workplace.id_context is not NULL then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'get_row()', 8, + 'Get the row using the id_context for v_TEST_30_1'); + begin + r_physical_workplace.id := NULL; + r_physical_workplace.parent_id := NULL; + r_physical_workplace.id_context := + v_id_context; + r_physical_workplace.workplace_type_id := NULL; + r_physical_workplace.code := NULL; + r_physical_workplace.name := NULL; + r_physical_workplace.active_date := NULL; + r_physical_workplace.inactive_date := NULL; + + r_physical_workplace := get_row(r_physical_workplace); + + if r_physical_workplace.id is not NULL then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + pl('v_id_context="'||v_id_context||'"'); + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'get_row()', 9, + 'Get the row using the code for v_TEST_30'); + begin + r_physical_workplace.id := NULL; + r_physical_workplace.parent_id := NULL; + r_physical_workplace.id_context := NULL; + r_physical_workplace.workplace_type_id := NULL; + r_physical_workplace.code := + TEST_TS.v_TEST_30; + r_physical_workplace.name := + TEST_TS.v_TEST_80; + r_physical_workplace.active_date := + TEST_TS.d_TEST_19000101; + r_physical_workplace.inactive_date := NULL; + + r_physical_workplace := get_row(r_physical_workplace); + + if r_physical_workplace.id is not NULL then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'help()', 10, + 'Display the help text'); + begin + help(); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'DELETE', 11, + 'Delete test entries'); + begin + delete PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + + delete PHYSICAL_WORKPLACE_T + where code = TEST_TS.v_TEST_30; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + commit; + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end PHYSICAL_WORKPLACE_TS; +/ +@be.sql PHYSICAL_WORKPLACE_TS + diff --git a/Chapter08/solutions/physical_workplace_ts.pks b/Chapter08/solutions/physical_workplace_ts.pks new file mode 100644 index 0000000..411a7f0 --- /dev/null +++ b/Chapter08/solutions/physical_workplace_ts.pks @@ -0,0 +1,103 @@ +create or replace PACKAGE PHYSICAL_WORKPLACE_TS as +/* +physical_workplace_ts.pks
+by Don Bales on 12/15/2006
+Table PHYSICAL_WORKPLACE_T's methods.
+Contains all the supporting service methods (functions and procedures) +for table PHYSICAL_WORKPLACE_T. +*/ + +-- GLOBAL VARIABLES + +-- Keep track of the number of inserts and updates to made by set_row( ). +n_inserted number := 0; +n_updated number := 0; + +/* +Returns an id_context for the specified parent_id and id. +Whatever creates a new row must also call this mehtod to create an appropriate +id_context value. Method set_row( ) does this for you. +*/ +FUNCTION create_id_context( +ain_parent_id in PHYSICAL_WORKPLACE_T.parent_id%TYPE, +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return PHYSICAL_WORKPLACE_T.id%TYPE; + +/* +Returns the value of a context for the code values in the physical workplace assignment. +*/ +FUNCTION get_code_context( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns the value of a context for the name values in the physical workplace assignment. +*/ +FUNCTION get_name_context( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns a PHYSICAL_WORKPLACE row for the specified criteria. + +There are three sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the unique id_context
+3. the code, name, and active_date
+ +If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_physical_workplace in PHYSICAL_WORKPLACE_T%ROWTYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE; + +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + +/* +Updates or inserts a row matching the passed parameters into table PHYSICAL_WORKPLACE_T. +See PROCEDURE set_row( ). +*/ +FUNCTION set_row( +ain_parent_id in PHYSICAL_WORKPLACE_T.parent_id%TYPE, +ain_workplace_type_id in PHYSICAL_WORKPLACE_T.workplace_type_id%TYPE, +aiv_code in PHYSICAL_WORKPLACE_T.code%TYPE, +aiv_name in PHYSICAL_WORKPLACE_T.name%TYPE, +aid_active_date in PHYSICAL_WORKPLACE_T.active_date%TYPE) +return PHYSICAL_WORKPLACE_T.id%TYPE; + +/* +Updates or inserts a row matching the passed row into table PHYSICAL_WORKPLACE_T. + +First, set_row() calls get row to try to find a matching row that already +exists in the database. So you need to set the id, id_context, +and code, name and active_date appropriately in order to prperly detect an +existing row. + +Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise, and new row is inserted, including the allocation of +a new primary key and id_context value. Upon inserting a new value, the +id and id_context values are updated in the passed row. +See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_physical_workplace in out PHYSICAL_WORKPLACE_T%ROWTYPE); + +/* +Performs unit tests for this package. +*/ +PROCEDURE test; + +end PHYSICAL_WORKPLACE_TS; +/ +@se.sql PHYSICAL_WORKPLACE_TS + diff --git a/Chapter08/solutions/test_o.tpb b/Chapter08/solutions/test_o.tpb new file mode 100644 index 0000000..1ba466c --- /dev/null +++ b/Chapter08/solutions/test_o.tpb @@ -0,0 +1,424 @@ +create or replace type body TEST_O as +/* +test_o.tpb +by Donald J. Bales on 12/15/2006 +A Type for logging test results +*/ + +STATIC PROCEDURE clear( +aiv_object_name varchar2) is + +pragma autonomous_transaction; + +begin + delete TEST_OT + where object_name = aiv_object_name + and unique_session_id = SYS.DBMS_SESSION.unique_session_id; + + commit; +end clear; + + +STATIC FUNCTION get_id +return number is + +n_id number; + +begin + select TEST_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +STATIC FUNCTION get_test_19000101 +return date is + +begin + return to_date('19000101', 'YYYYMMDD'); +end get_test_19000101; + + +STATIC FUNCTION get_test_19991231 +return date is + +begin + return to_date('19991231', 'YYYYMMDD'); +end get_test_19991231; + + +STATIC FUNCTION get_test_n +return varchar2 is + +begin + return 'N'; +end get_test_n; + + +STATIC FUNCTION get_test_y +return varchar2 is + +begin + return 'Y'; +end get_test_y; + + +STATIC FUNCTION get_test_30 +return varchar2 is + +begin + return 'TEST TEST TEST TEST TEST TESTx'; +end get_test_30; + + +STATIC FUNCTION get_test_30_1 +return varchar2 is + +begin + return 'TEST1 TEST1 TEST1 TEST1 TEST1x'; +end get_test_30_1; + + +STATIC FUNCTION get_test_30_2 +return varchar2 is + +begin + return 'TEST2 TEST2 TEST2 TEST2 TEST2x'; +end get_test_30_2; + + +STATIC FUNCTION get_test_80 +return varchar2 is + +begin + return 'Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Testx'; +end get_test_80; + + +STATIC FUNCTION get_test_100 +return varchar2 is + +begin + return 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Testx'; +end get_test_100; + + +STATIC FUNCTION get_test_2000 +return varchar2 is +-- 1 2 3 4 5 +-- 12345678901234567890123456789012345678901234567890 +begin + return 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Testx'; +end get_test_2000; + + +STATIC PROCEDURE help is +begin + pl('You''re on your own buddy.'); +end help; + + +MEMBER PROCEDURE error is + +begin + set_result('ERROR'); +end error; + + +MEMBER PROCEDURE error( +aiv_result in varchar2) is + +begin + set_result(aiv_result); +end error; + + +MEMBER PROCEDURE ok is + +begin + set_result('OK'); +end ok; + + +MEMBER PROCEDURE set_result( +aiv_result in varchar2) is + +pragma autonomous_transaction; + +begin + result := aiv_result; + + update TEST_OT + set result = self.result + where id = self.id; + + if nvl(sql%rowcount, 0) = 0 then + raise_application_error(-20000, 'Can''t find test'|| + to_char(self.id)|| + ' on update TEST'|| + ' in TEST_TS.test'); + end if; + + self := new test_o(); + + commit; +end set_result; + + +MEMBER PROCEDURE set_test( +aiv_object_name in varchar2, +aiv_method_name in varchar2, +ain_test_number in number, +aiv_description in varchar2) is + +pragma autonomous_transaction; + +begin + self.id := TEST_O.get_id(); + self.object_name := upper(aiv_object_name); + self.method_name := upper(aiv_method_name); + self.test_number := ain_test_number; + self.description := aiv_description; + self.result := NULL; + self.unique_session_id := SYS.DBMS_SESSION.unique_session_id; + self.insert_user := USER; + self.insert_date := SYSDATE; + + begin + insert into TEST_OT values (self); + exception + when OTHERS then + raise_application_error(-20000, SQLERRM|| + ' on insert TEST_OT'|| + ' in TEST_O.set_test'); + end; + commit; +end set_test; + + +MEMBER PROCEDURE success is + +begin + set_result('SUCCESS'); +end success; + + +STATIC PROCEDURE test is + +n_number number; +o_test TEST_O; + +begin + pl('TEST_O.test()'); + + -- A defect requires the schema owner + &_USER..TEST_O.clear('TEST_O'); + + o_test := new TEST_O(); + o_test.set_test('TEST_O', NULL, 1, + 'Is get_test_N equal to N?'); + if TEST_O.get_test_N = 'N' then + o_test.success(); + else + o_test.error(); + end if; + + o_test.set_test('TEST_O', NULL, 2, + 'Is the length of get_test_N equal to 1?'); + if nvl(length(TEST_O.get_test_N), 0) = 1 then + o_test.success(); + else + o_test.error(); + end if; + + o_test.set_test('TEST_O', NULL, 3, + 'Is get_test_Y equal to Y?'); + if TEST_O.get_test_Y = 'Y' then + o_test.success(); + else + o_test.error(); + end if; + + o_test.set_test('TEST_O', NULL, 4, + 'Is the length of get_test_Y equal to 1?'); + if nvl(length(TEST_O.get_test_Y), 0) = 1 then + o_test.success(); + else + o_test.error(); + end if; + + o_test.set_test('TEST_O', NULL, 5, + 'Is the length of get_test_30 equal to 30?'); + if nvl(length(TEST_O.get_test_30), 0) = 30 then + o_test.success(); + else + o_test.error(); + end if; + + o_test.set_test('TEST_O', NULL, 6, + 'Is the length of get_test_30_1 equal to 30?'); + if nvl(length(TEST_O.get_test_30_1), 0) = 30 then + o_test.success(); + else + o_test.error(); + end if; + + o_test.set_test('TEST_O', NULL, 7, + 'Is the length of get_test_30_2 equal to 30?'); + if nvl(length(TEST_O.get_test_30_2), 0) = 30 then + o_test.success(); + else + o_test.error(); + end if; + + o_test.set_test('TEST_O', NULL, 8, + 'Is the length of get_test_80 equal to 80?'); + if nvl(length(TEST_O.get_test_80), 0) = 80 then + o_test.success(); + else + o_test.error(); + end if; + + o_test.set_test('TEST_O', NULL, 9, + 'Is the length of get_test_100 equal to 100?'); + if nvl(length(TEST_O.get_test_100), 0) = 100 then + o_test.success(); + else + o_test.error(); + end if; + + o_test.set_test('TEST_O', NULL, 10, + 'Is the length of get_test_2000 equal to 2000?'); + if nvl(length(TEST_O.get_test_2000), 0) = 2000 then + o_test.success(); + else + o_test.error(); + end if; + + o_test.set_test('TEST_O', 'get_id', 11, + 'Does get_id() work?'); + begin + n_number := TEST_O.get_id(); + if n_number > 0 then + o_test.success(); + else + o_test.error(); + end if; + exception + when OTHERS then + o_test.error(SQLERRM); + end; + + o_test.set_test('TEST_O', 'help', 12, + 'Does help() work?'); + begin + &_USER..TEST_O.help(); + raise_application_error(-20999, 'Testing the error routine'); + o_test.success(); + exception + when OTHERS then + o_test.error(SQLERRM); + end; + + o_test.set_test('TEST_O', NULL, NULL, NULL); + o_test.success(); +end test; + + +MAP MEMBER FUNCTION to_map +return number is + +begin + return self.id; +end to_map; + + +CONSTRUCTOR FUNCTION test_o( +self in out nocopy test_o) +return self as result is + +begin + self.id := NULL; + self.object_name := NULL; + self.method_name := NULL; + self.test_number := NULL; + self.description := NULL; + self.result := NULL; + self.unique_session_id := NULL; + self.insert_user := NULL; + self.insert_date := NULL; + + return; +end test_o; + + +CONSTRUCTOR FUNCTION test_o( +self in out nocopy test_o, +ain_id in number, +aiv_object_name in varchar2, +aiv_method_name in varchar2, +ain_test_number in number, +aiv_description in varchar2) +return self as result is + +begin + self.id := ain_id; + self.object_name := aiv_object_name; + self.method_name := aiv_method_name; + self.test_number := ain_test_number; + self.description := aiv_description; + self.result := NULL; + self.unique_session_id := SYS.DBMS_SESSION.unique_session_id; + self.insert_user := USER; + self.insert_date := SYSDATE; + + return; +end test_o; + + +end; +/ +@be.sql TEST_O diff --git a/Chapter08/solutions/test_o.tps b/Chapter08/solutions/test_o.tps new file mode 100644 index 0000000..236e10e --- /dev/null +++ b/Chapter08/solutions/test_o.tps @@ -0,0 +1,121 @@ +execute drop_if_exists('TABLE','TEST_OT'); +execute drop_if_exists('VIEW','TEST_OV'); +execute drop_if_exists('TYPE','TEST_O'); +create type TEST_O as object ( +/* +test_o.tps +by Donald J. Bales on 12/15/2006 +A Type for logging test results +*/ +-- Type TEST_O's attributes +id number, +object_name varchar2(30), +method_name varchar2(30), +test_number number, +description varchar2(80), +result varchar2(256), +unique_session_id varchar2(24), +insert_user varchar2(30), +insert_date date, + +-- Allocate the next primary key value fir id +STATIC FUNCTION get_id +return number, + +-- Get the test value for January 1, 1900 +STATIC FUNCTION get_test_19000101 +return date, + +-- Get the test value for December 31, 1999 +STATIC FUNCTION get_test_19991231 +return date, + +-- Get the test value N for any indicators +STATIC FUNCTION get_test_n +return varchar2, + +-- Get the test value Y for any indicators +STATIC FUNCTION get_test_y +return varchar2, + +-- Get the 30 character test value +STATIC FUNCTION get_test_30 +return varchar2, + +-- Get the first 30 character test value duplicate for LIKE +STATIC FUNCTION get_test_30_1 +return varchar2, + +-- Get the second 30 character test value duplicate for LIKE +STATIC FUNCTION get_test_30_2 +return varchar2, + +-- Get the 80 character test value +STATIC FUNCTION get_test_80 +return varchar2, + +-- Get the 100 character test value +STATIC FUNCTION get_test_100 +return varchar2, + +-- Get the 2000 character test value +STATIC FUNCTION get_test_2000 +return varchar2, + +-- Clear any previous test run for the specified object name +STATIC PROCEDURE clear( +aiv_object_name varchar2), + +-- Set the result to ERROR +MEMBER PROCEDURE error, + +-- Set the result to Oracle ERROR +MEMBER PROCEDURE error( +aiv_result in varchar2), + +-- Set the result to the specified result value +MEMBER PROCEDURE set_result( +aiv_result in varchar2), + +-- Show the help text for this object +STATIC PROCEDURE help, + +-- Set the result to OK +MEMBER PROCEDURE ok, + +-- Set the result of the execution of test() to SUCCESS +MEMBER PROCEDURE success, + +-- Test this object +STATIC PROCEDURE test, + +-- Set the test about to be performed +MEMBER PROCEDURE set_test( +aiv_object_name in varchar2, +aiv_method_name in varchar2, +ain_test_number in number, +aiv_description in varchar2), + +-- Get the map value +MAP MEMBER FUNCTION to_map +return number, + +-- Parameter-less constructor +CONSTRUCTOR FUNCTION test_o( +self in out nocopy test_o) +return self as result, + +-- Convenience constructor +CONSTRUCTOR FUNCTION test_o( +self in out nocopy test_o, +ain_id in number, +aiv_object_name in varchar2, +aiv_method_name in varchar2, +ain_test_number in number, +aiv_description in varchar2) +return self as result +); +/ +@se.sql + +grant execute on TEST_O to public; diff --git a/Chapter08/solutions/test_ot.tab b/Chapter08/solutions/test_ot.tab new file mode 100644 index 0000000..f57d33d --- /dev/null +++ b/Chapter08/solutions/test_ot.tab @@ -0,0 +1,25 @@ +rem test_ot.tab +rem by Donald Bales on 12/15/2006 +rem Create test results + +execute drop_if_exists('TABLE','TEST_OT'); +table TEST_OT; +create table TEST_OT of TEST_O +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +alter table TEST_OT add +constraint TEST_OT_PK +primary key ( +id ) +using index +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +--drop sequence TEST_ID_SEQ; +--create sequence TEST_ID_SEQ +--start with 1 order; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'TEST_OT'); + +grant all on TEST_OT to PUBLIC; diff --git a/Chapter08/test.sql b/Chapter08/test.sql new file mode 100644 index 0000000..d6a7fd9 --- /dev/null +++ b/Chapter08/test.sql @@ -0,0 +1,169 @@ +rem test.sql +rem by Donald J. Bales on 12/15/2006 +rem An anonymous PL/SQL procedure to execute all test units +rem and to report on the results of each test. + +declare + +-- Get the names of all packages and types that have a test unit +cursor c_test is +select a.package_name +from SYS.ALL_ARGUMENTS a +where a.owner = USER +and a.object_name = 'TEST' +and nvl(a.argument_name, 'SELF') = 'SELF' +and not exists ( +select 1 +from SYS.ALL_ARGUMENTS x +where x.owner = a.owner +and x.package_name = a.package_name +and x.object_name = a.object_name +and nvl(x.overload, 0) = nvl(a.overload, 0) +and x.object_id = a.object_id +and nvl(a.argument_name, 'SELF') <> 'SELF' ) +order by 1; + +-- Get the names of all packages and types that don't have a test unit +cursor c_missing is +select a.package_name +from SYS.ALL_ARGUMENTS a +where a.owner = USER +MINUS +select a.package_name +from SYS.ALL_ARGUMENTS a +where a.owner = USER +and a.object_name = 'TEST' +and nvl(a.argument_name, 'SELF') = 'SELF' +and not exists ( +select 1 +from SYS.ALL_ARGUMENTS x +where x.owner = a.owner +and x.package_name = a.package_name +and x.object_name = a.object_name +and nvl(x.overload, 0) = nvl(a.overload, 0) +and x.object_id = a.object_id +and nvl(a.argument_name, 'SELF') <> 'SELF' ) +order by 1; + +-- Get the names of all packages and types that have test unit errors +cursor c_error is +select object_name|| + decode(substr(method_name, -1, 1), ')', '.', ' ')|| + method_name object_method, + test_number, + result +from TEST_T +where result <> 'OK' +and result <> 'SUCCESS' +order by 1; + +TYPE error_message_table is table of varchar2(255) +index by binary_integer; + +n_error_message number := 0; +n_object_method_width number := 39; +n_result_width number := 29; +n_status number; +n_test_number_width number := 5; + +t_error_message error_message_table; + +v_line varchar2(2000); + +begin + -- execute the test units + for r_test in c_test loop + begin + execute immediate 'begin '||r_test.package_name||'.test(); end;'; + exception + when OTHERS then + n_error_message := n_error_message + 1; + t_error_message(n_error_message) := + r_test.package_name||'.test() '||SQLERRM; + end; + end loop; + -- Empty the output buffer + loop + SYS.DBMS_OUTPUT.get_line(v_line, n_status); + if nvl(n_status, 0) < 1 then + exit; + end if; + end loop; + -- Show the test units that had errors + for r_error in c_error loop + if c_error%rowcount = 1 then + pl(chr(9)); + pl('THE FOLLOWING OBJECT''S TEST UNITS HAD ERRORS:'); + pl(chr(9)); + pl( + rpad( + substr('OBJECT/METHOD', + 1, n_object_method_width), + n_object_method_width, ' ')|| + ' '|| + lpad( + substr('TEST#', + 1, n_test_number_width), + n_test_number_width, ' ')|| + ' '|| + rpad( + substr('ERROR', + 1, n_result_width), + n_result_width, ' ') + ); + pl( + rpad( + substr('-------------', + 1, n_object_method_width), + n_object_method_width, '-')|| + ' '|| + lpad( + substr('-----', + 1, n_test_number_width), + n_test_number_width, '-')|| + ' '|| + rpad( + substr('-----', + 1, n_result_width), + n_result_width, '-') + ); + end if; + pl( + rpad( + substr(r_error.object_method, + 1, n_object_method_width), + n_object_method_width, ' ')|| + ' '|| + lpad( + substr(ltrim(to_char(r_error.test_number)), + 1, n_test_number_width), + n_test_number_width, ' ')|| + ' '|| + rpad( + substr(r_error.result, + 1, n_result_width), + n_result_width, ' ') + ); + end loop; + -- Show the test units that failed to run + for i in t_error_message.first..t_error_message.last loop + if i = t_error_message.first then + pl(chr(9)); + pl('THE FOLLOWING OBJECT''S TEST UNITS FAILED:'); + end if; + pl(chr(9)); + pl(t_error_message(i)); + end loop; + -- Show the object that missing test units + for r_missing in c_missing loop + if c_missing%rowcount = 1 then + pl(chr(9)); + pl('THE FOLLOWING OBJECTS ARE MISSING TEST UNITS:'); + pl(chr(9)); + end if; + pl(r_missing.package_name); + end loop; +end; +/ + + \ No newline at end of file diff --git a/Chapter08/test_t.tab b/Chapter08/test_t.tab new file mode 100644 index 0000000..b6de301 --- /dev/null +++ b/Chapter08/test_t.tab @@ -0,0 +1,33 @@ +rem test.tab +rem by Donald Bales on 12/15/2006 +rem Create test results + +execute drop_if_exists('TABLE','TEST_T'); +create table TEST_T ( +id number not null, +object_name varchar2(30), +method_name varchar2(30), +test_number number, +description varchar2(80), +result varchar2(256), +unique_session_id varchar2(24) not null, +insert_user varchar2(30) default USER not null, +insert_date date default SYSDATE not null ) +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +alter table TEST_T add +constraint TEST_T_PK +primary key ( +id ) +using index +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +execute drop_if_exists('SEQUENCE','TEST_ID_SEQ'); +create sequence TEST_ID_SEQ +start with 1 order; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'TEST_T'); + +grant all on TEST_T to PUBLIC; diff --git a/Chapter08/test_ts.pkb b/Chapter08/test_ts.pkb new file mode 100644 index 0000000..0738d84 --- /dev/null +++ b/Chapter08/test_ts.pkb @@ -0,0 +1,266 @@ +create or replace package body TEST_TS as +/* +test_ts.pkb +by Donald J. Bales on 12/15/2006 +A Testing package +*/ + +-- Hold this value across calls to test() and result() +n_id TEST_T.id%TYPE; + + +PROCEDURE clear( +aiv_object_name TEST_T.object_name%TYPE) is + +pragma autonomous_transaction; + +begin + delete TEST_T + where object_name = aiv_object_name + and unique_session_id = SYS.DBMS_SESSION.unique_session_id; + + commit; +end clear; + + +PROCEDURE error is + +begin + set_result(v_TEST_ERROR); +end error; + + +PROCEDURE error( +aiv_result in TEST_T.result%TYPE) is + +begin + set_result(aiv_result); +end error; + + +FUNCTION get_id +return TEST_T.id%TYPE is + +n_id TEST_T.id%TYPE; + +begin + select TEST_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +PROCEDURE help is +begin + pl('You''re on your own buddy.'); +end help; + + +PROCEDURE initialize is +begin + null; +end; + + +PROCEDURE ok is + +begin + set_result(v_TEST_OK); +end ok; + + +PROCEDURE set_result( +aiv_result in TEST_T.result%TYPE) is + +pragma autonomous_transaction; + +begin + update TEST_T + set result = aiv_result + where id = n_id; + + if nvl(sql%rowcount, 0) = 0 then + raise_application_error(-20000, 'Can''t find test'|| + to_char(n_id)|| + ' on update TEST'|| + ' in TEST_TS.test'); + end if; + + n_id := NULL; + + commit; +end set_result; + + +PROCEDURE set_test( +aiv_object_name in TEST_T.object_name%TYPE, +aiv_method_name in TEST_T.method_name%TYPE, +ain_test_number in TEST_T.test_number%TYPE, +aiv_description in TEST_T.description%TYPE) is + +pragma autonomous_transaction; + +begin + n_id := get_id(); + + begin + insert into TEST_T ( + id, + object_name, + method_name, + test_number, + description, + result, + unique_session_id, + insert_user, + insert_date ) + values ( + n_id, + upper(aiv_object_name), + upper(aiv_method_name), + ain_test_number, + aiv_description, + NULL, + SYS.DBMS_SESSION.unique_session_id, + USER, + SYSDATE ); + exception + when OTHERS then + raise_application_error(-20000, SQLERRM|| + ' on insert TEST'|| + ' in TEST_TS.test'); + end; + commit; +end set_test; + + +PROCEDURE success is + +begin + set_result(v_TEST_SUCCESS); +end success; + + +PROCEDURE test is + +n_number number; + +begin + pl('TESTS.test()'); + clear('TEST_TS'); + + TEST_TS.set_test('TEST_TS', NULL, 1, + 'Is v_TEST_N equal to N?'); + if v_TEST_N = 'N' then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + + TEST_TS.set_test('TEST_TS', NULL, 2, + 'Is the length of v_TEST_N equal to 1?'); + if nvl(length(v_TEST_N), 0) = 1 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + + TEST_TS.set_test('TEST_TS', NULL, 3, + 'Is v_TEST_Y equal to Y?'); + if v_TEST_Y = 'Y' then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + + TEST_TS.set_test('TEST_TS', NULL, 4, + 'Is the length of v_TEST_Y equal to 1?'); + if nvl(length(v_TEST_Y), 0) = 1 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + + TEST_TS.set_test('TEST_TS', NULL, 5, + 'Is the length of v_TEST_30 equal to 30?'); + if nvl(length(v_TEST_30), 0) = 30 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + + TEST_TS.set_test('TEST_TS', NULL, 6, + 'Is the length of v_TEST_30_1 equal to 30?'); + if nvl(length(v_TEST_30_1), 0) = 30 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + + TEST_TS.set_test('TEST_TS', NULL, 7, + 'Is the length of v_TEST_30_2 equal to 30?'); + if nvl(length(v_TEST_30_2), 0) = 30 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + + TEST_TS.set_test('TEST_TS', NULL, 8, + 'Is the length of v_TEST_80 equal to 80?'); + if nvl(length(v_TEST_80), 0) = 80 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + + TEST_TS.set_test('TEST_TS', NULL, 9, + 'Is the length of v_TEST_100 equal to 100?'); + if nvl(length(v_TEST_100), 0) = 100 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + + TEST_TS.set_test('TEST_TS', NULL, 10, + 'Is the length of v_TEST_2000 equal to 2000?'); + if nvl(length(v_TEST_2000), 0) = 2000 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + + TEST_TS.set_test('TEST_TS', 'get_id', 11, + 'Does get_id() work?'); + begin + n_number := get_id(); + if n_number > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('TEST_TS', 'help', 12, + 'Does help() work?'); + begin + help(); +-- raise_application_error(-20999, 'Testing test unit report'); + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('TEST_TS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end TEST_TS; +/ +@be.sql TESTS diff --git a/Chapter08/test_ts.pks b/Chapter08/test_ts.pks new file mode 100644 index 0000000..9c2807d --- /dev/null +++ b/Chapter08/test_ts.pks @@ -0,0 +1,134 @@ +create or replace package TEST_TS as +/* +test_ts.pks +by Donald J. Bales on 12/15/2006 +A Testing package +*/ + +-- Result constants +v_TEST_ERROR constant varchar2(5) := 'ERROR'; +v_TEST_OK constant varchar2(2) := 'OK'; +v_TEST_SUCCESS constant varchar2(7) := 'SUCCESS'; + +-- Testing constants +d_TEST_19000101 constant date := + to_date('19000101', 'YYYYMMDD'); +d_TEST_19991231 constant date := + to_date('19000101', 'YYYYMMDD'); + +v_TEST_N constant varchar2(1) := 'N'; + +v_TEST_Y constant varchar2(1) := 'Y'; + +v_TEST_30 constant varchar2(30) := + 'TEST TEST TEST TEST TEST TESTx'; + +v_TEST_30_1 constant varchar2(30) := + 'TEST1 TEST1 TEST1 TEST1 TEST1x'; + +v_TEST_30_2 constant varchar2(30) := + 'TEST2 TEST2 TEST2 TEST2 TEST2x'; + +v_TEST_80 constant varchar2(80) := + 'Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Testx'; + +v_TEST_100 constant varchar2(100) := + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Testx'; + +v_TEST_2000 constant varchar2(2000) := + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Testx'; + +-- 1 2 3 4 5 +-- 12345678901234567890123456789012345678901234567890 + +-- Clear the results of the last test +PROCEDURE clear( +aiv_object_name TEST_T.object_name%TYPE); + + +-- Set the result of the last test to v_TEST_ERROR +PROCEDURE error; + + +-- Set the result of the last test to the passed Oracle error +PROCEDURE error( +aiv_result in TEST_T.result%TYPE); + + +-- Display help text +PROCEDURE help; + + +-- Instantiate the package +PROCEDURE initialize; + + +-- Set the result of the last test to v_TEST_OK +PROCEDURE ok; + + +-- Update the test with it's results +PROCEDURE set_result( +aiv_result in TEST_T.result%TYPE); + + +-- Add a test +PROCEDURE set_test( +aiv_object_name in TEST_T.object_name%TYPE, +aiv_method_name in TEST_T.method_name%TYPE, +ain_test_number in TEST_T.test_number%TYPE, +aiv_description in TEST_T.description%TYPE); + + +-- Set the result of the last test to v_TEST_SUCCESS +PROCEDURE success; + + +-- Test unit +PROCEDURE test; + + +end TEST_TS; +/ +@se.sql TEST_TS diff --git a/Chapter08/worker_type_ts.pkb b/Chapter08/worker_type_ts.pkb new file mode 100644 index 0000000..9007f04 --- /dev/null +++ b/Chapter08/worker_type_ts.pkb @@ -0,0 +1,351 @@ +create or replace PACKAGE BODY WORKER_TYPE_TS as +/* +worker_type_ts.pkb +by Don Bales on 12/15/2006 +Table WORKER_TYPE_T's methods +*/ + + +PROCEDURE get_code_descr( +ain_id in WORKER_TYPE_T.id%TYPE, +aov_code out WORKER_TYPE_T.code%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE ) is + +begin + select code, + description + into aov_code, + aov_description + from WORKER_TYPE_T + where id = ain_id; +end get_code_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out WORKER_TYPE_T.code%TYPE, +aon_id out WORKER_TYPE_T.id%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE, +aid_on in WORKER_TYPE_T.active_date%TYPE ) is + +v_code WORKER_TYPE_T.code%TYPE; + +begin + select id, + description + into aon_id, + aov_description + from WORKER_TYPE_T + where code = aiov_code + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); +exception + when NO_DATA_FOUND then + select id, + code, + description + into aon_id, + v_code, + aov_description + from WORKER_TYPE_T + where code like aiov_code||'%' + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); + + aiov_code := v_code; +end get_code_id_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out WORKER_TYPE_T.code%TYPE, +aon_id out WORKER_TYPE_T.id%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE ) is + +begin + get_code_id_descr( + aiov_code, + aon_id, + aov_description, + SYSDATE ); +end get_code_id_descr; + + +FUNCTION get_id +return WORKER_TYPE_T.id%TYPE is + +n_id WORKER_TYPE_T.id%TYPE; + +begin + select WORKER_TYPE_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_id( +aiv_code in WORKER_TYPE_T.code%TYPE ) +return WORKER_TYPE_T.id%TYPE is + +n_id WORKER_TYPE_T.id%TYPE; + +begin + select id + into n_id + from WORKER_TYPE_T + where code = aiv_code; + + return n_id; +end get_id; + + +PROCEDURE help is + +begin +-- 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('WORKER_TYPE_TS'); + pl(chr(9)); + pl('----------------------------------- FUNCTIONS ----------------------------------'); + pl(chr(9)); + pl('WORKER_TYPE_TS.get_id'); + pl('return WORKER_TYPE_T.id%TYPE;'); + pl(chr(9)||'Returns a newly allocated sequence value for id.'); + pl(chr(9)); + pl('WORKER_TYPE_TS.get_id('); + pl('aiv_code in WORKER_TYPE_T.code%TYPE )'); + pl('return WORKER_TYPE_T.id%TYPE;'); + pl(chr(9)||'Returns the corresponding id for the specified code.'); + pl(chr(9)); + pl('----------------------------------- PROCEDURES ---------------------------------'); + pl(chr(9)); + pl('WORKER_TYPE_TS.get_code_descr('); + pl('ain_id in WORKER_TYPE_T.id%TYPE,'); + pl('aov_code out WORKER_TYPE_T.code%TYPE,'); + pl('aov_description out WORKER_TYPE_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding code and description for the specified'); + pl(chr(9)||'id.'); + pl(chr(9)); + pl('WORKER_TYPE_TS.get_code_id_descr('); + pl('aiov_code in out WORKER_TYPE_T.code%TYPE,'); + pl('aon_id out WORKER_TYPE_T.id%TYPE,'); + pl('aov_description out WORKER_TYPE_T.description%TYPE,'); + pl('aid_on in WORKER_TYPE_T.active_date%TYPE );'); + pl(chr(9)||'Gets the corresponding code, id, and description for'); + pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified code and point in time.'); + pl(chr(9)); + pl('WORKER_TYPE_TS.get_code_id_descr('); + pl('aiov_code in out WORKER_TYPE_T.code%TYPE,'); + pl('aon_id out WORKER_TYPE_T.id%TYPE,'); + pl('aov_description out WORKER_TYPE_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding code, id, and description for'); + pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified code at the current point in time.'); + pl(chr(9)); + pl('WORKER_TYPE_TS.help( );'); + pl(chr(9)||'Displays this help text if set serveroutput is on.'); + pl(chr(9)); + pl('WORKER_TYPE_TS.test( );'); + pl(chr(9)||'Built-in test unit. It will report success or error for each test if set'); + pl(chr(9)||'serveroutput is on.'); + pl(chr(9)); +end help; + + +PROCEDURE test is + +n_id WORKER_TYPE_T.id%TYPE; +v_code WORKER_TYPE_T.code%TYPE; +v_description WORKER_TYPE_T.description%TYPE; + +begin + -- Send feedback that the test ran + pl('WORKER_TYPE_TS.test()'); + + -- Clear the last set of test results + TEST_TS.clear('WORKER_TYPE_TS'); + + -- First, we need some test values + + -- Let's make sure they don't already exist: DELETE + TEST_TS.set_test('WORKER_TYPE_TS', 'DELETE', 0, + 'Delete test entries'); + begin + delete WORKER_TYPE_T + where code in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Now let's add three test codes: INSERT + TEST_TS.set_test('WORKER_TYPE_TS', 'INSERT', 1, + 'Insert 3 test entries'); + begin + insert into WORKER_TYPE_T ( + id, + code, + description, + active_date, + inactive_date ) + values ( + get_id(), + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101, + NULL ); + + insert into WORKER_TYPE_T ( + id, + code, + description, + active_date, + inactive_date ) + values ( + get_id(), + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101, + TEST_TS.d_TEST_19991231 ); + + insert into WORKER_TYPE_T ( + id, + code, + description, + active_date, + inactive_date ) + values ( + get_id(), + TEST_TS.v_TEST_30_2, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101, + TEST_TS.d_TEST_19991231 ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Now that we have test entries, + -- let's test the package methods + TEST_TS.set_test('WORKER_TYPE_TS', 'get_id()', 2, + 'Get the ID for the specified code'); + begin + n_id := get_id(TEST_TS.v_TEST_30); + + if n_id > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORKER_TYPE_TS', 'get_code_descr()', 3, + 'Get the code and description for the specified ID'); + begin + get_code_descr( + n_id, + v_code, + v_description); + if v_code = TEST_TS.v_TEST_30 and + v_description = TEST_TS.v_TEST_80 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORKER_TYPE_TS', 'get_code_id_descr()', 4, + 'Get the code, ID, and description for the specified code'); + begin + v_code := 'TEST'; + get_code_id_descr( + v_code, + n_id, + v_description); + if v_code = TEST_TS.v_TEST_30 and + n_id > 0 and + v_description = TEST_TS.v_TEST_80 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORKER_TYPE_TS', 'get_code_id_descr()', 5, + 'Get the code, ID, and description for the specified date'); + begin + v_code := 'TEST'; + -- This test should raise a TOO_MANY_ROWS exception + -- because at least three duplicate values will + -- on the date specified + get_code_id_descr( + v_code, + n_id, + v_description, + TEST_TS.d_TEST_19991231); + if v_code = TEST_TS.v_TEST_30 and + n_id > 0 and + v_description = TEST_TS.v_TEST_80 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when TOO_MANY_ROWS then + TEST_TS.ok(); + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORKER_TYPE_TS', 'help()', 6, + 'Display help'); + begin + help(); + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Let's make sure they don't already exist: DELETE + TEST_TS.set_test('WORKER_TYPE_TS', 'DELETE', 7, + 'Delete test entries'); + begin + delete WORKER_TYPE_T + where code in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORKER_TYPE_TS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end WORKER_TYPE_TS; +/ +@be.sql WORKER_TYPE_TS diff --git a/Chapter08/worker_type_ts.pks b/Chapter08/worker_type_ts.pks new file mode 100644 index 0000000..310dd55 --- /dev/null +++ b/Chapter08/worker_type_ts.pks @@ -0,0 +1,55 @@ +create or replace PACKAGE WORKER_TYPE_TS as +/* +worker_type_ts.pks +by Don Bales on 12/15/2006 +Code Table WORKER_TYPE_T's methods. +*/ + + +-- Gets the code and decription values for the specified work_type_id. +PROCEDURE get_code_descr( +ain_id in WORKER_TYPE_T.id%TYPE, +aov_code out WORKER_TYPE_T.code%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE ); + + +-- Verifies the passed aiov_code value is an exact or like match on +-- the date specified. +PROCEDURE get_code_id_descr( +aiov_code in out WORKER_TYPE_T.code%TYPE, +aon_id out WORKER_TYPE_T.id%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE, +aid_on in WORKER_TYPE_T.active_date%TYPE ); + + +-- Verifies the passed aiov_code value is currently an exact or like +-- match. +PROCEDURE get_code_id_descr( +aiov_code in out WORKER_TYPE_T.code%TYPE, +aon_id out WORKER_TYPE_T.id%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE ); + + +-- Returns a newly allocated id value. +FUNCTION get_id +return WORKER_TYPE_T.id%TYPE; + + +-- Returns the id for the specified code value. +FUNCTION get_id( +aiv_code in WORKER_TYPE_T.code%TYPE ) +return WORKER_TYPE_T.id%TYPE; + + +-- Test-based help for this package. "set serveroutput on" in +-- SQL*Plus. +PROCEDURE help; + + +-- Test units for this package. +PROCEDURE test; + + +end WORKER_TYPE_TS; +/ +@se.sql WORKER_TYPE_TS diff --git a/Chapter09/README.txt b/Chapter09/README.txt new file mode 100644 index 0000000..f3e7171 --- /dev/null +++ b/Chapter09/README.txt @@ -0,0 +1,70 @@ +README.txt for Chapter 9 +by Donald J. Bales on 4/15/2007 + +OBJECT NAME DESCRIPTION +--------------------------------------- ------------------------------------- +be.sql Show package body compilation errors + +ci.sql Compile invalid objects + +create_html_help.sql A SQL*Plus script used to generate + HTML-based help for all packages and + TYPES + +desc.sql Describe an object + +fe.sql Show function compilation errors + +solutions\gender_ts.pkb Create table package GENDER_TS' body + +html_help.pkb Create utility package HTML_HELP's + body + +html_help.pks Create utility package HTML_HELP's + specification + +html_help.sql A SQL*Plus script generated by script + create_html_help.sql, used to + generate HTML-based help for all + packages and TYPES + +last_test_results.sql Show the last test() method's results + +last_test_results.txt The last test() method's results + +solutions\logical_assignment_ts.pkb Create table package + LOGICAL_ASSIGNMENT_TS' body + +solutions\logical_workplace_ts.pkb Create table package + LOGICAL_WORKPLACE_TS' specification + +login.sql Set my SQL*Plus defaults + +pe.sql Show procedure compilations errors + +solutions\physical_assignment_ts.pkb Create table package + PHYSICAL_ASSIGNMENT_TS' body + +solutions\physical_workplace_ts.pkb Create table package + PHYSICAL_WORKPLACE_TS' body + +pl.prc Don's handy-dandy "put_line" + procedure + +se.sql Show package specification + compilation errors + +stylesheet.css The style sheet for HTML-based help + generated by script + create_html_help.sql + +solutions\test_ts.pkb Create utility package TEST_TS' body + +text_help.pkb Create utility package TEXT_HELP's + body + +text_help.pks Create utility package TEXT_HELP's + specification + +solutions\worker_type_ts.pkb Create table package WORKER_TYPE_TS' + body diff --git a/Chapter09/be.sql b/Chapter09/be.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter09/be.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter09/ci.sql b/Chapter09/ci.sql new file mode 100644 index 0000000..6dcc7e7 --- /dev/null +++ b/Chapter09/ci.sql @@ -0,0 +1,50 @@ +rem ci.sql +rem by Donald J. Bales on 12/15/2006 +rem Compile my invalid objects + +set feedback off; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +set serveroutput on size 1000000; + +spool ci.txt; +declare + +cursor c1 is +select object_type, + object_name +from SYS.USER_OBJECTS +where status = 'INVALID' +order by 1, 2; + +v_sql varchar2(100); + +begin + for r1 in c1 loop + begin + if r1.object_type = 'PACKAGE BODY' then + v_sql := 'alter PACKAGE '||r1.object_name||' compile BODY'; + elsif r1.object_type = 'TYPE BODY' then + v_sql := 'alter TYPE '||r1.object_name||' compile BODY'; + else + v_sql := 'alter '||r1.object_type||' '||r1.object_name||' compile'; + end if; + execute immediate v_sql; + pl(r1.object_type||' '||r1.object_name||' compiled successfully'); + exception + when OTHERS then + pl(SQLERRM||' on '||v_sql); + end; + end loop; +end; +/ + +spool off; + +set feedback on; + + + + \ No newline at end of file diff --git a/Chapter09/ci.txt b/Chapter09/ci.txt new file mode 100644 index 0000000..e69de29 diff --git a/Chapter09/compile_all.sql b/Chapter09/compile_all.sql new file mode 100644 index 0000000..41e0e82 --- /dev/null +++ b/Chapter09/compile_all.sql @@ -0,0 +1,30 @@ +set echo on; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +spool compile_all.txt; +@pl.prc +@html_help.pks +@text_help.pks +@html_help.pkb +@text_help.pkb +@.\solutions\test_ts.pks +@.\solutions\dates.pks +@.\solutions\gender_ts.pks +@.\solutions\logical_assignment_ts.pks +@.\solutions\logical_workplace_ts.pks +@.\solutions\numbers.pks +@.\solutions\physical_assignment_ts.pks +@.\solutions\physical_workplace_ts.pks +@.\solutions\top_100_names.pks +@.\solutions\varchar2s.pks +@.\solutions\work_assignment_ts.pks +@.\solutions\work_ts.pks +@.\solutions\worker_ts.pks +@.\solutions\worker_type_ts.pks +@.\solutions\workplace_type_ts.pks +spool off; +set echo off; +@ci.sql +@ci.sql diff --git a/Chapter09/create_html_help.sql b/Chapter09/create_html_help.sql new file mode 100644 index 0000000..fb252d7 --- /dev/null +++ b/Chapter09/create_html_help.sql @@ -0,0 +1,45 @@ +rem create_html_help.sql +rem by Don Bales on 12/15/2006 +rem SQL*Plus script to create a SQL*Plus script to create html help for +rem the current user. + +set feedback off; +set linesize 1000; +set newpage 1; +set pagesize 0; +set trimspool on; +set serveroutput on size 1000000; + +spool html_help.sql; + +prompt rem html_help.sql +prompt rem by Don Bales on 12/15/2006 +prompt rem Created by SQL*Plus script create_html_help.sql +prompt; +prompt set feedback off;; +prompt set linesize 1000;; +prompt set newpage 1;; +prompt set pagesize 32767;; +prompt set trimspool on;; +prompt; +select 'spool '||lower(name)||'.html;'|| + chr(10)||'execute HTML_HELP.create_help('''||name||''');'|| + chr(10)||'spool off;'||chr(10) +from SYS.USER_SOURCE +where type in ('PACKAGE', 'TYPE') +group by name +order by name; + +prompt spool object_index.html;; +prompt execute HTML_HELP.create_index();; +prompt spool off;; +prompt; +prompt set feedback on;; +prompt set linesize 1000;; +prompt set newpage 1;; +prompt set pagesize 32767;; +prompt set trimspool on;; + +spool off; + +@html_help.sql diff --git a/Chapter09/desc.sql b/Chapter09/desc.sql new file mode 100644 index 0000000..45206dc --- /dev/null +++ b/Chapter09/desc.sql @@ -0,0 +1,6 @@ +define table_name="&1"; +set linesize 78; +prompt &table_name +desc &table_name +set linesize 1000; +undefine table_name \ No newline at end of file diff --git a/Chapter09/fe.sql b/Chapter09/fe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter09/fe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter09/html_help.pkb b/Chapter09/html_help.pkb new file mode 100644 index 0000000..404f089 --- /dev/null +++ b/Chapter09/html_help.pkb @@ -0,0 +1,888 @@ +create or replace PACKAGE BODY HTML_HELP as +/* +html_help.pkb +by Donald J. Bales on 12/15/2006 +Package to create HTML-based help files for packages +*/ + +-- TYPES + +TYPE spec_record is record ( +line_type varchar2(1), +line_number number, +line_text varchar2(2000), +method_name varchar2(2000), +first_sentence varchar2(2000)); + +TYPE spec_table is table of spec_record index by binary_integer; + +TYPE buffer_table is table of varchar2(2000) index by binary_integer; + +-- CONSTANTS + +v_LT_COMMENT constant varchar2(1) := 'C'; +v_LT_METHOD constant varchar2(1) := 'M'; +v_LT_OTHER constant varchar2(1) := 'O'; + +-- FORWARD DECLARATIONS + +FUNCTION get_comment_start( +aiv_text in varchar2) +return number; + + +FUNCTION get_comment_end( +aiv_text in varchar2) +return number; + + +FUNCTION get_method_end( +aiv_text in varchar2) +return number; + + +FUNCTION get_method_name_start( +aiv_text in varchar2) +return number; + + +FUNCTION get_method_name_end( +aiv_text in varchar2) +return number; + + +FUNCTION is_comment_start( +aiv_text in varchar2) +return boolean; + + +FUNCTION is_comment_end( +aiv_text in varchar2) +return boolean; + + +FUNCTION is_method_end( +aiv_text in varchar2) +return boolean; + + +PROCEDURE out( +aiv_text in varchar2); + + +PROCEDURE open_html( +aiv_title in varchar2); + + +PROCEDURE close_html; + + +-- FUNCTIONS + +FUNCTION get_comment_line_text( +aiv_text in varchar2) +return varchar2 is + +n_start number := 1; +n_end number; + +begin + if is_comment_start(aiv_text) then + n_start := get_comment_start(aiv_text); + end if; + if is_comment_end(aiv_text) then + n_end := get_comment_end(aiv_text); + else + n_end := nvl(length(aiv_text), 0); + end if; + if n_end > n_start then + return substr(aiv_text, n_start, (n_end + 1) - n_start); + else + return NULL; + end if; +end get_comment_line_text; + + +FUNCTION get_comment_end( +aiv_text in varchar2) +return number is + +n_position number; + +begin + n_position := nvl(instr(upper(aiv_text), '*/'), 0); + if n_position > 0 then + return n_position - 1; + else + n_position := nvl(instr(upper(aiv_text), '--'), 0); + if n_position > 0 then + return nvl(length(aiv_text), 0); + else + return -1; + end if; + end if; +end get_comment_end; + + +FUNCTION get_comment_start( +aiv_text in varchar2) +return number is + +n_position number; + +begin + n_position := nvl(instr(upper(aiv_text), '/*'), 0); + if n_position > 0 then + return n_position + 2; + else + n_position := nvl(instr(upper(aiv_text), '--'), 0); + if n_position > 0 then + return n_position + 2; + else + return -1; + end if; + end if; +end get_comment_start; + + +FUNCTION get_first_sentence( +aiv_text in varchar2) +return varchar2 is + +n_start number := 1; +n_end number; + +begin + if is_comment_start(aiv_text) then + n_start := get_comment_start(aiv_text); + end if; + n_end := nvl(instr(aiv_text, '.') - 1, -1); + if n_end = -1 then + n_end := nvl(length(aiv_text), 0); + end if; + if n_end > n_start then + return substr(aiv_text, n_start, (n_end + 1) - n_start); + else + return NULL; + end if; +end get_first_sentence; + + +FUNCTION get_method_end( +aiv_text in varchar2) +return number is + +n_position number; + +begin + n_position := nvl(instr(upper(aiv_text), ';'), 0); + if n_position > 0 then + return n_position - 1; + else + return length(aiv_text); + end if; +end get_method_end; + + +FUNCTION get_method_line_text( +aiv_text in varchar2) +return varchar2 is + +n_start number := 1; +n_end number; + +begin + if is_method_end(aiv_text) then + n_end := get_method_end(aiv_text); + else + n_end := nvl(length(aiv_text), 0); + end if; + if n_end > 0 then + return substr(aiv_text, n_start, (n_end + 1) - n_start); + else + return NULL; + end if; +end get_method_line_text; + + +FUNCTION get_method_name( +aiv_text in varchar2) +return varchar2 is + +n_first number; +n_end number; + +begin + n_first := get_method_name_start(aiv_text); + n_end := get_method_name_end(aiv_text); + if n_end > n_first then + return substr(aiv_text, n_first, (n_end + 1) - n_first); + else + return NULL; + end if; +end get_method_name; + + +FUNCTION get_method_name_start( +aiv_text in varchar2) +return number is + +n_position number; + +begin + n_position := nvl(instr(upper(aiv_text), 'FUNCTION '), 0); + if n_position > 0 then + return n_position + 9; + else + n_position := nvl(instr(upper(aiv_text), 'PROCEDURE '), 0); + if n_position > 0 then + return n_position + 10; + else + return 0; + end if; + end if; +end get_method_name_start; + + +FUNCTION get_method_name_end( +aiv_text in varchar2) +return number is + +n_position number; + +begin + n_position := nvl(instr(upper(aiv_text), '('), 0); + if n_position > 0 then + return n_position - 1; + else + n_position := get_method_end(aiv_text); + if n_position > 0 then + return n_position; + else + return nvl(length(aiv_text), 0); + end if; + end if; +end get_method_name_end; + + +FUNCTION is_comment_end( +aiv_text in varchar2) +return boolean is + +n_position number; + +begin + if get_comment_end(aiv_text) >= 0 then + return TRUE; + else + return FALSE; + end if; +end is_comment_end; + + +FUNCTION is_comment_start( +aiv_text in varchar2) +return boolean is + +n_position number; + +begin + if get_comment_start(aiv_text) >= 0 then + return TRUE; + else + return FALSE; + end if; +end is_comment_start; + + +FUNCTION is_method_end( +aiv_text in varchar2) +return boolean is + +n_position number; + +begin + if nvl(instr(aiv_text, ';'), 0) > 0 then + return TRUE; + else + return FALSE; + end if; +end is_method_end; + + +FUNCTION is_method_start( +aiv_text in varchar2) +return boolean is + +n_position number; + +begin + if get_method_name_start(aiv_text) > 0 then + return TRUE; + else + return FALSE; + end if; +end is_method_start; + + +FUNCTION comments_span( +aiv_text in varchar2) +return varchar2 is +begin + return ''||aiv_text||''; +end comments_span; + + +FUNCTION first_sentence_span( +aiv_text in varchar2) +return varchar2 is +begin + return ''||aiv_text||''; +end first_sentence_span; + + +FUNCTION method_span( +aiv_text in varchar2) +return varchar2 is +begin + return ''||aiv_text||''; +end method_span; + + +FUNCTION method_name_span( +aiv_text in varchar2) +return varchar2 is +begin + return ''||aiv_text||''; +end method_name_span; + + +FUNCTION package_name_span( +aiv_text in varchar2) +return varchar2 is +begin + return ''||aiv_text||''; +end package_name_span; + + +PROCEDURE create_index is + +cursor c1 is +select distinct name +from SYS.USER_SOURCE +where type in ('PACKAGE', 'TYPE') +order by 1; + +cursor c2( +aiv_name in varchar2) is +select text +from SYS.USER_SOURCE +where type in ('PACKAGE', 'TYPE') +and name = aiv_name +order by line; + +b_comment boolean; +n_period number; + +begin + open_html('Package/Type index'); + out('

Owner '||user||'

'); + out(''); + for r1 in c1 loop + if c1%rowcount = 1 then + out(''); + end if; + b_comment := FALSE; + for r2 in c2(r1.name) loop + if nvl(instr(r2.text, '/*'), 0) > 0 or + nvl(instr(r2.text, '--'), 0) > 0 then + b_comment := TRUE; + end if; + if b_comment and + nvl(instr(upper(r2.text), '.PKS'), 0) = 0 and + substr(upper(ltrim(r2.text)), 1, 3) <> 'BY ' and + substr(upper(ltrim(r2.text)), 1, 13) <> 'COPYRIGHT BY ' then + n_period := nvl(instr(ltrim(r2.text), '.'), 0); + if n_period > 0 then + out(''); + exit; + end if; + end if; + end loop; + end loop; + out('
Packages/Types
'||package_name_span(r1.name)||''||comments_span(substr(ltrim(r2.text), 1, n_period))||'
'); + close_html(); +end create_index; + + +PROCEDURE create_help( +aiv_object_name in varchar2) is + +cursor c1( +aiv_object_name in varchar2) is +select text, + type +from SYS.USER_SOURCE +where name = upper(aiv_object_name) +and type in ('PACKAGE', 'TYPE') +and line > 1 +order by line; + +b_comment boolean := FALSE; +b_first_sentence boolean := FALSE; +b_method boolean := FALSE; +b_method_name boolean := FALSE; +b_other boolean := FALSE; +n_backward number; +n_line_number number; +n_spec number := 0; +t_spec spec_table; +v_comment varchar2(2000); +v_first_sentence varchar2(2000); +v_method varchar2(2000); +v_method_name varchar2(2000); +v_text varchar2(2000); +v_type varchar2(30); + +begin + for r1 in c1(aiv_object_name) loop + if c1%rowcount = 1 then + v_type := r1.type; + end if; + + -- strip away any carriage-returns and line-feeds + v_text := replace(replace(r1.text, chr(13), NULL), chr(10), NULL); + -- detect comments and methods + if is_comment_start(v_text) then + b_comment := TRUE; + b_first_sentence := FALSE; + if not b_first_sentence then + v_first_sentence := get_first_sentence(v_text); + if v_first_sentence is not NULL then + b_first_sentence := TRUE; + n_line_number := 1; + n_spec := n_spec + 1; + t_spec(n_spec).line_type := v_LT_COMMENT; + t_spec(n_spec).line_number := n_line_number; + t_spec(n_spec).line_text := get_comment_line_text(v_text); + t_spec(n_spec).first_sentence := v_first_sentence; + end if; + else + v_comment := get_comment_line_text(v_text); + if v_comment is not NULL then + n_line_number := 1; + n_spec := n_spec + 1; + t_spec(n_spec).line_type := v_LT_COMMENT; + t_spec(n_spec).line_number := n_line_number; + t_spec(n_spec).line_text := get_comment_line_text(v_text); + t_spec(n_spec).first_sentence := NULL; + end if; + end if; + if is_comment_end(v_text) then + b_comment := FALSE; + b_first_sentence := FALSE; + end if; + elsif b_comment and + is_comment_end(v_text) then + if not b_first_sentence then + v_first_sentence := get_first_sentence(v_text); + if v_first_sentence is not NULL then + b_first_sentence := TRUE; + n_line_number := 1; + n_spec := n_spec + 1; + t_spec(n_spec).line_type := v_LT_COMMENT; + t_spec(n_spec).line_number := n_line_number; + t_spec(n_spec).line_text := get_comment_line_text(v_text); + t_spec(n_spec).first_sentence := v_first_sentence; + end if; + else + v_comment := get_comment_line_text(v_text); + if v_comment is not NULL then + n_line_number := n_line_number + 1; + n_spec := n_spec + 1; + t_spec(n_spec).line_type := v_LT_COMMENT; + t_spec(n_spec).line_number := n_line_number; + t_spec(n_spec).line_text := get_comment_line_text(v_text); + t_spec(n_spec).first_sentence := NULL; + end if; + end if; + b_comment := FALSE; + b_first_sentence := FALSE; + elsif b_comment then + if not b_first_sentence then + v_first_sentence := get_first_sentence(v_text); + if v_first_sentence is not NULL then + b_first_sentence := TRUE; + n_line_number := 1; + n_spec := n_spec + 1; + t_spec(n_spec).line_type := v_LT_COMMENT; + t_spec(n_spec).line_number := n_line_number; + t_spec(n_spec).line_text := get_comment_line_text(v_text); + t_spec(n_spec).first_sentence := v_first_sentence; + end if; + else + v_comment := get_comment_line_text(v_text); + if v_comment is not NULL then + n_line_number := n_line_number + 1; + n_spec := n_spec + 1; + t_spec(n_spec).line_type := v_LT_COMMENT; + t_spec(n_spec).line_number := n_line_number; + t_spec(n_spec).line_text := get_comment_line_text(v_text); + t_spec(n_spec).first_sentence := NULL; + end if; + end if; + elsif is_method_start(v_text) then + b_method := TRUE; + b_method_name := FALSE; + if not b_method_name then + v_method_name := get_method_name(v_text); + if v_method_name is not NULL then + b_method_name := TRUE; + n_line_number := 1; + n_spec := n_spec + 1; + t_spec(n_spec).line_type := v_LT_METHOD; + t_spec(n_spec).line_number := n_line_number; + t_spec(n_spec).line_text := get_method_line_text(v_text); + t_spec(n_spec).method_name := v_method_name; + else + n_line_number := 1; + n_spec := n_spec + 1; + t_spec(n_spec).line_type := v_LT_METHOD; + t_spec(n_spec).line_number := n_line_number; + t_spec(n_spec).line_text := get_method_line_text(v_text); + t_spec(n_spec).method_name := NULL; + end if; + else + v_method := get_method_line_text(v_text); + if v_method is not NULL then + n_line_number := n_line_number + 1; + n_spec := n_spec + 1; + t_spec(n_spec).line_type := v_LT_METHOD; + t_spec(n_spec).line_number := n_line_number; + t_spec(n_spec).line_text := v_method; + t_spec(n_spec).method_name := NULL; + end if; + end if; + if is_method_end(v_text) then + b_method := FALSE; + b_method_name := FALSE; + end if; + elsif b_method and + is_method_end(v_text) then + if not b_method_name then + v_method_name := get_method_name(v_text); + if v_method_name is not NULL then + b_method_name := TRUE; + n_line_number := 1; + n_spec := n_spec + 1; + t_spec(n_spec).line_type := v_LT_METHOD; + t_spec(n_spec).line_number := n_line_number; + t_spec(n_spec).line_text := get_method_line_text(v_text); + t_spec(n_spec).method_name := v_method_name; + else + n_line_number := 1; + n_spec := n_spec + 1; + t_spec(n_spec).line_type := v_LT_METHOD; + t_spec(n_spec).line_number := n_line_number; + t_spec(n_spec).line_text := get_method_line_text(v_text); + t_spec(n_spec).method_name := NULL; + end if; + else + v_method := get_method_line_text(v_text); + if v_method is not NULL then + n_line_number := n_line_number + 1; + n_spec := n_spec + 1; + t_spec(n_spec).line_type := v_LT_METHOD; + t_spec(n_spec).line_number := n_line_number; + t_spec(n_spec).line_text := v_method; + t_spec(n_spec).method_name := NULL; + end if; + end if; + b_method := FALSE; + b_method_name := FALSE; + elsif b_method then + v_method := get_method_line_text(v_text); + if v_method is not NULL then + n_line_number := n_line_number + 1; + n_spec := n_spec + 1; + t_spec(n_spec).line_type := v_LT_METHOD; + t_spec(n_spec).line_number := n_line_number; + t_spec(n_spec).line_text := v_method; + t_spec(n_spec).method_name := NULL; + end if; + elsif upper(substr(ltrim(v_text), 1, 3)) = 'END' then + exit; + elsif nvl(length(rtrim(v_text)), 0) > 0 then + n_line_number := 1; + n_spec := n_spec + 1; + t_spec(n_spec).line_type := v_LT_OTHER; + t_spec(n_spec).line_number := n_line_number; + t_spec(n_spec).line_text := v_text; + end if; + end loop; + + -- Now create the HTML + open_html(aiv_object_name); + -- Package name and comments + if v_type = 'PACKAGE' then + out('

Package '||upper(aiv_object_name)||'

'); + else + out('

Type '||upper(aiv_object_name)||'

'); + end if; + if n_spec > 0 then + for i in 1..n_spec loop + if t_spec(i).first_sentence is not NULL then + out('

'); + n_line_number := t_spec(i).line_number; + for j in i..n_spec loop + if j > 1 and + t_spec(j).line_number <= n_line_number then + exit; + end if; + out(t_spec(j).line_text); + end loop; + out('

'); + exit; + end if; + end loop; + out('

'); + -- Other + for i in 1..n_spec loop + if t_spec(i).line_type = v_LT_OTHER then + if not b_other then + out(''); + if v_type = 'PACKAGE' then + out(''); + else + out(''); + end if; + out('
Global Constants and Variables
Attributes
'); + out('
');
+          b_other := TRUE;
+        end if;
+        if i > 1                                 and
+          t_spec(i - 1).line_type = v_LT_COMMENT then
+          n_backward := i - t_spec(i - 1).line_number;
+          if n_backward > 0 then
+            out('

'); + for j in n_backward..(i - 1) loop + out(t_spec(j).line_text); + end loop; + out('

');
+          end if;
+        end if;
+        out(t_spec(i).line_text);
+      end if;
+    end loop;
+    if b_other then
+      out('
'); + out('

'); + end if; +/* -- Debug Output + out(''); */ + -- Method Summary + out(''); + out(''); + for i in 1..n_spec loop + if t_spec(i).method_name is not NULL then + v_first_sentence := '
'; + n_backward := i - 1; + if n_backward > 0 then + loop + if t_spec(n_backward).method_name is not NULL then + exit; + end if; + if t_spec(n_backward).first_sentence is not NULL then + v_first_sentence := t_spec(n_backward).first_sentence; + exit; + end if; + n_backward := n_backward - 1; + if n_backward < 1 then + exit; + end if; + end loop; + end if; + out(''); + out(' '); + end if; + end loop; + out('
Method Summary
'||method_name_span(t_spec(i).method_name)||''||first_sentence_span(nvl(v_first_sentence, '
'))||'
'); + out('


'); + -- Method Details + out(''); + out(''); + out('
Method Detail
'); + for i in 1..n_spec loop + if t_spec(i).method_name is not NULL then + out('

'||t_spec(i).method_name||'

'); + out('
');
+        for j in i..n_spec loop
+          if t_spec(j).line_type <> v_LT_METHOD or
+            (j > i                              and 
+             t_spec(j).method_name is not NULL) then
+            exit;
+          end if;
+          out(t_spec(j).line_text);
+        end loop;
+        out('
'); + if i > 1 and + t_spec(i - 1).line_type = v_LT_COMMENT then + n_backward := i - t_spec(i - 1).line_number; + if n_backward > 0 then + out('

'); + for j in n_backward..(i - 1) loop + out(t_spec(j).line_text); + end loop; + out('

'); + end if; + end if; + out('
'); + end if; + end loop; + end if; + close_html(); +end create_help; + + +PROCEDURE help is + +begin + TEXT_HELP.process('HTML_HELP'); +end help; + + +PROCEDURE out( +aiv_text in varchar2) is + +TYPE split_table is table of varchar2(255) +index by binary_integer; + +n_length number; +n_split number := 255; +n_start number := 1; +n_stop number; +n_text number := 0; + +t_text split_table; + +n_limit_1 number := 0; +n_limit_2 number := 0; + +begin + n_length := nvl(length(aiv_text), 0); + + if n_length > 255 then + loop + n_limit_1 := n_limit_1 + 1; + n_stop := least(n_start + n_split, n_length); + loop + n_limit_2 := n_limit_2 + 1; + + if n_stop = n_start then + n_stop := n_length; + exit; + elsif substr(aiv_text, n_stop, 1) = chr(32) then + exit; + else + n_stop := n_stop - 1; + end if; + end loop; + n_text := n_text + 1; + t_text(n_text) := substr(aiv_text, n_start, n_stop - n_start); + n_start := n_stop; + if n_start >= n_length then + exit; + end if; + end loop; + for i in t_text.first..t_text.last loop + SYS.DBMS_OUTPUT.put_line(t_text(i)); + end loop; + else + SYS.DBMS_OUTPUT.put_line(aiv_text); + end if; +end out; + + +PROCEDURE open_html( +aiv_title in varchar2) is + +begin + out(' + +'||aiv_title||' + + +'); +end open_html; + + +PROCEDURE close_html is + +begin + out(' +'); +end close_html; + + +PROCEDURE test is + +begin + pl('HTML_HELP.test()'); + + TEST_TS.clear('HTML_HELP'); + + TEST_TS.set_test('HTML_HELP', 'create_package_index()', 1, + 'Test method create_package_index()' ); + begin + create_index(); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('HTML_HELP', 'create_package_help()', 2, + 'Test method create_package_help()' ); + begin + create_help('HTML_HELP'); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('HTML_HELP', 'help()', 3, + 'Test method help()' ); + begin + help(); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('HTML_HELP', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end HTML_HELP; +/ +@be.sql HTML_HELP diff --git a/Chapter09/html_help.pks b/Chapter09/html_help.pks new file mode 100644 index 0000000..fda37ca --- /dev/null +++ b/Chapter09/html_help.pks @@ -0,0 +1,29 @@ +create or replace PACKAGE HTML_HELP as +/* +html_help.pks +by Donald J. Bales on 12/15/2006 +Package to create HTML-based help files for packages. +*/ + +-- Creates a "object_index" html file for the current USER. + +PROCEDURE create_index; + + +-- Creates a "" html for each package for the current USER. + +PROCEDURE create_help( +aiv_object_name in varchar2); + + +-- Text-based help for this package. "set serveroutput on" in SQL*Plus. + +PROCEDURE help; + + +PROCEDURE test; + + +end HTML_HELP; +/ +@se.sql HTML_HELP diff --git a/Chapter09/html_help.sql b/Chapter09/html_help.sql new file mode 100644 index 0000000..29b6d84 --- /dev/null +++ b/Chapter09/html_help.sql @@ -0,0 +1,107 @@ +rem html_help.sql +rem by Don Bales on 12/15/2006 +rem Created by SQL*Plus script create_html_help.sql + +set feedback off; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; + +spool dates.html; +execute HTML_HELP.create_help('DATES'); +spool off; + +spool debug_o.html; +execute HTML_HELP.create_help('DEBUG_O'); +spool off; + +spool debug_ots.html; +execute HTML_HELP.create_help('DEBUG_OTS'); +spool off; + +spool debug_ts.html; +execute HTML_HELP.create_help('DEBUG_TS'); +spool off; + +spool gender_o.html; +execute HTML_HELP.create_help('GENDER_O'); +spool off; + +spool gender_ts.html; +execute HTML_HELP.create_help('GENDER_TS'); +spool off; + +spool html_help.html; +execute HTML_HELP.create_help('HTML_HELP'); +spool off; + +spool logical_assignment_ts.html; +execute HTML_HELP.create_help('LOGICAL_ASSIGNMENT_TS'); +spool off; + +spool logical_workplace_ts.html; +execute HTML_HELP.create_help('LOGICAL_WORKPLACE_TS'); +spool off; + +spool numbers.html; +execute HTML_HELP.create_help('NUMBERS'); +spool off; + +spool parameters.html; +execute HTML_HELP.create_help('PARAMETERS'); +spool off; + +spool scopes.html; +execute HTML_HELP.create_help('SCOPES'); +spool off; + +spool sys_yoid0000073829$.html; +execute HTML_HELP.create_help('SYS_YOID0000073829$'); +spool off; + +spool test_o.html; +execute HTML_HELP.create_help('TEST_O'); +spool off; + +spool test_ts.html; +execute HTML_HELP.create_help('TEST_TS'); +spool off; + +spool text_help.html; +execute HTML_HELP.create_help('TEXT_HELP'); +spool off; + +spool varchar2s.html; +execute HTML_HELP.create_help('VARCHAR2S'); +spool off; + +spool worker_o.html; +execute HTML_HELP.create_help('WORKER_O'); +spool off; + +spool worker_ts.html; +execute HTML_HELP.create_help('WORKER_TS'); +spool off; + +spool worker_type_o.html; +execute HTML_HELP.create_help('WORKER_TYPE_O'); +spool off; + +spool worker_type_ts.html; +execute HTML_HELP.create_help('WORKER_TYPE_TS'); +spool off; + +spool workplace_type_ts.html; +execute HTML_HELP.create_help('WORKPLACE_TYPE_TS'); +spool off; + +spool object_index.html; +execute HTML_HELP.create_index(); +spool off; + +set feedback on; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; diff --git a/Chapter09/last_test_results.sql b/Chapter09/last_test_results.sql new file mode 100644 index 0000000..99051a3 --- /dev/null +++ b/Chapter09/last_test_results.sql @@ -0,0 +1,35 @@ +rem last_test_results.sql +rem by Donald J. Bales on 12/15/2006 +rem Display the last test results + +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; + +column test format a34; +column t# format 99; +column description format a27; +column result format a7; + +spool last_test_results.txt; + +select object_name|| + decode(substr(method_name, -1, 1), ')', '.', ' ')|| + method_name test, + test_number t#, + description, + result +from TEST_T +where unique_session_id = SYS.DBMS_SESSION.unique_session_id +and object_name = ( +select object_name +from TEST_T +where unique_session_id = SYS.DBMS_SESSION.unique_session_id +and test_id = ( +select max(test_id) +from TEST_T +where unique_session_id = SYS.DBMS_SESSION.unique_session_id)) +order by test_id; + +spool off; diff --git a/Chapter09/last_test_results.txt b/Chapter09/last_test_results.txt new file mode 100644 index 0000000..b68c3c7 --- /dev/null +++ b/Chapter09/last_test_results.txt @@ -0,0 +1,5 @@ + +TEST T# DESCRIPTION RESULT +---------------------------------- --- --------------------------- ------- +TEXT_HELP SUCCESS + diff --git a/Chapter09/login.sql b/Chapter09/login.sql new file mode 100644 index 0000000..839e26f --- /dev/null +++ b/Chapter09/login.sql @@ -0,0 +1,10 @@ +rem login.sql +rem by Donald J. Bales on 12/15/2006 +rem Set my default SQL*Plus environment +set linesize 1000; +set newpage 1; +set pagesize 32767; +set serveroutput on size 1000000; +set trimspool on; +alter session set nls_date_format = 'SYYYYMMDD HH24MISS'; +prompt BPS' default settings loaded successfully! diff --git a/Chapter09/pe.sql b/Chapter09/pe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter09/pe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter09/pl.prc b/Chapter09/pl.prc new file mode 100644 index 0000000..10b8e34 --- /dev/null +++ b/Chapter09/pl.prc @@ -0,0 +1,14 @@ +create or replace PROCEDURE pl( +aiv_text in varchar2 ) is +/* +pl.prc +by Donald J. Bales on 12/15/2006 +A wrapper procedure for SYS.DBMS_OUTPUT.put_line() +for the lazy typist. +*/ + +begin + SYS.DBMS_OUTPUT.put_line(aiv_text); +end pl; +/ +@pe.sql pl diff --git a/Chapter09/se.sql b/Chapter09/se.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter09/se.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter09/solutions/create_html_help.sql b/Chapter09/solutions/create_html_help.sql new file mode 100644 index 0000000..fb252d7 --- /dev/null +++ b/Chapter09/solutions/create_html_help.sql @@ -0,0 +1,45 @@ +rem create_html_help.sql +rem by Don Bales on 12/15/2006 +rem SQL*Plus script to create a SQL*Plus script to create html help for +rem the current user. + +set feedback off; +set linesize 1000; +set newpage 1; +set pagesize 0; +set trimspool on; +set serveroutput on size 1000000; + +spool html_help.sql; + +prompt rem html_help.sql +prompt rem by Don Bales on 12/15/2006 +prompt rem Created by SQL*Plus script create_html_help.sql +prompt; +prompt set feedback off;; +prompt set linesize 1000;; +prompt set newpage 1;; +prompt set pagesize 32767;; +prompt set trimspool on;; +prompt; +select 'spool '||lower(name)||'.html;'|| + chr(10)||'execute HTML_HELP.create_help('''||name||''');'|| + chr(10)||'spool off;'||chr(10) +from SYS.USER_SOURCE +where type in ('PACKAGE', 'TYPE') +group by name +order by name; + +prompt spool object_index.html;; +prompt execute HTML_HELP.create_index();; +prompt spool off;; +prompt; +prompt set feedback on;; +prompt set linesize 1000;; +prompt set newpage 1;; +prompt set pagesize 32767;; +prompt set trimspool on;; + +spool off; + +@html_help.sql diff --git a/Chapter09/solutions/dates.html b/Chapter09/solutions/dates.html new file mode 100644 index 0000000..d17a9b2 --- /dev/null +++ b/Chapter09/solutions/dates.html @@ -0,0 +1,112 @@ + + +DATES + + + +

Package DATES

+

+dates.pks +by Donald J. Bales on 12/15/2006 +Additional DATE data type methods. +

+

+ + +
Global Constants and Variables
+
+

+The maximum and minimum dates values. +

+d_MAX                        constant date := to_date('99991231235959', 'YYYYMMDDHH24MISS');
+d_MIN                        constant date := to_date('-47120101', 'SYYYYMMDD');
+
+

+ + + + + + + + + + + + + + + + +
Method Summary
end_of_day Returns the specified date with the time set to 23:59:59, therefore, the end of the day
get_max Returns constant d_MAX
get_min Returns constant d_MIN
help Text-based help for this package
random Returns a randomly generated date that exists between the years specified
start_of_day Returns the specified date with the time set to 00:00:00, therefore, the start of the day
test Test unit for this package
+


+ + +
Method Detail
+

end_of_day

+
+FUNCTION end_of_day(
+aid_date                       in     date )
+return                                date
+
+

+Returns the specified date with the time set to 23:59:59, therefore, the end of the day. +

+
+

get_max

+
+FUNCTION get_max
+return                                date
+
+

+Returns constant d_MAX. This is useful in SQL statements where the constant DATES.d_MAX is not accessible. +

+
+

get_min

+
+FUNCTION get_min
+return                                date
+
+

+Returns constant d_MIN. This is useful in SQL statements where the constant DATES.d_MIN is not accessible. +

+
+

help

+
+PROCEDURE help
+
+

+Text-based help for this package. "set serveroutput on" in SQL*Plus. +

+
+

random

+
+FUNCTION random(
+ain_starting_year              in     number,
+ain_ending_year                in     number )
+return                                date
+
+

+Returns a randomly generated date that exists between the years specified. +

+
+

start_of_day

+
+FUNCTION start_of_day(
+aid_date                       in     date )
+return                                date
+
+

+Returns the specified date with the time set to 00:00:00, therefore, the start of the day. +

+
+

test

+
+PROCEDURE test
+
+

+Test unit for this package. +

+
+ + diff --git a/Chapter09/solutions/dates.pks b/Chapter09/solutions/dates.pks new file mode 100644 index 0000000..9103fe4 --- /dev/null +++ b/Chapter09/solutions/dates.pks @@ -0,0 +1,60 @@ +create or replace package DATES as +/* +dates.pks +by Donald J. Bales on 12/15/2006 +Additional DATE data type methods. +*/ + +-- The maximum and minimum dates values. + +d_MAX constant date := to_date('99991231235959', 'YYYYMMDDHH24MISS'); +d_MIN constant date := to_date('-47120101', 'SYYYYMMDD'); + + +-- Returns the specified date with the time set to 23:59:59, therefore, the end of the day. + +FUNCTION end_of_day( +aid_date in date ) +return date; + + +-- Returns constant d_MAX. This is useful in SQL statements where the constant DATES.d_MAX is not accessible. + +FUNCTION get_max +return date; + + +-- Returns constant d_MIN. This is useful in SQL statements where the constant DATES.d_MIN is not accessible. + +FUNCTION get_min +return date; + + +-- Text-based help for this package. "set serveroutput on" in SQL*Plus. + +PROCEDURE help; + + +-- Returns a randomly generated date that exists between the years specified. + +FUNCTION random( +ain_starting_year in number, +ain_ending_year in number ) +return date; + + +-- Returns the specified date with the time set to 00:00:00, therefore, the start of the day. + +FUNCTION start_of_day( +aid_date in date ) +return date; + + +-- Test unit for this package. + +PROCEDURE test; + + +end DATES; +/ +@se.sql DATES diff --git a/Chapter09/solutions/debug_o.html b/Chapter09/solutions/debug_o.html new file mode 100644 index 0000000..e74230c --- /dev/null +++ b/Chapter09/solutions/debug_o.html @@ -0,0 +1,118 @@ + + +DEBUG_O + + + +

Type DEBUG_O

+

+debug_o.tps +by Donald Bales on 12/15/2006 +Type DEBUG_O's specification: +A type for logging debug information +

+

+ + +
Attributes
+
+

+debug_o.tps +by Donald Bales on 12/15/2006 +Type DEBUG_O's specification: +A type for logging debug information +

+id                                    number,
+text                                  varchar2(256),
+unique_session_id                     varchar2(24),
+insert_user                           varchar2(30),
+insert_date                           date,
+
+

+ + + + + + + + + + + + + + +
Method Summary
get_id Get the next primary key value
debug_o A NULL values constructor
debug_o A convenience constructor
debug_o Override the default constructor
set_text Write to the debug object table
to_map A map function
+


+ + +
Method Detail
+

get_id

+
+STATIC FUNCTION get_id
+return                                number,
+
+

+Get the next primary key value +

+
+

debug_o

+
+CONSTRUCTOR FUNCTION debug_o(
+self                           in out nocopy debug_o)
+return                                self as result,
+
+

+A NULL values constructor +

+
+

debug_o

+
+CONSTRUCTOR FUNCTION debug_o(
+self                           in out nocopy debug_o,
+ain_id                         in     number,
+aiv_text                       in     varchar2)
+return                                self as result,
+
+

+A convenience constructor +

+
+

debug_o

+
+CONSTRUCTOR FUNCTION debug_o(
+self                           in out nocopy debug_o,
+id                             in     number,
+text                           in     varchar2,
+unique_session_id              in     varchar2,
+insert_user                    in     varchar2,
+insert_date                    in     date)
+return                                self as result,
+
+

+Override the default constructor +

+
+

set_text

+
+STATIC PROCEDURE set_text(
+aiv_program_unit               in     varchar2,
+aiv_text                       in     varchar2),
+
+

+Write to the debug object table +

+
+

to_map

+
+MAP MEMBER FUNCTION to_map
+return                                number
+) not final
+
+

+A map function +

+
+ + diff --git a/Chapter09/solutions/debug_ots.html b/Chapter09/solutions/debug_ots.html new file mode 100644 index 0000000..5d74d85 --- /dev/null +++ b/Chapter09/solutions/debug_ots.html @@ -0,0 +1,56 @@ + + +DEBUG_OTS + + + +

Package DEBUG_OTS

+

+debug_ots.pks +by Donald J. Bales on 12/15/2006 +Object Table DEBUG_OT's package +

+

+ + + + + + + + +
Method Summary
disable Disable debug logging for the specified program unit
enable Enable debug logging for the specified program unit
set_text program unit, if it is enabled
+


+ + +
Method Detail
+

disable

+
+PROCEDURE disable(
+aiv_program_unit               in     varchar2)
+
+

+Disable debug logging for the specified program unit +

+
+

enable

+
+PROCEDURE enable(
+aiv_program_unit               in     varchar2)
+
+

+Enable debug logging for the specified program unit +

+
+

set_text

+
+PROCEDURE set_text(
+aiv_program_unit               in     varchar2,
+aiv_text                       in     DEBUG_OT.text%TYPE)
+
+

+program unit, if it is enabled +

+
+ + diff --git a/Chapter09/solutions/debug_ts.html b/Chapter09/solutions/debug_ts.html new file mode 100644 index 0000000..9e70727 --- /dev/null +++ b/Chapter09/solutions/debug_ts.html @@ -0,0 +1,67 @@ + + +DEBUG_TS + + + +

Package DEBUG_TS

+

+debug_ts.pks +by Donald J. Bales on 12/15/2006 +Table DEBUG_T's package +

+

+ + + + + + + + + + +
Method Summary
get_id Gets the next primary key value for the table
enable Enable debug output for the specified program unit
disable Disable debug output for the specified program unit
set_text Log debug output if enabled for the specified program unit
+


+ + +
Method Detail
+

get_id

+
+FUNCTION get_id
+return                                DEBUG_T.id%TYPE
+
+

+Gets the next primary key value for the table +

+
+

enable

+
+PROCEDURE enable(
+aiv_program_unit               in     varchar2)
+
+

+Enable debug output for the specified program unit +

+
+

disable

+
+PROCEDURE disable(
+aiv_program_unit               in     varchar2)
+
+

+Disable debug output for the specified program unit +

+
+

set_text

+
+PROCEDURE set_text(
+aiv_program_unit               in     varchar2,
+aiv_text                       in     DEBUG_T.text%TYPE)
+
+

+Log debug output if enabled for the specified program unit +

+
+ + diff --git a/Chapter09/solutions/emails.html b/Chapter09/solutions/emails.html new file mode 100644 index 0000000..47e787a --- /dev/null +++ b/Chapter09/solutions/emails.html @@ -0,0 +1,133 @@ + + +EMAILS + + + +

Package EMAILS

+

+emails.pks +by Donald J. Bales on 12/15/2006 +Package to send emails +

+

+ + +
Global Constants and Variables
+
+

+An associative array (PL/SQL table) used to hold the lines of an email message +

+TYPE LINES is table of varchar2(2000) index by binary_integer;
+
+

+ + + + + + + + + + + + + + + + + + + + +
Method Summary
get_domain Returns the domain value
get_host Returns the host value
get_username Returns the username
send Send an email message through the database
set_domain Sets the domain value
set_host Sets the host value
set_password Sets the password value
set_username Sets the username value
test This package's test units
+


+ + +
Method Detail
+

get_domain

+
+FUNCTION get_domain
+return                                varchar2
+
+

+Returns the domain value +

+
+

get_host

+
+FUNCTION get_host
+return                                varchar2
+
+

+Returns the host value +

+
+

get_username

+
+FUNCTION get_username
+return                                varchar2
+
+

+Returns the username +

+
+

send

+
+PROCEDURE send(
+aiv_from                       in     varchar2,
+aiv_to                         in     varchar2,
+aiv_subject                    in     varchar2,
+ait_lines                      in     LINES)
+
+

+Send an email message through the database +

+
+

set_domain

+
+PROCEDURE set_domain(
+aiv_domain                     in     varchar2)
+
+

+Sets the domain value +

+
+

set_host

+
+PROCEDURE set_host(
+aiv_host                       in     varchar2)
+
+

+Sets the host value +

+
+

set_password

+
+PROCEDURE set_password(
+aiv_password                   in     varchar2)
+
+

+Sets the password value +

+
+

set_username

+
+PROCEDURE set_username(
+aiv_username                   in     varchar2)
+
+

+Sets the username value +

+
+

test

+
+PROCEDURE test
+
+

+This package's test units +

+
+ + diff --git a/Chapter09/solutions/gender_o.html b/Chapter09/solutions/gender_o.html new file mode 100644 index 0000000..cfb3516 --- /dev/null +++ b/Chapter09/solutions/gender_o.html @@ -0,0 +1,161 @@ + + +GENDER_O + + + +

Type GENDER_O

+

+gender_o.tps +by Don Bales on 12/15/2006 +Type GENDER's attributes and methods. +

+

+ + +
Attributes
+
+

+gender_o.tps +by Don Bales on 12/15/2006 +Type GENDER's attributes and methods. +

+id                                    number,
+code                                  varchar2(30),
+description                           varchar2(80),
+active_date                           date,
+inactive_date                         date,
+
+

+ + + + + + + + + + + + + + + + + + + + + + +
Method Summary
gender_oA constructor for creating a new instance of type GENDER_O with NULL
gender_oA constructor for creating a new instance of type GENDER_O for insert
get_code_descrGets the code and decription values for the specified id
get_code_id_descrVerifies that the passed code value is an exact or like match on the
get_code_id_descrVerifies that the passed code value is currently an exact or like match
get_idReturns a new primary key id value for a row
get_idReturns the id for the specified code value
help,Test-based help for this package
test,Test units for this package
to_varchar2A MAP function for sorting at the object level
+


+ + +
Method Detail
+

gender_o

+
+CONSTRUCTOR FUNCTION gender_o(
+self                           in out gender_o)
+return                                self as result,
+
+

+A constructor for creating a new instance of type GENDER_O with NULL +values. +

+
+

gender_o

+
+CONSTRUCTOR FUNCTION gender_o(
+self                           in out gender_o,
+aiv_code                              varchar2,
+aiv_description                       varchar2)
+return                                self as result,
+
+

+A constructor for creating a new instance of type GENDER_O for insert. +

+
+

get_code_descr

+
+STATIC PROCEDURE get_code_descr(
+ain_id                         in     number,
+aov_code                          out varchar2,
+aov_description                   out varchar2),
+
+

+Gets the code and decription values for the specified id. +

+
+

get_code_id_descr

+
+STATIC PROCEDURE get_code_id_descr(
+aiov_code                      in out varchar2,
+aon_id                            out number,
+aov_description                   out varchar2,
+aid_on                         in     date),
+
+

+Verifies that the passed code value is an exact or like match on the +date specified. +

+
+

get_code_id_descr

+
+STATIC PROCEDURE get_code_id_descr(
+aiov_code                      in out varchar2,
+aon_id                            out number,
+aov_description                   out varchar2),
+
+

+Verifies that the passed code value is currently an exact or like match. +

+
+

get_id

+
+MEMBER FUNCTION get_id
+return                                number,
+
+

+Returns a new primary key id value for a row. +

+
+

get_id

+
+STATIC FUNCTION get_id(
+aiv_code                       in     varchar2)
+return                                number,
+
+

+Returns the id for the specified code value. +

+
+

help,

+
+STATIC PROCEDURE help,
+
+

+Test-based help for this package. "set serveroutput on" in SQL*Plus. +

+
+

test,

+
+STATIC PROCEDURE test,
+
+

+Test units for this package. +

+
+

to_varchar2

+
+MAP MEMBER FUNCTION to_varchar2
+return                                varchar2
+)
+
+

+A MAP function for sorting at the object level. +

+
+ + diff --git a/Chapter09/solutions/gender_ts.html b/Chapter09/solutions/gender_ts.html new file mode 100644 index 0000000..adfdb50 --- /dev/null +++ b/Chapter09/solutions/gender_ts.html @@ -0,0 +1,105 @@ + + +GENDER_TS + + + +

Package GENDER_TS

+

+gender_ts.pks +by Don Bales on 12/15/2006 +Table GENDER_T's methods. +

+

+ + + + + + + + + + + + + + + + +
Method Summary
get_code_descrGets the code and decription values for the specified id
get_code_id_descrVerifies that the passed code value is an exact or like match on the date specified
get_code_id_descrVerifies that the passed code value is currently an exact or like match
get_idReturns a new primary key id value for a row
get_idReturns the id for the specified code value
helpTest-based help for this package
testTest units for this package
+


+ + +
Method Detail
+

get_code_descr

+
+PROCEDURE get_code_descr(
+ain_id                         in     GENDER_T.id%TYPE,
+aov_code                          out GENDER_T.code%TYPE,
+aov_description                   out GENDER_T.description%TYPE)
+
+

+Gets the code and decription values for the specified id. +

+
+

get_code_id_descr

+
+PROCEDURE get_code_id_descr(
+aiov_code                      in out GENDER_T.code%TYPE,
+aon_id                            out GENDER_T.id%TYPE,
+aov_description                   out GENDER_T.description%TYPE,
+aid_on                         in     GENDER_T.active_date%TYPE)
+
+

+Verifies that the passed code value is an exact or like match on the date specified. +

+
+

get_code_id_descr

+
+PROCEDURE get_code_id_descr(
+aiov_code                      in out GENDER_T.code%TYPE,
+aon_id                            out GENDER_T.id%TYPE,
+aov_description                   out GENDER_T.description%TYPE)
+
+

+Verifies that the passed code value is currently an exact or like match. +

+
+

get_id

+
+FUNCTION get_id
+return                                GENDER_T.id%TYPE
+
+

+Returns a new primary key id value for a row. +

+
+

get_id

+
+FUNCTION get_id(
+aiv_code                       in     GENDER_T.code%TYPE)
+return                                GENDER_T.id%TYPE
+
+

+Returns the id for the specified code value. +

+
+

help

+
+PROCEDURE help
+
+

+Test-based help for this package. "set serveroutput on" in SQL*Plus. +

+
+

test

+
+PROCEDURE test
+
+

+Test units for this package. +

+
+ + diff --git a/Chapter09/solutions/gender_ts.pkb b/Chapter09/solutions/gender_ts.pkb new file mode 100644 index 0000000..aa5ac42 --- /dev/null +++ b/Chapter09/solutions/gender_ts.pkb @@ -0,0 +1,357 @@ +create or replace PACKAGE BODY GENDER_TS as +/* +gender_ts.pkb +by Don Bales on 12/15/2006 +Table GENDER_T's methods +*/ + + +-- FUNCTIONS + +FUNCTION get_id +return GENDER_T.id%TYPE is + +n_id GENDER_T.id%TYPE; + +begin + select GENDER_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_id( +aiv_code in GENDER_T.code%TYPE ) +return GENDER_T.id%TYPE is + +n_id GENDER_T.id%TYPE; + +begin + select id + into n_id + from GENDER_T + where code = aiv_code; + + return n_id; +end get_id; + + +-- PROCEDURES + +PROCEDURE get_code_descr( +ain_id in GENDER_T.id%TYPE, +aov_code out GENDER_T.code%TYPE, +aov_description out GENDER_T.description%TYPE ) is + +begin + select code, + description + into aov_code, + aov_description + from GENDER_T + where id = ain_id; +end get_code_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE, +aid_on in GENDER_T.active_date%TYPE ) is + +v_code GENDER_T.code%TYPE; + +begin + select id, + description + into aon_id, + aov_description + from GENDER_T + where code = aiov_code + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); +exception + when NO_DATA_FOUND then + select id, + code, + description + into aon_id, + v_code, + aov_description + from GENDER_T + where code like aiov_code||'%' + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); + + aiov_code := v_code; +end get_code_id_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE ) is + +begin + get_code_id_descr( + aiov_code, + aon_id, + aov_description, + SYSDATE ); +end get_code_id_descr; + + +PROCEDURE help is + +begin +-- 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('GENDER_TS'); + pl(chr(9)); + pl('----------------------------------- FUNCTIONS ----------------------------------'); + pl(chr(9)); + pl('GENDER_TS.get_id'); + pl('return GENDER_T.id%TYPE;'); + pl(chr(9)||'Returns a newly allocated sequence value for id.'); + pl(chr(9)); + pl('GENDER_TS.get_id('); + pl('aiv_code in GENDER_T.code%TYPE )'); + pl('return GENDER_T.id%TYPE;'); + pl(chr(9)||'Returns the corresponding id for the specified code.'); + pl(chr(9)); + pl('----------------------------------- PROCEDURES ---------------------------------'); + pl(chr(9)); + pl('GENDER_TS.get_code_descr('); + pl('ain_id in GENDER_T.id%TYPE,'); + pl('aov_code out GENDER_T.code%TYPE,'); + pl('aov_description out GENDER_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding code and description for the specified'); + pl(chr(9)||'id.'); + pl(chr(9)); + pl('GENDER_TS.get_code_id_descr('); + pl('aiov_code in out GENDER_T.code%TYPE,'); + pl('aon_id out GENDER_T.id%TYPE,'); + pl('aov_description out GENDER_T.description%TYPE,'); + pl('aid_on in GENDER_T.active_date%TYPE );'); + pl(chr(9)||'Gets the corresponding code, id, and description for'); + pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified code and point in time.'); + pl(chr(9)); + pl('GENDER_TS.get_code_id_descr('); + pl('aiov_code in out GENDER_T.code%TYPE,'); + pl('aon_id out GENDER_T.id%TYPE,'); + pl('aov_description out GENDER_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding code, id, and description for'); + pl(chr(9)||'the specified code. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified code at the current point in time.'); + pl(chr(9)); + pl('GENDER_TS.help( );'); + pl(chr(9)||'Displays this help text if set serveroutput is on.'); + pl(chr(9)); + pl('GENDER_TS.test( );'); + pl(chr(9)||'Built-in test unit. It will report success or error for each test if set'); + pl(chr(9)||'serveroutput is on.'); + pl(chr(9)); +end help; + + +PROCEDURE test is + +n_id GENDER_T.id%TYPE; +v_code GENDER_T.code%TYPE; +v_description GENDER_T.description%TYPE; + +begin + -- Send feedback that the test ran + pl('GENDER_TS.test()'); + + -- Clear the last set of test results + TEST_TS.clear('GENDER_TS'); + + -- First, we need some test values + + -- Let's make sure they don't already exist: DELETE + TEST_TS.set_test('GENDER_TS', 'DELETE', 0, + 'Delete test entries'); + begin + delete GENDER_T + where code in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Now let's add three test codes: INSERT + TEST_TS.set_test('GENDER_TS', 'INSERT', 1, + 'Insert 3 test entries'); + begin + insert into GENDER_T ( + id, + code, + description, + active_date, + inactive_date ) + values ( + get_id(), + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101, + NULL ); + + insert into GENDER_T ( + id, + code, + description, + active_date, + inactive_date ) + values ( + get_id(), + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101, + TEST_TS.d_TEST_19991231 ); + + insert into GENDER_T ( + id, + code, + description, + active_date, + inactive_date ) + values ( + get_id(), + TEST_TS.v_TEST_30_2, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101, + TEST_TS.d_TEST_19991231 ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Now that we have test entries, + -- let's test the package methods + TEST_TS.set_test('GENDER_TS', 'get_id()', 2, + 'Get the ID for the specified code'); + begin + n_id := get_id(TEST_TS.v_TEST_30); + + if n_id > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('GENDER_TS', 'get_code_descr()', 3, + 'Get the code and description for the specified ID'); + begin + get_code_descr( + n_id, + v_code, + v_description); + if v_code = TEST_TS.v_TEST_30 and + v_description = TEST_TS.v_TEST_80 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('GENDER_TS', 'get_code_id_descr()', 4, + 'Get the code, ID, and description for the specified code'); + begin + v_code := 'TEST'; + get_code_id_descr( + v_code, + n_id, + v_description); + if v_code = TEST_TS.v_TEST_30 and + n_id > 0 and + v_description = TEST_TS.v_TEST_80 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('GENDER_TS', 'get_code_id_descr()', 5, + 'Get the code, ID, and description for the specified date'); + begin + v_code := 'TEST'; + -- This test should raise a TOO_MANY_ROWS exception + -- because at least three duplicate values will + -- on the date specified + get_code_id_descr( + v_code, + n_id, + v_description, + TEST_TS.d_TEST_19991231); + if v_code = TEST_TS.v_TEST_30 and + n_id > 0 and + v_description = TEST_TS.v_TEST_80 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when TOO_MANY_ROWS then + TEST_TS.ok(); + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('GENDER_TS', 'help()', 6, + 'Display help'); + begin + help(); + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Let's make sure they don't already exist: DELETE + TEST_TS.set_test('GENDER_TS', 'DELETE', 7, + 'Delete test entries'); + begin + delete GENDER_T + where code in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + raise_application_error(-20001, 'Test Failed'); + + TEST_TS.set_test('GENDER_TS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end GENDER_TS; +/ +@be.sql GENDER_TS + diff --git a/Chapter09/solutions/gender_ts.pks b/Chapter09/solutions/gender_ts.pks new file mode 100644 index 0000000..24c014e --- /dev/null +++ b/Chapter09/solutions/gender_ts.pks @@ -0,0 +1,66 @@ +create or replace PACKAGE GENDER_TS as +/* +gender_ts.pks +by Don Bales on 12/15/2006 +Table GENDER_T's methods. +*/ + + +/* +Gets the code and decription values for the specified id. +*/ +PROCEDURE get_code_descr( +ain_id in GENDER_T.id%TYPE, +aov_code out GENDER_T.code%TYPE, +aov_description out GENDER_T.description%TYPE); + + +/* +Verifies that the passed code value is an exact or like match on the date specified. +*/ +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE, +aid_on in GENDER_T.active_date%TYPE); + + +/* +Verifies that the passed code value is currently an exact or like match. +*/ +PROCEDURE get_code_id_descr( +aiov_code in out GENDER_T.code%TYPE, +aon_id out GENDER_T.id%TYPE, +aov_description out GENDER_T.description%TYPE); + + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return GENDER_T.id%TYPE; + + +/* +Returns the id for the specified code value. +*/ +FUNCTION get_id( +aiv_code in GENDER_T.code%TYPE) +return GENDER_T.id%TYPE; + + +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + + +/* +Test units for this package. +*/ +PROCEDURE test; + + +end GENDER_TS; +/ +@se.sql GENDER_TS diff --git a/Chapter09/solutions/html_help.html b/Chapter09/solutions/html_help.html new file mode 100644 index 0000000..90377ca --- /dev/null +++ b/Chapter09/solutions/html_help.html @@ -0,0 +1,60 @@ + + +HTML_HELP + + + +

Package HTML_HELP

+

+html_help.pks +by Donald J. Bales on 12/15/2006 +Package to create HTML-based help files for packages. +

+

+ + + + + + + + + + +
Method Summary
create_index Creates a "object_index" html file for the current USER
create_help Creates a "" html for each package for the current USER
help Text-based help for this package
test
+


+ + +
Method Detail
+

create_index

+
+PROCEDURE create_index
+
+

+Creates a "object_index" html file for the current USER. +

+
+

create_help

+
+PROCEDURE create_help(
+aiv_object_name                in     varchar2)
+
+

+Creates a "" html for each package for the current USER. +

+
+

help

+
+PROCEDURE help
+
+

+Text-based help for this package. "set serveroutput on" in SQL*Plus. +

+
+

test

+
+PROCEDURE test
+
+
+ + diff --git a/Chapter09/solutions/html_help.sql b/Chapter09/solutions/html_help.sql new file mode 100644 index 0000000..0abf754 --- /dev/null +++ b/Chapter09/solutions/html_help.sql @@ -0,0 +1,155 @@ +rem html_help.sql +rem by Don Bales on 12/15/2006 +rem Created by SQL*Plus script create_html_help.sql + +set feedback off; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; + +spool dates.html; +execute HTML_HELP.create_help('DATES'); +spool off; + +spool debug_o.html; +execute HTML_HELP.create_help('DEBUG_O'); +spool off; + +spool debug_ots.html; +execute HTML_HELP.create_help('DEBUG_OTS'); +spool off; + +spool debug_ts.html; +execute HTML_HELP.create_help('DEBUG_TS'); +spool off; + +spool emails.html; +execute HTML_HELP.create_help('EMAILS'); +spool off; + +spool gender_o.html; +execute HTML_HELP.create_help('GENDER_O'); +spool off; + +spool gender_ts.html; +execute HTML_HELP.create_help('GENDER_TS'); +spool off; + +spool html_help.html; +execute HTML_HELP.create_help('HTML_HELP'); +spool off; + +spool logical_assignment_ts.html; +execute HTML_HELP.create_help('LOGICAL_ASSIGNMENT_TS'); +spool off; + +spool logical_workplace_ts.html; +execute HTML_HELP.create_help('LOGICAL_WORKPLACE_TS'); +spool off; + +spool numbers.html; +execute HTML_HELP.create_help('NUMBERS'); +spool off; + +spool on_demand_process.html; +execute HTML_HELP.create_help('ON_DEMAND_PROCESS'); +spool off; + +spool parameters.html; +execute HTML_HELP.create_help('PARAMETERS'); +spool off; + +spool physical_assignment_ts.html; +execute HTML_HELP.create_help('PHYSICAL_ASSIGNMENT_TS'); +spool off; + +spool physical_workplace_ts.html; +execute HTML_HELP.create_help('PHYSICAL_WORKPLACE_TS'); +spool off; + +spool polling_process.html; +execute HTML_HELP.create_help('POLLING_PROCESS'); +spool off; + +spool report_staging_tables.html; +execute HTML_HELP.create_help('REPORT_STAGING_TABLES'); +spool off; + +spool scopes.html; +execute HTML_HELP.create_help('SCOPES'); +spool off; + +spool sys_yoid0000060409$.html; +execute HTML_HELP.create_help('SYS_YOID0000060409$'); +spool off; + +spool sys_yoid0000060417$.html; +execute HTML_HELP.create_help('SYS_YOID0000060417$'); +spool off; + +spool test_o.html; +execute HTML_HELP.create_help('TEST_O'); +spool off; + +spool test_ts.html; +execute HTML_HELP.create_help('TEST_TS'); +spool off; + +spool text_help.html; +execute HTML_HELP.create_help('TEXT_HELP'); +spool off; + +spool top_100_names.html; +execute HTML_HELP.create_help('TOP_100_NAMES'); +spool off; + +spool varchar2s.html; +execute HTML_HELP.create_help('VARCHAR2S'); +spool off; + +spool weekly_interface.html; +execute HTML_HELP.create_help('WEEKLY_INTERFACE'); +spool off; + +spool weekly_interface_statuss.html; +execute HTML_HELP.create_help('WEEKLY_INTERFACE_STATUSS'); +spool off; + +spool worker_o.html; +execute HTML_HELP.create_help('WORKER_O'); +spool off; + +spool worker_ts.html; +execute HTML_HELP.create_help('WORKER_TS'); +spool off; + +spool worker_type_o.html; +execute HTML_HELP.create_help('WORKER_TYPE_O'); +spool off; + +spool worker_type_ts.html; +execute HTML_HELP.create_help('WORKER_TYPE_TS'); +spool off; + +spool workplace_type_ts.html; +execute HTML_HELP.create_help('WORKPLACE_TYPE_TS'); +spool off; + +spool work_assignment_ts.html; +execute HTML_HELP.create_help('WORK_ASSIGNMENT_TS'); +spool off; + +spool work_ts.html; +execute HTML_HELP.create_help('WORK_TS'); +spool off; + +spool object_index.html; +execute HTML_HELP.create_index(); +spool off; + +set feedback on; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; diff --git a/Chapter09/solutions/logical_assignment_ts.html b/Chapter09/solutions/logical_assignment_ts.html new file mode 100644 index 0000000..e8063f0 --- /dev/null +++ b/Chapter09/solutions/logical_assignment_ts.html @@ -0,0 +1,154 @@ + + +LOGICAL_ASSIGNMENT_TS + + + +

Package LOGICAL_ASSIGNMENT_TS

+

+logical_assignment_ts.pks +Copyright by Donald J. Bales on 12/15/2006 +Table LOGICAL_ASSIGNMENT_T's methods +

+

+ + +
Global Constants and Variables
+
+

+Keep track of the number of inserts and updates to made by set_row(). +

+n_inserted                            number := 0;
+n_updated                             number := 0;
+
+

+ + + + + + + + + + + + + + + + + + + + +
Method Summary
get_idReturns a new primary key id value for a row
get_logical_workplaceReturns a the LOGICAL_WORKPLACE row for the specified worker_id and on the specified date
get_logical_workplaceReturns a the current LOGICAL_WORKPLACE row for the specified worker_id
get_rowReturns a LOGICAL_ASSIGNMENT row for the specified criteria
help Test-based help for this package
is_activeReturns TRUE if the worker has a logical assignment on the specified date, otherwise FALSE
is_activeReturns TRUE if the worker currently has a logical assignment, otherwise FALSE
set_rowUpdates or inserts a row matching the passed row into table LOGICAL_WORKPLACE_T
testThe test unit for this package
+


+ + +
Method Detail
+

get_id

+
+FUNCTION get_id
+return                                LOGICAL_ASSIGNMENT_T.id%TYPE
+
+

+Returns a new primary key id value for a row. +

+
+

get_logical_workplace

+
+FUNCTION get_logical_workplace(
+ain_worker_id                  in     LOGICAL_ASSIGNMENT_T.worker_id%TYPE,
+aid_on                         in     LOGICAL_ASSIGNMENT_T.active_date%TYPE)
+return                                LOGICAL_WORKPLACE_T%ROWTYPE
+
+

+Returns a the LOGICAL_WORKPLACE row for the specified worker_id and on the specified date. +

+
+

get_logical_workplace

+
+FUNCTION get_logical_workplace(
+ain_worker_id                  in     LOGICAL_ASSIGNMENT_T.worker_id%TYPE)
+return                                LOGICAL_WORKPLACE_T%ROWTYPE
+
+

+Returns a the current LOGICAL_WORKPLACE row for the specified worker_id. +

+
+

get_row

+
+FUNCTION get_row(
+air_logical_assignment         in     LOGICAL_ASSIGNMENT_T%ROWTYPE)
+return                                LOGICAL_ASSIGNMENT_T%ROWTYPE
+
+

+Returns a LOGICAL_ASSIGNMENT row for the specified criteria. +
+There are two sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the woker_id and active_date
+
+If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +

+
+

help

+
+PROCEDURE help
+
+

+Test-based help for this package. "set serveroutput on" in SQL*Plus. +

+
+

is_active

+
+FUNCTION is_active(
+ain_worker_id                  in     LOGICAL_ASSIGNMENT_T.worker_id%TYPE,
+aid_on                         in     date)
+return                                boolean
+
+

+Returns TRUE if the worker has a logical assignment on the specified date, otherwise FALSE. +

+
+

is_active

+
+FUNCTION is_active(
+ain_worker_id                  in     LOGICAL_ASSIGNMENT_T.worker_id%TYPE)
+return                                boolean
+
+

+Returns TRUE if the worker currently has a logical assignment, otherwise FALSE. +

+
+

set_row

+
+PROCEDURE set_row(
+aior_logical_assignment        in out LOGICAL_ASSIGNMENT_T%ROWTYPE)
+
+

+Updates or inserts a row matching the passed row into table LOGICAL_WORKPLACE_T. +
+First, set_row( ) calls get_row( ) to try to find a matching row that already +exists in the database. So you need to set the id, or worked_id +and active_date appropriately in order to properly detect an existing row.
+
+Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise a new row is inserted, including the allocation of +a new primary key value. Upon inserting a new value, the id +value is updated in the passed row.
+See PROCEDURE get_row( ); +

+
+

test

+
+PROCEDURE test
+
+

+The test unit for this package. +

+
+ + diff --git a/Chapter09/solutions/logical_assignment_ts.pks b/Chapter09/solutions/logical_assignment_ts.pks new file mode 100644 index 0000000..422df99 --- /dev/null +++ b/Chapter09/solutions/logical_assignment_ts.pks @@ -0,0 +1,102 @@ +create or replace PACKAGE LOGICAL_ASSIGNMENT_TS as +/* +logical_assignment_ts.pks +Copyright by Donald J. Bales on 12/15/2006 +Table LOGICAL_ASSIGNMENT_T's methods +*/ + +-- GLOBAL VARIABLES + +-- Keep track of the number of inserts and updates to made by set_row(). +n_inserted number := 0; +n_updated number := 0; + + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return LOGICAL_ASSIGNMENT_T.id%TYPE; + + +/* +Returns a the LOGICAL_WORKPLACE row for the specified worker_id and on the specified date. +*/ +FUNCTION get_logical_workplace( +ain_worker_id in LOGICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in LOGICAL_ASSIGNMENT_T.active_date%TYPE) +return LOGICAL_WORKPLACE_T%ROWTYPE; + + +/* +Returns a the current LOGICAL_WORKPLACE row for the specified worker_id. +*/ +FUNCTION get_logical_workplace( +ain_worker_id in LOGICAL_ASSIGNMENT_T.worker_id%TYPE) +return LOGICAL_WORKPLACE_T%ROWTYPE; + + +/* +Returns a LOGICAL_ASSIGNMENT row for the specified criteria. +
+There are two sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the woker_id and active_date
+
+If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_logical_assignment in LOGICAL_ASSIGNMENT_T%ROWTYPE) +return LOGICAL_ASSIGNMENT_T%ROWTYPE; + + +/* + Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + + +/* +Returns TRUE if the worker has a logical assignment on the specified date, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in LOGICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in date) +return boolean; + + +/* +Returns TRUE if the worker currently has a logical assignment, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in LOGICAL_ASSIGNMENT_T.worker_id%TYPE) +return boolean; + + +/* +Updates or inserts a row matching the passed row into table LOGICAL_WORKPLACE_T. +
+First, set_row( ) calls get_row( ) to try to find a matching row that already +exists in the database. So you need to set the id, or worked_id +and active_date appropriately in order to properly detect an existing row.
+
+Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise a new row is inserted, including the allocation of +a new primary key value. Upon inserting a new value, the id +value is updated in the passed row.
+See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_logical_assignment in out LOGICAL_ASSIGNMENT_T%ROWTYPE); + + +/* +The test unit for this package. +*/ +PROCEDURE test; + + +end LOGICAL_ASSIGNMENT_TS; +/ +@be.sql LOGICAL_ASSIGNMENT_TS diff --git a/Chapter09/solutions/logical_workplace_ts.html b/Chapter09/solutions/logical_workplace_ts.html new file mode 100644 index 0000000..e65d9bf --- /dev/null +++ b/Chapter09/solutions/logical_workplace_ts.html @@ -0,0 +1,159 @@ + + +LOGICAL_WORKPLACE_TS + + + +

Package LOGICAL_WORKPLACE_TS

+

+logical_workplace_ts.pks
+by Don Bales on 12/15/2006
+Table LOGICAL_WORKPLACE_T's methods. Contains all the supporting service +methods (functions and procedures) for table LOGICAL_WORKPLACE_T. +

+

+ + +
Global Constants and Variables
+
+

+Keep track of the number of inserts and updates to made by set_row( ). +

+n_inserted                            number := 0;
+n_updated                             number := 0;
+
+

+ + + + + + + + + + + + + + + + + + + + +
Method Summary
create_id_contextReturns an id_context for the specified parent_id and id
get_idReturns a new primary key id value for a row
get_code_contextReturns the value of a context for the code values in the logical workplace assignment
get_name_contextReturns the value of a context for the name values in the logical workplace assignment
get_rowReturns a LOGICAL_WORKPLACE row for the specified criteria
helpTest-based help for this package
set_rowUpdates or inserts a row matching the passed parameters into table LOGICAL_WORKPLACE_T
set_rowUpdates or inserts a row matching the passed row into table LOGICAL_WORKPLACE_T
testPerforms unit tests for this package
+


+ + +
Method Detail
+

create_id_context

+
+FUNCTION create_id_context(
+ain_parent_id                  in     LOGICAL_WORKPLACE_T.parent_id%TYPE,
+ain_id                         in     LOGICAL_WORKPLACE_T.id%TYPE)
+return                                varchar2
+
+

+Returns an id_context for the specified parent_id and id. +Whatever creates a new row must also call this mehtod to create an appropriate +id_context value. Method set_row( ) does this for you. +

+
+

get_id

+
+FUNCTION get_id
+return                                LOGICAL_WORKPLACE_T.id%TYPE
+
+

+Returns a new primary key id value for a row. +

+
+

get_code_context

+
+FUNCTION get_code_context(
+ain_id                         in     LOGICAL_WORKPLACE_T.id%TYPE)
+return                                varchar2
+
+

+Returns the value of a context for the code values in the logical workplace assignment. +

+
+

get_name_context

+
+FUNCTION get_name_context(
+ain_id                         in     LOGICAL_WORKPLACE_T.id%TYPE)
+return                                varchar2
+
+

+Returns the value of a context for the name values in the logical workplace assignment. +

+
+

get_row

+
+FUNCTION get_row(
+air_logical_workplace          in     LOGICAL_WORKPLACE_T%ROWTYPE)
+return                                LOGICAL_WORKPLACE_T%ROWTYPE
+
+

+Returns a LOGICAL_WORKPLACE row for the specified criteria. +There are three sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the unique id_context
+3. the code, name, and active_date
+If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +

+
+

help

+
+PROCEDURE help
+
+

+Test-based help for this package. "set serveroutput on" in SQL*Plus. +

+
+

set_row

+
+FUNCTION set_row(
+ain_parent_id                  in     LOGICAL_WORKPLACE_T.parent_id%TYPE,
+ain_workplace_type_id          in     LOGICAL_WORKPLACE_T.workplace_type_id%TYPE,
+aiv_code                       in     LOGICAL_WORKPLACE_T.code%TYPE,
+aiv_name                       in     LOGICAL_WORKPLACE_T.name%TYPE,
+aid_active_date                in     LOGICAL_WORKPLACE_T.active_date%TYPE)
+return                                LOGICAL_WORKPLACE_T.id%TYPE
+
+

+Updates or inserts a row matching the passed parameters into table LOGICAL_WORKPLACE_T. +See PROCEDURE set_row( ). +

+
+

set_row

+
+PROCEDURE set_row(
+aior_logical_workplace         in out LOGICAL_WORKPLACE_T%ROWTYPE)
+
+

+Updates or inserts a row matching the passed row into table LOGICAL_WORKPLACE_T. +First, set_row() calls get row to try to find a matching row that already +exists in the database. So you need to set the id, id_context, +and code, name and active_date appropriately in order to prperly detect an +existing row. +Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise, and new row is inserted, including the allocation of +a new primary key and id_context value. Upon inserting a new value, the +id and id_context values are updated in the passed row. +See PROCEDURE get_row( ); +

+
+

test

+
+PROCEDURE test
+
+

+Performs unit tests for this package. +

+
+ + diff --git a/Chapter09/solutions/logical_workplace_ts.pks b/Chapter09/solutions/logical_workplace_ts.pks new file mode 100644 index 0000000..a1a23ab --- /dev/null +++ b/Chapter09/solutions/logical_workplace_ts.pks @@ -0,0 +1,102 @@ +create or replace PACKAGE LOGICAL_WORKPLACE_TS as +/* +logical_workplace_ts.pks
+by Don Bales on 12/15/2006
+Table LOGICAL_WORKPLACE_T's methods. Contains all the supporting service +methods (functions and procedures) for table LOGICAL_WORKPLACE_T. +*/ + +-- GLOBAL VARIABLES + +-- Keep track of the number of inserts and updates to made by set_row( ). +n_inserted number := 0; +n_updated number := 0; + +/* +Returns an id_context for the specified parent_id and id. +Whatever creates a new row must also call this mehtod to create an appropriate +id_context value. Method set_row( ) does this for you. +*/ +FUNCTION create_id_context( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return LOGICAL_WORKPLACE_T.id%TYPE; + +/* +Returns the value of a context for the code values in the logical workplace assignment. +*/ +FUNCTION get_code_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns the value of a context for the name values in the logical workplace assignment. +*/ +FUNCTION get_name_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns a LOGICAL_WORKPLACE row for the specified criteria. + +There are three sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the unique id_context
+3. the code, name, and active_date
+ +If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_logical_workplace in LOGICAL_WORKPLACE_T%ROWTYPE) +return LOGICAL_WORKPLACE_T%ROWTYPE; + +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + +/* +Updates or inserts a row matching the passed parameters into table LOGICAL_WORKPLACE_T. +See PROCEDURE set_row( ). +*/ +FUNCTION set_row( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +ain_workplace_type_id in LOGICAL_WORKPLACE_T.workplace_type_id%TYPE, +aiv_code in LOGICAL_WORKPLACE_T.code%TYPE, +aiv_name in LOGICAL_WORKPLACE_T.name%TYPE, +aid_active_date in LOGICAL_WORKPLACE_T.active_date%TYPE) +return LOGICAL_WORKPLACE_T.id%TYPE; + +/* +Updates or inserts a row matching the passed row into table LOGICAL_WORKPLACE_T. + +First, set_row() calls get row to try to find a matching row that already +exists in the database. So you need to set the id, id_context, +and code, name and active_date appropriately in order to prperly detect an +existing row. + +Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise, and new row is inserted, including the allocation of +a new primary key and id_context value. Upon inserting a new value, the +id and id_context values are updated in the passed row. +See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_logical_workplace in out LOGICAL_WORKPLACE_T%ROWTYPE); + +/* +Performs unit tests for this package. +*/ +PROCEDURE test; + +end LOGICAL_WORKPLACE_TS; +/ +@se.sql LOGICAL_WORKPLACE_TS + diff --git a/Chapter09/solutions/numbers.html b/Chapter09/solutions/numbers.html new file mode 100644 index 0000000..c689c61 --- /dev/null +++ b/Chapter09/solutions/numbers.html @@ -0,0 +1,35 @@ + + +NUMBERS + + + +

Package NUMBERS

+

+numbers.pks +by Donald J. Bales on 12/15/2006 +A utility package for the data type NUMBER +

+

+ + + + +
Method Summary
to_number_or_null Returns the passed varchar2 as a number if it represents a number,
+


+ + +
Method Detail
+

to_number_or_null

+
+FUNCTION to_number_or_null (
+aiv_number                     in     varchar2 )
+return                                number
+
+

+Returns the passed varchar2 as a number if it represents a number, +otherwise, it returns NULL +

+
+ + diff --git a/Chapter09/solutions/numbers.pks b/Chapter09/solutions/numbers.pks new file mode 100644 index 0000000..2f3b7fa --- /dev/null +++ b/Chapter09/solutions/numbers.pks @@ -0,0 +1,18 @@ +create or replace package NUMBERS as +/* +numbers.pks +by Donald J. Bales on 12/15/2006 +A utility package for the data type NUMBER +*/ + +/* +Returns the passed varchar2 as a number if it represents a number, +otherwise, it returns NULL +*/ +FUNCTION to_number_or_null ( +aiv_number in varchar2 ) +return number; + +end NUMBERS; +/ +@se.sql diff --git a/Chapter09/solutions/object_index.html b/Chapter09/solutions/object_index.html new file mode 100644 index 0000000..d2890be --- /dev/null +++ b/Chapter09/solutions/object_index.html @@ -0,0 +1,42 @@ + + +Package/Type index + + + +

Owner BPS

+ + + + + + + + + + + + + + + + + + + + + + + + +
Packages/Types
DATESAdditional DATE data type methods.
DEBUG_Odebug_o.
DEBUG_OTSaiv_text in DEBUG_OT.
DEBUG_TSreturn DEBUG_T.
GENDER_Ogender_o.
GENDER_TSTable GENDER_T's methods.
HTML_HELPPackage to create HTML-based help files for packages.
LOGICAL_ASSIGNMENT_TS-- Keep track of the number of inserts and updates to made by +set_row().
LOGICAL_WORKPLACE_TSTable LOGICAL_WORKPLACE_T's methods.
PHYSICAL_ASSIGNMENT_TS-- Keep track of the number of inserts and updates to made by +set_row().
PHYSICAL_WORKPLACE_TSTable PHYSICAL_WORKPLACE_T's methods.
REPORT_STAGING_TABLES-- Display this package's help text.
TEST_Otest_o.
TEST_TSaiv_object_name TEST_T.
TEXT_HELPtest_help.
TOP_100_NAMESDisplay the help text for this package.
VARCHAR2S-- ending character values.
WEEKLY_INTERFACE-- Download the data source to its staging area.
WEEKLY_INTERFACE_STATUSS-- Returns TRUE if the data source has been recorded as +downloaded.
WORKER_Oworker_o.
WORKER_TSTable WORKER_T's methods.
WORKER_TYPE_Oworker_type_o.
WORKER_TYPE_TSCode Table WORKER_TYPE_T's methods.
WORKPLACE_TYPE_TSTable WORKPLACE_TYPE_T's methods.
WORK_ASSIGNMENT_TS-- Keep track of the number of inserts and updates to made by +set_row().
WORK_TSTable WORK_T's methods.
+ + diff --git a/Chapter09/solutions/on_demand_process.html b/Chapter09/solutions/on_demand_process.html new file mode 100644 index 0000000..036bf7e --- /dev/null +++ b/Chapter09/solutions/on_demand_process.html @@ -0,0 +1,54 @@ + + +ON_DEMAND_PROCESS + + + +

Package ON_DEMAND_PROCESS

+

+on_demand_process.pks +by Donald J. Bales on 12/15/2006 +On-demand Data Processing (ON_DEMAND): +An example of an on-demand data processing package +designed to truncate report staging tables +

+

+ + + + + + + + +
Method Summary
help Displays help text for this procedure
process Performs the desired on-demand processing
test This package's test units
+


+ + +
Method Detail
+

help

+
+PROCEDURE help
+
+

+Displays help text for this procedure +

+
+

process

+
+PROCEDURE process
+
+

+Performs the desired on-demand processing +

+
+

test

+
+PROCEDURE test
+
+

+This package's test units +

+
+ + diff --git a/Chapter09/solutions/parameters.html b/Chapter09/solutions/parameters.html new file mode 100644 index 0000000..03bf9d7 --- /dev/null +++ b/Chapter09/solutions/parameters.html @@ -0,0 +1,49 @@ + + +PARAMETERS + + + +

Package PARAMETERS

+

+parameters.pks +by Donald J. Bales on 12/15/2006 +A packge to test parameter scope +

+

+ + + + + + +
Method Summary
in_out_inout A function that execises the scope of parameters
in_out_inout A procedure that execises the scope of parameters
+


+ + +
Method Detail
+

in_out_inout

+
+FUNCTION in_out_inout(
+aiv_in                         in     varchar2,
+aov_out                           out varchar2,
+aiov_inout                     in out varchar2)
+return                                varchar2
+
+

+A function that execises the scope of parameters +

+
+

in_out_inout

+
+PROCEDURE in_out_inout(
+aiv_in                         in     varchar2,
+aov_out                           out varchar2,
+aiov_inout                     in out varchar2)
+
+

+A procedure that execises the scope of parameters +

+
+ + diff --git a/Chapter09/solutions/physical_assignment_ts.html b/Chapter09/solutions/physical_assignment_ts.html new file mode 100644 index 0000000..356831e --- /dev/null +++ b/Chapter09/solutions/physical_assignment_ts.html @@ -0,0 +1,154 @@ + + +PHYSICAL_ASSIGNMENT_TS + + + +

Package PHYSICAL_ASSIGNMENT_TS

+

+physical_assignment_ts.pks +Copyright by Donald J. Bales on 12/15/2006 +Table PHYSICAL_ASSIGNMENT_T's methods +

+

+ + +
Global Constants and Variables
+
+

+Keep track of the number of inserts and updates to made by set_row(). +

+n_inserted                            number := 0;
+n_updated                             number := 0;
+
+

+ + + + + + + + + + + + + + + + + + + + +
Method Summary
get_idReturns a new primary key id value for a row
get_physical_workplaceReturns a the PHYSICAL_WORKPLACE row for the specified worker_id and on the specified date
get_physical_workplaceReturns a the current PHYSICAL_WORKPLACE row for the specified worker_id
get_rowReturns a PHYSICAL_ASSIGNMENT row for the specified criteria
help Test-based help for this package
is_activeReturns TRUE if the worker has a physical assignment on the specified date, otherwise FALSE
is_activeReturns TRUE if the worker currently has a physical assignment, otherwise FALSE
set_rowUpdates or inserts a row matching the passed row into table PHYSICAL_WORKPLACE_T
testThe test unit for this package
+


+ + +
Method Detail
+

get_id

+
+FUNCTION get_id
+return                                PHYSICAL_ASSIGNMENT_T.id%TYPE
+
+

+Returns a new primary key id value for a row. +

+
+

get_physical_workplace

+
+FUNCTION get_physical_workplace(
+ain_worker_id                  in     PHYSICAL_ASSIGNMENT_T.worker_id%TYPE,
+aid_on                         in     PHYSICAL_ASSIGNMENT_T.active_date%TYPE)
+return                                PHYSICAL_WORKPLACE_T%ROWTYPE
+
+

+Returns a the PHYSICAL_WORKPLACE row for the specified worker_id and on the specified date. +

+
+

get_physical_workplace

+
+FUNCTION get_physical_workplace(
+ain_worker_id                  in     PHYSICAL_ASSIGNMENT_T.worker_id%TYPE)
+return                                PHYSICAL_WORKPLACE_T%ROWTYPE
+
+

+Returns a the current PHYSICAL_WORKPLACE row for the specified worker_id. +

+
+

get_row

+
+FUNCTION get_row(
+air_physical_assignment        in     PHYSICAL_ASSIGNMENT_T%ROWTYPE)
+return                                PHYSICAL_ASSIGNMENT_T%ROWTYPE
+
+

+Returns a PHYSICAL_ASSIGNMENT row for the specified criteria. +
+There are two sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the woker_id and active_date
+
+If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +

+
+

help

+
+PROCEDURE help
+
+

+Test-based help for this package. "set serveroutput on" in SQL*Plus. +

+
+

is_active

+
+FUNCTION is_active(
+ain_worker_id                  in     PHYSICAL_ASSIGNMENT_T.worker_id%TYPE,
+aid_on                         in     date)
+return                                boolean
+
+

+Returns TRUE if the worker has a physical assignment on the specified date, otherwise FALSE. +

+
+

is_active

+
+FUNCTION is_active(
+ain_worker_id                  in     PHYSICAL_ASSIGNMENT_T.worker_id%TYPE)
+return                                boolean
+
+

+Returns TRUE if the worker currently has a physical assignment, otherwise FALSE. +

+
+

set_row

+
+PROCEDURE set_row(
+aior_physical_assignment       in out PHYSICAL_ASSIGNMENT_T%ROWTYPE)
+
+

+Updates or inserts a row matching the passed row into table PHYSICAL_WORKPLACE_T. +
+First, set_row( ) calls get_row( ) to try to find a matching row that already +exists in the database. So you need to set the id, or worked_id +and active_date appropriately in order to properly detect an existing row.
+
+Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise a new row is inserted, including the allocation of +a new primary key value. Upon inserting a new value, the id +value is updated in the passed row.
+See PROCEDURE get_row( ); +

+
+

test

+
+PROCEDURE test
+
+

+The test unit for this package. +

+
+ + diff --git a/Chapter09/solutions/physical_assignment_ts.pks b/Chapter09/solutions/physical_assignment_ts.pks new file mode 100644 index 0000000..a70f463 --- /dev/null +++ b/Chapter09/solutions/physical_assignment_ts.pks @@ -0,0 +1,92 @@ +create or replace PACKAGE PHYSICAL_ASSIGNMENT_TS as +/* +physical_assignment_ts.pks +Copyright by Donald J. Bales on 12/15/2006 +Table PHYSICAL_ASSIGNMENT_T's methods +*/ + +-- GLOBAL VARIABLES +-- Keep track of the number of inserts and updates to made by set_row(). +n_inserted number := 0; +n_updated number := 0; + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return PHYSICAL_ASSIGNMENT_T.id%TYPE; + +/* +Returns a the PHYSICAL_WORKPLACE row for the specified worker_id and on the specified date. +*/ +FUNCTION get_physical_workplace( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in PHYSICAL_ASSIGNMENT_T.active_date%TYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE; + +/* +Returns a the current PHYSICAL_WORKPLACE row for the specified worker_id. +*/ +FUNCTION get_physical_workplace( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE; + +/* +Returns a PHYSICAL_ASSIGNMENT row for the specified criteria. +
+There are two sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the woker_id and active_date
+
+If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_physical_assignment in PHYSICAL_ASSIGNMENT_T%ROWTYPE) +return PHYSICAL_ASSIGNMENT_T%ROWTYPE; + +/* + Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + +/* +Returns TRUE if the worker has a physical assignment on the specified date, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in date) +return boolean; + +/* +Returns TRUE if the worker currently has a physical assignment, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE) +return boolean; + +/* +Updates or inserts a row matching the passed row into table PHYSICAL_WORKPLACE_T. +
+First, set_row( ) calls get_row( ) to try to find a matching row that already +exists in the database. So you need to set the id, or worked_id +and active_date appropriately in order to properly detect an existing row.
+
+Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise a new row is inserted, including the allocation of +a new primary key value. Upon inserting a new value, the id +value is updated in the passed row.
+See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_physical_assignment in out PHYSICAL_ASSIGNMENT_T%ROWTYPE); + +/* +The test unit for this package. +*/ +PROCEDURE test; + + +end PHYSICAL_ASSIGNMENT_TS; +/ +@be.sql PHYSICAL_ASSIGNMENT_TS diff --git a/Chapter09/solutions/physical_workplace_ts.html b/Chapter09/solutions/physical_workplace_ts.html new file mode 100644 index 0000000..4d99cf8 --- /dev/null +++ b/Chapter09/solutions/physical_workplace_ts.html @@ -0,0 +1,171 @@ + + +PHYSICAL_WORKPLACE_TS + + + +

Package PHYSICAL_WORKPLACE_TS

+

+id_ts.pks
+Copyright by Don Bales on 12/15/2006
+Table PHYSICAL_WORKPLACE_T's methods. Contains all the supporting service +methods (functions and procedures) for table PHYSICAL_WORKPLACE_T. +

+

+ + +
Global Constants and Variables
+
+

+Keep track of the number of inserts and updates to made by set_row( ). +

+n_inserted                            number := 0;
+n_updated                             number := 0;
+
+

+ + + + + + + + + + + + + + + + + + + + + + +
Method Summary
create_id_contextReturns an id_context for the specified parent_id and id_id
get_code_contextReturns the value of a context for the code values in the physical workplace assignment
get_idReturns a new primary key id value for a row
get_id_contextReturns the value of a context for the id values in the logical workplace assignment
get_name_contextReturns the value of a context for the name values in the physical workplace assignment
get_rowReturns a PHYSICAL_WORKPLACE row for the specified criteria
helpTest-based help for this package
set_rowUpdates or inserts a row matching the passed parameters into table PHYSICAL_WORKPLACE_T
set_rowUpdates or inserts a row matching the passed row into table PHYSICAL_WORKPLACE_T
testPerforms unit tests for this package
+


+ + +
Method Detail
+

create_id_context

+
+FUNCTION create_id_context(
+ain_parent_id                  in     PHYSICAL_WORKPLACE_T.parent_id%TYPE,
+ain_id_id                      in     PHYSICAL_WORKPLACE_T.id%TYPE)
+return                                varchar2
+
+

+Returns an id_context for the specified parent_id and id_id. +Whatever creates a new row must also call this mehtod to create an appropriate +id_context value. Method set_row() does this for you. +

+
+

get_code_context

+
+FUNCTION get_code_context(
+ain_id_id                      in     PHYSICAL_WORKPLACE_T.id%TYPE)
+return                                varchar2
+
+

+Returns the value of a context for the code values in the physical workplace assignment. +

+
+

get_id

+
+FUNCTION get_id
+return                                PHYSICAL_WORKPLACE_T.id%TYPE
+
+

+Returns a new primary key id value for a row. +

+
+

get_id_context

+
+FUNCTION get_id_context(
+ain_id_id                      in     PHYSICAL_WORKPLACE_T.id%TYPE)
+return                                varchar2
+
+

+Returns the value of a context for the id values in the logical workplace assignment. +

+
+

get_name_context

+
+FUNCTION get_name_context(
+ain_id_id                      in     PHYSICAL_WORKPLACE_T.id%TYPE)
+return                                varchar2
+
+

+Returns the value of a context for the name values in the physical workplace assignment. +

+
+

get_row

+
+FUNCTION get_row(
+air_id                         in     PHYSICAL_WORKPLACE_T%ROWTYPE)
+return                                PHYSICAL_WORKPLACE_T%ROWTYPE
+
+

+Returns a PHYSICAL_WORKPLACE row for the specified criteria. +There are three sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id_id
+2. the unique id_context
+3. the code, name, and active_date
+If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +

+
+

help

+
+PROCEDURE help
+
+

+Test-based help for this package. "set serveroutput on" in SQL*Plus. +

+
+

set_row

+
+FUNCTION set_row(
+ain_parent_id                  in     PHYSICAL_WORKPLACE_T.parent_id%TYPE,
+ain_workplace_type_id          in     PHYSICAL_WORKPLACE_T.workplace_type_id%TYPE,
+aiv_code                       in     PHYSICAL_WORKPLACE_T.code%TYPE,
+aiv_name                       in     PHYSICAL_WORKPLACE_T.name%TYPE,
+aid_active_date                in     PHYSICAL_WORKPLACE_T.active_date%TYPE)
+return                                PHYSICAL_WORKPLACE_T.id%TYPE
+
+

+Updates or inserts a row matching the passed parameters into table PHYSICAL_WORKPLACE_T. +See PROCEDURE set_row( ). +

+
+

set_row

+
+PROCEDURE set_row(
+aior_id                        in out PHYSICAL_WORKPLACE_T%ROWTYPE)
+
+

+Updates or inserts a row matching the passed row into table PHYSICAL_WORKPLACE_T. +First, set_row() calls get row to try to find a matching row that already +exists in the database. So you need to set the id_id, id_context, +and code, name and active_date appropriately in order to prperly detect an +existing row. +Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise, and new row is inserted, including the allocation of +a new primary key and id_context value. Upon inserting a new value, the +id_id and id_context values are updated in the passed row. +See PROCEDURE get_row( ); +

+
+

test

+
+PROCEDURE test
+
+

+Performs unit tests for this package. +

+
+ + diff --git a/Chapter09/solutions/physical_workplace_ts.pks b/Chapter09/solutions/physical_workplace_ts.pks new file mode 100644 index 0000000..2fc9f12 --- /dev/null +++ b/Chapter09/solutions/physical_workplace_ts.pks @@ -0,0 +1,114 @@ +create or replace PACKAGE PHYSICAL_WORKPLACE_TS as +/* +id_ts.pks
+Copyright by Don Bales on 12/15/2006
+Table PHYSICAL_WORKPLACE_T's methods. Contains all the supporting service +methods (functions and procedures) for table PHYSICAL_WORKPLACE_T. +*/ + +-- GLOBAL VARIABLES + +-- Keep track of the number of inserts and updates to made by set_row( ). +n_inserted number := 0; +n_updated number := 0; + + +/* +Returns an id_context for the specified parent_id and id_id. +Whatever creates a new row must also call this mehtod to create an appropriate +id_context value. Method set_row() does this for you. +*/ +FUNCTION create_id_context( +ain_parent_id in PHYSICAL_WORKPLACE_T.parent_id%TYPE, +ain_id_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns the value of a context for the code values in the physical workplace assignment. +*/ +FUNCTION get_code_context( +ain_id_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return PHYSICAL_WORKPLACE_T.id%TYPE; + +/* +Returns the value of a context for the id values in the logical workplace assignment. +*/ +FUNCTION get_id_context( +ain_id_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns the value of a context for the name values in the physical workplace assignment. +*/ +FUNCTION get_name_context( +ain_id_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns a PHYSICAL_WORKPLACE row for the specified criteria. + +There are three sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id_id
+2. the unique id_context
+3. the code, name, and active_date
+ +If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_id in PHYSICAL_WORKPLACE_T%ROWTYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE; + + +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + + +/* +Updates or inserts a row matching the passed parameters into table PHYSICAL_WORKPLACE_T. +See PROCEDURE set_row( ). +*/ +FUNCTION set_row( +ain_parent_id in PHYSICAL_WORKPLACE_T.parent_id%TYPE, +ain_workplace_type_id in PHYSICAL_WORKPLACE_T.workplace_type_id%TYPE, +aiv_code in PHYSICAL_WORKPLACE_T.code%TYPE, +aiv_name in PHYSICAL_WORKPLACE_T.name%TYPE, +aid_active_date in PHYSICAL_WORKPLACE_T.active_date%TYPE) +return PHYSICAL_WORKPLACE_T.id%TYPE; + + +/* +Updates or inserts a row matching the passed row into table PHYSICAL_WORKPLACE_T. + +First, set_row() calls get row to try to find a matching row that already +exists in the database. So you need to set the id_id, id_context, +and code, name and active_date appropriately in order to prperly detect an +existing row. + +Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise, and new row is inserted, including the allocation of +a new primary key and id_context value. Upon inserting a new value, the +id_id and id_context values are updated in the passed row. +See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_id in out PHYSICAL_WORKPLACE_T%ROWTYPE); + + +/* +Performs unit tests for this package. +*/ +PROCEDURE test; + + +end PHYSICAL_WORKPLACE_TS; +/ +@se.sql PHYSICAL_WORKPLACE_TS diff --git a/Chapter09/solutions/polling_process.html b/Chapter09/solutions/polling_process.html new file mode 100644 index 0000000..8c96795 --- /dev/null +++ b/Chapter09/solutions/polling_process.html @@ -0,0 +1,72 @@ + + +POLLING_PROCESS + + + +

Package POLLING_PROCESS

+

+polling_process.pks +by Donald J. Bales on 12/15/2006 +An example of a polling data processing package +

+

+ + + + + + + + + + + + +
Method Summary
enable Enable debug logging
disable Disable debug logging
process Perform the required polling type processing
quit Send a command to tell this process to quit
status Ask this process for it's current status
+


+ + +
Method Detail
+

enable

+
+PROCEDURE enable
+
+

+Enable debug logging +

+
+

disable

+
+PROCEDURE disable
+
+

+Disable debug logging +

+
+

process

+
+PROCEDURE process
+
+

+Perform the required polling type processing +

+
+

quit

+
+PROCEDURE quit
+
+

+Send a command to tell this process to quit +

+
+

status

+
+PROCEDURE status
+
+

+Ask this process for it's current status +

+
+ + diff --git a/Chapter09/solutions/report_staging_tables.html b/Chapter09/solutions/report_staging_tables.html new file mode 100644 index 0000000..66bd9cc --- /dev/null +++ b/Chapter09/solutions/report_staging_tables.html @@ -0,0 +1,54 @@ + + +REPORT_STAGING_TABLES + + + +

Package REPORT_STAGING_TABLES

+

+report_staging_tables.pks +by Donald J. Bales on 12/15/2006 +On-demand Data Processing (ODP): +An example of an on-demand data processing package +designed to truncate report staging tables +

+

+ + + + + + + + +
Method Summary
help Display this package's help text
process Delete any data more than two days old from the report staging tables
test Test this package's methods
+


+ + +
Method Detail
+

help

+
+PROCEDURE help
+
+

+Display this package's help text. +

+
+

process

+
+PROCEDURE process
+
+

+Delete any data more than two days old from the report staging tables. +

+
+

test

+
+PROCEDURE test
+
+

+Test this package's methods. +

+
+ + diff --git a/Chapter09/solutions/scopes.html b/Chapter09/solutions/scopes.html new file mode 100644 index 0000000..3c48174 --- /dev/null +++ b/Chapter09/solutions/scopes.html @@ -0,0 +1,54 @@ + + +SCOPES + + + +

Package SCOPES

+

+scopes.pks +by Donald J. Bales on 12/15/2006 +A package to test scope +

+

+ + +
Global Constants and Variables
+
+

+Here's a global variable declaration +

+gv_scope                              varchar2(80) :=
+'I''m a global (or package spec) variable';
+
+

+ + + + + + +
Method Summary
my_scope_is_global Here's a global (or package spec) function declaration
my_scope_is_global Here's a global (or package spec) procedure declaration
+


+ + +
Method Detail
+

my_scope_is_global

+
+FUNCTION my_scope_is_global
+return                                varchar2
+
+

+Here's a global (or package spec) function declaration +

+
+

my_scope_is_global

+
+PROCEDURE my_scope_is_global
+
+

+Here's a global (or package spec) procedure declaration +

+
+ + diff --git a/Chapter09/solutions/stylesheet.css b/Chapter09/solutions/stylesheet.css new file mode 100644 index 0000000..cc1fa1e --- /dev/null +++ b/Chapter09/solutions/stylesheet.css @@ -0,0 +1,17 @@ +h2 { font-size: 140% } +h3 { font-size: 120% } + +table { border-collapse: collapse; border-color: gray; border-style: solid; border-width: 1; background-color: white; text-align: left; width: 100% } +th { border-color: gray; border-style: solid; border-width: 1; background-color: lightgrey; padding: 3; font-size: 125% } +td { border-color: gray; border-style: solid; border-width: 1; background-color: white; padding: 3; font-size: 100% } + +.method_name_td { width: 20% } +.method_name_span { font-size: 80%; font-family: Monospace, New Courier; } +.method_pre { font-size: 80%; font-family: Monospace, New Courier; } +.package_name_td { width: 20% } +.package_name_span { font-size: 80%; font-family: Monospace, New Courier; } +.first_sentence_td { } +.first_sentence_span { font-size: 80%; font-family: Helvetica, Arial, sans-serif; } +.comments_td { } +.comments_span { font-size: 80%; font-family: Helvetica, Arial, sans-serif; } +.comments_p { font-size: 80%; font-family: Helvetica, Arial, sans-serif; } diff --git a/Chapter09/solutions/test_o.html b/Chapter09/solutions/test_o.html new file mode 100644 index 0000000..f0a67d0 --- /dev/null +++ b/Chapter09/solutions/test_o.html @@ -0,0 +1,299 @@ + + +TEST_O + + + +

Type TEST_O

+

+test_o.tps +by Donald J. Bales on 12/15/2006 +A Type for logging test results +

+

+ + +
Attributes
+
+

+Type TEST_O's attributes +

+id                                    number,
+object_name                           varchar2(30),
+method_name                           varchar2(30),
+test_number                           number,
+description                           varchar2(80),
+result                                varchar2(256),
+unique_session_id                     varchar2(24),
+insert_user                           varchar2(30),
+insert_date                           date,
+
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Method Summary
get_id Allocate the next primary key value fir id
get_test_19000101 Get the test value for January 1, 1900
get_test_19991231 Get the test value for December 31, 1999
get_test_n Get the test value N for any indicators
get_test_y Get the test value Y for any indicators
get_test_30 Get the 30 character test value
get_test_30_1 Get the first 30 character test value duplicate for LIKE
get_test_30_2 Get the second 30 character test value duplicate for LIKE
get_test_80 Get the 80 character test value
get_test_100 Get the 100 character test value
get_test_2000 Get the 2000 character test value
clear Clear any previous test run for the specified object name
error, Set the result to ERROR
error Set the result to Oracle ERROR
set_result Set the result to the specified result value
help, Show the help text for this object
ok, Set the result to OK
success, Set the result of the execution of test() to SUCCESS
test, Test this object
set_test Set the test about to be performed
to_map Get the map value
test_o Parameter-less constructor
test_o Convenience constructor
+


+ + +
Method Detail
+

get_id

+
+STATIC FUNCTION get_id
+return                                number,
+
+

+Allocate the next primary key value fir id +

+
+

get_test_19000101

+
+STATIC FUNCTION get_test_19000101
+return                                date,
+
+

+Get the test value for January 1, 1900 +

+
+

get_test_19991231

+
+STATIC FUNCTION get_test_19991231
+return                                date,
+
+

+Get the test value for December 31, 1999 +

+
+

get_test_n

+
+STATIC FUNCTION get_test_n
+return                                varchar2,
+
+

+Get the test value N for any indicators +

+
+

get_test_y

+
+STATIC FUNCTION get_test_y
+return                                varchar2,
+
+

+Get the test value Y for any indicators +

+
+

get_test_30

+
+STATIC FUNCTION get_test_30
+return                                varchar2,
+
+

+Get the 30 character test value +

+
+

get_test_30_1

+
+STATIC FUNCTION get_test_30_1
+return                                varchar2,
+
+

+Get the first 30 character test value duplicate for LIKE +

+
+

get_test_30_2

+
+STATIC FUNCTION get_test_30_2
+return                                varchar2,
+
+

+Get the second 30 character test value duplicate for LIKE +

+
+

get_test_80

+
+STATIC FUNCTION get_test_80
+return                                varchar2,
+
+

+Get the 80 character test value +

+
+

get_test_100

+
+STATIC FUNCTION get_test_100
+return                                varchar2,
+
+

+Get the 100 character test value +

+
+

get_test_2000

+
+STATIC FUNCTION get_test_2000
+return                                varchar2,
+
+

+Get the 2000 character test value +

+
+

clear

+
+STATIC PROCEDURE clear(
+aiv_object_name                       varchar2),
+
+

+Clear any previous test run for the specified object name +

+
+

error,

+
+MEMBER PROCEDURE error,
+
+

+Set the result to ERROR +

+
+

error

+
+MEMBER PROCEDURE error(
+aiv_result                     in     varchar2),
+
+

+Set the result to Oracle ERROR +

+
+

set_result

+
+MEMBER PROCEDURE set_result(
+aiv_result                     in     varchar2),
+
+

+Set the result to the specified result value +

+
+

help,

+
+STATIC PROCEDURE help,
+
+

+Show the help text for this object +

+
+

ok,

+
+MEMBER PROCEDURE ok,
+
+

+Set the result to OK +

+
+

success,

+
+MEMBER PROCEDURE success,
+
+

+Set the result of the execution of test() to SUCCESS +

+
+

test,

+
+STATIC PROCEDURE test,
+
+

+Test this object +

+
+

set_test

+
+MEMBER PROCEDURE set_test(
+aiv_object_name                in     varchar2,
+aiv_method_name                in     varchar2,
+ain_test_number                in     number,
+aiv_description                in     varchar2),
+
+

+Set the test about to be performed +

+
+

to_map

+
+MAP MEMBER FUNCTION to_map
+return                                number,
+
+

+Get the map value +

+
+

test_o

+
+CONSTRUCTOR FUNCTION test_o(
+self                           in out nocopy test_o)
+return                         self as result,
+
+

+Parameter-less constructor +

+
+

test_o

+
+CONSTRUCTOR FUNCTION test_o(
+self                           in out nocopy test_o,
+ain_id                         in     number,
+aiv_object_name                in     varchar2,
+aiv_method_name                in     varchar2,
+ain_test_number                in     number,
+aiv_description                in     varchar2)
+return                                self as result
+)
+
+

+Convenience constructor +

+
+ + diff --git a/Chapter09/solutions/test_ts.html b/Chapter09/solutions/test_ts.html new file mode 100644 index 0000000..9ddd28c --- /dev/null +++ b/Chapter09/solutions/test_ts.html @@ -0,0 +1,203 @@ + + +TEST_TS + + + +

Package TEST_TS

+

+test_ts.pks +by Donald J. Bales on 12/15/2006 +A Testing package +

+

+ + +
Global Constants and Variables
+
+

+Result constants +

+v_TEST_ERROR                constant  varchar2(5) := 'ERROR';
+v_TEST_OK                   constant  varchar2(2) := 'OK';
+v_TEST_SUCCESS              constant  varchar2(7) := 'SUCCESS';
+

+Testing constants +

+d_TEST_19000101             constant  date        :=
+to_date('19000101', 'YYYYMMDD');
+d_TEST_19991231             constant  date        :=
+to_date('19000101', 'YYYYMMDD');
+v_TEST_N                    constant  varchar2(1) := 'N';
+v_TEST_Y                    constant  varchar2(1) := 'Y';
+v_TEST_30                   constant  varchar2(30) :=
+'TEST TEST TEST TEST TEST TESTx';
+v_TEST_30_1                 constant  varchar2(30) :=
+'TEST1 TEST1 TEST1 TEST1 TEST1x';
+v_TEST_30_2                 constant  varchar2(30) :=
+'TEST2 TEST2 TEST2 TEST2 TEST2x';
+v_TEST_80                   constant  varchar2(80) :=
+'Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Testx';
+v_TEST_100                  constant  varchar2(100) :=
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Testx';
+v_TEST_2000                 constant  varchar2(2000) :=
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Test '||
+'Test Test Test Test Test Test Test Test Test Testx';
+
+

+ + + + + + + + + + + + + + + + + + + + + + +
Method Summary
clear Clear the results of the last test
error Set the result of the last test to v_TEST_ERROR
error Set the result of the last test to the passed Oracle error
help Display help text
initialize Instantiate the package
ok Set the result of the last test to v_TEST_OK
set_result Update the test with it's results
set_test Add a test
success Set the result of the last test to v_TEST_SUCCESS
test Test unit
+


+ + +
Method Detail
+

clear

+
+PROCEDURE clear(
+aiv_object_name                       TEST_T.object_name%TYPE)
+
+

+Clear the results of the last test +

+
+

error

+
+PROCEDURE error
+
+

+Set the result of the last test to v_TEST_ERROR +

+
+

error

+
+PROCEDURE error(
+aiv_result                     in     TEST_T.result%TYPE)
+
+

+Set the result of the last test to the passed Oracle error +

+
+

help

+
+PROCEDURE help
+
+

+Display help text +

+
+

initialize

+
+PROCEDURE initialize
+
+

+Instantiate the package +

+
+

ok

+
+PROCEDURE ok
+
+

+Set the result of the last test to v_TEST_OK +

+
+

set_result

+
+PROCEDURE set_result(
+aiv_result                     in     TEST_T.result%TYPE)
+
+

+Update the test with it's results +

+
+

set_test

+
+PROCEDURE set_test(
+aiv_object_name                in     TEST_T.object_name%TYPE,
+aiv_method_name                in     TEST_T.method_name%TYPE,
+ain_test_number                in     TEST_T.test_number%TYPE,
+aiv_description                in     TEST_T.description%TYPE)
+
+

+Add a test +

+
+

success

+
+PROCEDURE success
+
+

+Set the result of the last test to v_TEST_SUCCESS +

+
+

test

+
+PROCEDURE test
+
+

+Test unit +

+
+ + diff --git a/Chapter09/solutions/test_ts.pks b/Chapter09/solutions/test_ts.pks new file mode 100644 index 0000000..9c2807d --- /dev/null +++ b/Chapter09/solutions/test_ts.pks @@ -0,0 +1,134 @@ +create or replace package TEST_TS as +/* +test_ts.pks +by Donald J. Bales on 12/15/2006 +A Testing package +*/ + +-- Result constants +v_TEST_ERROR constant varchar2(5) := 'ERROR'; +v_TEST_OK constant varchar2(2) := 'OK'; +v_TEST_SUCCESS constant varchar2(7) := 'SUCCESS'; + +-- Testing constants +d_TEST_19000101 constant date := + to_date('19000101', 'YYYYMMDD'); +d_TEST_19991231 constant date := + to_date('19000101', 'YYYYMMDD'); + +v_TEST_N constant varchar2(1) := 'N'; + +v_TEST_Y constant varchar2(1) := 'Y'; + +v_TEST_30 constant varchar2(30) := + 'TEST TEST TEST TEST TEST TESTx'; + +v_TEST_30_1 constant varchar2(30) := + 'TEST1 TEST1 TEST1 TEST1 TEST1x'; + +v_TEST_30_2 constant varchar2(30) := + 'TEST2 TEST2 TEST2 TEST2 TEST2x'; + +v_TEST_80 constant varchar2(80) := + 'Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Testx'; + +v_TEST_100 constant varchar2(100) := + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Testx'; + +v_TEST_2000 constant varchar2(2000) := + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Test '|| + 'Test Test Test Test Test Test Test Test Test Testx'; + +-- 1 2 3 4 5 +-- 12345678901234567890123456789012345678901234567890 + +-- Clear the results of the last test +PROCEDURE clear( +aiv_object_name TEST_T.object_name%TYPE); + + +-- Set the result of the last test to v_TEST_ERROR +PROCEDURE error; + + +-- Set the result of the last test to the passed Oracle error +PROCEDURE error( +aiv_result in TEST_T.result%TYPE); + + +-- Display help text +PROCEDURE help; + + +-- Instantiate the package +PROCEDURE initialize; + + +-- Set the result of the last test to v_TEST_OK +PROCEDURE ok; + + +-- Update the test with it's results +PROCEDURE set_result( +aiv_result in TEST_T.result%TYPE); + + +-- Add a test +PROCEDURE set_test( +aiv_object_name in TEST_T.object_name%TYPE, +aiv_method_name in TEST_T.method_name%TYPE, +ain_test_number in TEST_T.test_number%TYPE, +aiv_description in TEST_T.description%TYPE); + + +-- Set the result of the last test to v_TEST_SUCCESS +PROCEDURE success; + + +-- Test unit +PROCEDURE test; + + +end TEST_TS; +/ +@se.sql TEST_TS diff --git a/Chapter09/solutions/text_help.html b/Chapter09/solutions/text_help.html new file mode 100644 index 0000000..8658cf9 --- /dev/null +++ b/Chapter09/solutions/text_help.html @@ -0,0 +1,53 @@ + + +TEXT_HELP + + + +

Package TEXT_HELP

+

+test_help.pkb +by Donald J. Bales on 12/15/2006 +A package to produce text based help +

+

+ + + + + + + + +
Method Summary
helpThe help text for this package
processGenerate help text for the specified object using its specification
testThe test unit for this package
+


+ + +
Method Detail
+

help

+
+PROCEDURE help
+
+

+The help text for this package. +

+
+

process

+
+PROCEDURE process(
+aiv_object_name               in     varchar2)
+
+

+Generate help text for the specified object using its specification. +

+
+

test

+
+PROCEDURE test
+
+

+The test unit for this package. +

+
+ + diff --git a/Chapter09/solutions/top_100_names.html b/Chapter09/solutions/top_100_names.html new file mode 100644 index 0000000..47cea47 --- /dev/null +++ b/Chapter09/solutions/top_100_names.html @@ -0,0 +1,66 @@ + + +TOP_100_NAMES + + + +

Package TOP_100_NAMES

+

+top_100_names.pks +by Donald J. Bales on 12/15/2006 +Data Migration: +Seed the Worker table with the top 100 names +100 last x 100 first x 26 middle = 260,000 entries +

+

+ + + + + + + + + + +
Method Summary
helpDisplay the help text for this package
InitializeInitializes package pseudo-constants, it is called
ProcessMigrates data (inserts or updates) from tables TOP_100_LAST_NAME,
testTest the methods in this package
+


+ + +
Method Detail
+

help

+
+PROCEDURE help
+
+

+Display the help text for this package. +

+
+

Initialize

+
+PROCEDURE Initialize
+
+

+Initializes package pseudo-constants, it is called +by the package body's initialization section. +

+
+

Process

+
+PROCEDURE Process
+
+

+Migrates data (inserts or updates) from tables TOP_100_LAST_NAME, +TOP_100_FIRST_NAME, and A_THRU_Z to table WORKER_TS +

+
+

test

+
+PROCEDURE test
+
+

+Test the methods in this package +

+
+ + diff --git a/Chapter09/solutions/top_100_names.pks b/Chapter09/solutions/top_100_names.pks new file mode 100644 index 0000000..db74492 --- /dev/null +++ b/Chapter09/solutions/top_100_names.pks @@ -0,0 +1,35 @@ +create or replace package TOP_100_NAMES as +/* +top_100_names.pks +by Donald J. Bales on 12/15/2006 + +Data Migration: + Seed the Worker table with the top 100 names + 100 last x 100 first x 26 middle = 260,000 entries +*/ + +/* +Display the help text for this package. +*/ +PROCEDURE help; + +/* +Initializes package pseudo-constants, it is called +by the package body's initialization section. +*/ +PROCEDURE Initialize; + +/* +Migrates data (inserts or updates) from tables TOP_100_LAST_NAME, +TOP_100_FIRST_NAME, and A_THRU_Z to table WORKER_TS +*/ +PROCEDURE Process; + +/* +Test the methods in this package +*/ +PROCEDURE test; + +end TOP_100_NAMES; +/ +@se.sql diff --git a/Chapter09/solutions/varchar2s.html b/Chapter09/solutions/varchar2s.html new file mode 100644 index 0000000..da407de --- /dev/null +++ b/Chapter09/solutions/varchar2s.html @@ -0,0 +1,45 @@ + + +VARCHAR2S + + + +

Package VARCHAR2S

+

+varchar2s.pks +Copyright by Donald J. Bales on 12/15/2006 +VARCHAR2 data type utilities +

+

+ + + + + + +
Method Summary
random ending character values
test This package's test units
+


+ + +
Method Detail
+

random

+
+FUNCTION random(
+aiv_starting_character                varchar2,
+aiv_ending_character                  varchar2)
+return                                varchar2
+
+

+ending character values. +

+
+

test

+
+PROCEDURE test
+
+

+This package's test units +

+
+ + diff --git a/Chapter09/solutions/varchar2s.pks b/Chapter09/solutions/varchar2s.pks new file mode 100644 index 0000000..825a3ce --- /dev/null +++ b/Chapter09/solutions/varchar2s.pks @@ -0,0 +1,21 @@ +create or replace package VARCHAR2S as +/* +varchar2s.pks +Copyright by Donald J. Bales on 12/15/2006 +VARCHAR2 data type utilities +*/ + +-- Returns a randomly generated character between the specificed starting and +-- ending character values. +FUNCTION random( +aiv_starting_character varchar2, +aiv_ending_character varchar2) +return varchar2; + +-- This package's test units +PROCEDURE test; + + +end VARCHAR2S; +/ +@se.sql VARCHAR2S diff --git a/Chapter09/solutions/weekly_interface.html b/Chapter09/solutions/weekly_interface.html new file mode 100644 index 0000000..ff9582d --- /dev/null +++ b/Chapter09/solutions/weekly_interface.html @@ -0,0 +1,84 @@ + + +WEEKLY_INTERFACE + + + +

Package WEEKLY_INTERFACE

+

+weekly_interface.pks +by Donald J. Bales on 12/15/2006 +An example of a weekly interface process +

+

+ + + + + + + + + + + + + + +
Method Summary
download Download the data source to its staging area
is_downloaded Returns TRUE if the data source has been downloaded THIS week
process Download if needed, then upload if needed, THIS week
set_downloaded Record that the data source has been downloaded for THIS week
upload Upload the data source into the target relational structure
is_verified Returns TRUE is the data source's code have been verified
+


+ + +
Method Detail
+

download

+
+PROCEDURE download
+
+

+Download the data source to its staging area. +

+
+

is_downloaded

+
+FUNCTION is_downloaded
+return                                number
+
+

+Returns TRUE if the data source has been downloaded THIS week. +

+
+

process

+
+PROCEDURE process
+
+

+Download if needed, then upload if needed, THIS week. +

+
+

set_downloaded

+
+PROCEDURE set_downloaded
+
+

+Record that the data source has been downloaded for THIS week. +

+
+

upload

+
+PROCEDURE upload
+
+

+Upload the data source into the target relational structure. +

+
+

is_verified

+
+FUNCTION is_verified
+return                                boolean
+
+

+Returns TRUE is the data source's code have been verified. +

+
+ + diff --git a/Chapter09/solutions/weekly_interface_statuss.html b/Chapter09/solutions/weekly_interface_statuss.html new file mode 100644 index 0000000..e3335fb --- /dev/null +++ b/Chapter09/solutions/weekly_interface_statuss.html @@ -0,0 +1,75 @@ + + +WEEKLY_INTERFACE_STATUSS + + + +

Package WEEKLY_INTERFACE_STATUSS

+

+weekly_interface_statuss.pks +by Donald J. Bales on 12/15/2006 +Table WEEKLY_INTERFACE_STATUS' routines +

+

+ + + + + + + + + + + + +
Method Summary
get_week Returns the CURRENT number of the week in the CURRENT year
is_downloaded Returns TRUE if the data source has been recorded as downloaded
is_uploaded Returns TRUE if the data source has been recorded as uploaded
set_downloaded Record that the data source has been downloaded for THIS week
set_uploaded Record that the data source has been uploaded for THIS week
+


+ + +
Method Detail
+

get_week

+
+FUNCTION get_week
+return                                number
+
+

+Returns the CURRENT number of the week in the CURRENT year +

+
+

is_downloaded

+
+FUNCTION is_downloaded
+return                                boolean
+
+

+Returns TRUE if the data source has been recorded as downloaded. +

+
+

is_uploaded

+
+FUNCTION is_uploaded
+return                                boolean
+
+

+Returns TRUE if the data source has been recorded as uploaded. +

+
+

set_downloaded

+
+PROCEDURE set_downloaded
+
+

+Record that the data source has been downloaded for THIS week. +

+
+

set_uploaded

+
+PROCEDURE set_uploaded
+
+

+Record that the data source has been uploaded for THIS week. +

+
+ + diff --git a/Chapter09/solutions/work_assignment_ts.html b/Chapter09/solutions/work_assignment_ts.html new file mode 100644 index 0000000..8fa54fe --- /dev/null +++ b/Chapter09/solutions/work_assignment_ts.html @@ -0,0 +1,154 @@ + + +WORK_ASSIGNMENT_TS + + + +

Package WORK_ASSIGNMENT_TS

+

+work_assignment_ts.pks +by Donald J. Bales on 12/15/2006 +Table WORK_ASSIGNMENT_T's methods +

+

+ + +
Global Constants and Variables
+
+

+Keep track of the number of inserts and updates to made by set_row(). +

+n_inserted                            number := 0;
+n_updated                             number := 0;
+
+

+ + + + + + + + + + + + + + + + + + + + +
Method Summary
get_idReturns a new primary key id value for a row
get_workReturns a the WORK row for the specified worker_id and on the specified date
get_workReturns a the current WORK row for the specified worker_id
get_rowReturns a WORK_ASSIGNMENT row for the specified criteria
help Test-based help for this package
is_activeReturns TRUE if the worker has a work assignment on the specified date, otherwise FALSE
is_activeReturns TRUE if the worker currently has a work assignment, otherwise FALSE
set_rowUpdates or inserts a row matching the passed row into table WORK_WORKPLACE_T
testThe test unit for this package
+


+ + +
Method Detail
+

get_id

+
+FUNCTION get_id
+return                                WORK_ASSIGNMENT_T.id%TYPE
+
+

+Returns a new primary key id value for a row. +

+
+

get_work

+
+FUNCTION get_work(
+ain_worker_id                  in     WORK_ASSIGNMENT_T.worker_id%TYPE,
+aid_on                         in     WORK_ASSIGNMENT_T.active_date%TYPE)
+return                                WORK_T%ROWTYPE
+
+

+Returns a the WORK row for the specified worker_id and on the specified date. +

+
+

get_work

+
+FUNCTION get_work(
+ain_worker_id                  in     WORK_ASSIGNMENT_T.worker_id%TYPE)
+return                                WORK_T%ROWTYPE
+
+

+Returns a the current WORK row for the specified worker_id. +

+
+

get_row

+
+FUNCTION get_row(
+air_work_assignment            in     WORK_ASSIGNMENT_T%ROWTYPE)
+return                                WORK_ASSIGNMENT_T%ROWTYPE
+
+

+Returns a WORK_ASSIGNMENT row for the specified criteria. +
+There are two sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the woker_id and active_date
+
+If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +

+
+

help

+
+PROCEDURE help
+
+

+Test-based help for this package. "set serveroutput on" in SQL*Plus. +

+
+

is_active

+
+FUNCTION is_active(
+ain_worker_id                  in     WORK_ASSIGNMENT_T.worker_id%TYPE,
+aid_on                         in     date)
+return                                boolean
+
+

+Returns TRUE if the worker has a work assignment on the specified date, otherwise FALSE. +

+
+

is_active

+
+FUNCTION is_active(
+ain_worker_id                  in     WORK_ASSIGNMENT_T.worker_id%TYPE)
+return                                boolean
+
+

+Returns TRUE if the worker currently has a work assignment, otherwise FALSE. +

+
+

set_row

+
+PROCEDURE set_row(
+aior_work_assignment           in out WORK_ASSIGNMENT_T%ROWTYPE)
+
+

+Updates or inserts a row matching the passed row into table WORK_WORKPLACE_T. +
+First, set_row( ) calls get_row( ) to try to find a matching row that already +exists in the database. So you need to set the id, or worked_id +and active_date appropriately in order to properly detect an existing row.
+
+Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise a new row is inserted, including the allocation of +a new primary key value. Upon inserting a new value, the id +value is updated in the passed row.
+See PROCEDURE get_row( ); +

+
+

test

+
+PROCEDURE test
+
+

+The test unit for this package. +

+
+ + diff --git a/Chapter09/solutions/work_assignment_ts.pks b/Chapter09/solutions/work_assignment_ts.pks new file mode 100644 index 0000000..6592554 --- /dev/null +++ b/Chapter09/solutions/work_assignment_ts.pks @@ -0,0 +1,92 @@ +create or replace PACKAGE WORK_ASSIGNMENT_TS as +/* +work_assignment_ts.pks +by Donald J. Bales on 12/15/2006 +Table WORK_ASSIGNMENT_T's methods +*/ + +-- GLOBAL VARIABLES +-- Keep track of the number of inserts and updates to made by set_row(). +n_inserted number := 0; +n_updated number := 0; + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return WORK_ASSIGNMENT_T.id%TYPE; + +/* +Returns a the WORK row for the specified worker_id and on the specified date. +*/ +FUNCTION get_work( +ain_worker_id in WORK_ASSIGNMENT_T.worker_id%TYPE, +aid_on in WORK_ASSIGNMENT_T.active_date%TYPE) +return WORK_T%ROWTYPE; + +/* +Returns a the current WORK row for the specified worker_id. +*/ +FUNCTION get_work( +ain_worker_id in WORK_ASSIGNMENT_T.worker_id%TYPE) +return WORK_T%ROWTYPE; + +/* +Returns a WORK_ASSIGNMENT row for the specified criteria. +
+There are two sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the woker_id and active_date
+
+If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_work_assignment in WORK_ASSIGNMENT_T%ROWTYPE) +return WORK_ASSIGNMENT_T%ROWTYPE; + +/* + Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + +/* +Returns TRUE if the worker has a work assignment on the specified date, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in WORK_ASSIGNMENT_T.worker_id%TYPE, +aid_on in date) +return boolean; + +/* +Returns TRUE if the worker currently has a work assignment, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in WORK_ASSIGNMENT_T.worker_id%TYPE) +return boolean; + +/* +Updates or inserts a row matching the passed row into table WORK_WORKPLACE_T. +
+First, set_row( ) calls get_row( ) to try to find a matching row that already +exists in the database. So you need to set the id, or worked_id +and active_date appropriately in order to properly detect an existing row.
+
+Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise a new row is inserted, including the allocation of +a new primary key value. Upon inserting a new value, the id +value is updated in the passed row.
+See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_work_assignment in out WORK_ASSIGNMENT_T%ROWTYPE); + +/* +The test unit for this package. +*/ +PROCEDURE test; + + +end WORK_ASSIGNMENT_TS; +/ +@be.sql WORK_ASSIGNMENT_TS diff --git a/Chapter09/solutions/work_ts.html b/Chapter09/solutions/work_ts.html new file mode 100644 index 0000000..1fe125e --- /dev/null +++ b/Chapter09/solutions/work_ts.html @@ -0,0 +1,117 @@ + + +WORK_TS + + + +

Package WORK_TS

+

+work_ts.pks
+by Donald Bales on 12/15/2006
+Table WORK_T's methods. Contains all the supporting service +methods (functions and procedures) for table WORK_T. +

+

+ + +
Global Constants and Variables
+
+

+Keep track of the number of inserts and updates to made by set_row( ). +

+n_inserted                            number := 0;
+n_updated                             number := 0;
+
+

+ + + + + + + + + + + + + + +
Method Summary
get_idReturns a new primary key id value for a row
get_rowReturns a WORK row for the specified criteria
helpText-based help for this package
set_rowUpdates or inserts a row matching the passed row into table WORK_T
set_rowParametric version of set_row()
testPerforms unit tests for this package
+


+ + +
Method Detail
+

get_id

+
+FUNCTION get_id
+return                                WORK_T.id%TYPE
+
+

+Returns a new primary key id value for a row. +

+
+

get_row

+
+FUNCTION get_row(
+air_work                       in     WORK_T%ROWTYPE)
+return                                WORK_T%ROWTYPE
+
+

+Returns a WORK row for the specified criteria. +There are three sets of criteria. You can retrieve a row by specifying:
+1. the primary key: work_id
+2. the unique id_context
+3. the code, name, and active_date
+If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +

+
+

help

+
+PROCEDURE help
+
+

+Text-based help for this package. +

+
+

set_row

+
+PROCEDURE set_row(
+aior_work                      in out WORK_T%ROWTYPE)
+
+

+Updates or inserts a row matching the passed row into table WORK_T. +First, set_row() calls get row to try to find a matching row that already +exists in the database. So you need to set the work_id, id_context, +and code, name and active_date appropriately in order to prperly detect an +existing row. +Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise, and new row is inserted, including the allocation of +a new primary key and id_context value. Upon inserting a new value, the +work_id and id_context values are updated in the passed row. +See PROCEDURE get_row( ); +

+
+

set_row

+
+PROCEDURE set_row(
+aiv_code                       in     WORK_T.code%TYPE,
+aiv_name                       in     WORK_T.name%TYPE,
+aid_active_date                in     WORK_T.active_date%TYPE,
+aid_inactive_date              in     WORK_T.inactive_date%TYPE)
+
+

+Parametric version of set_row() +

+
+

test

+
+PROCEDURE test
+
+

+Performs unit tests for this package. +

+
+ + diff --git a/Chapter09/solutions/work_ts.pks b/Chapter09/solutions/work_ts.pks new file mode 100644 index 0000000..7f6799d --- /dev/null +++ b/Chapter09/solutions/work_ts.pks @@ -0,0 +1,75 @@ +create or replace PACKAGE WORK_TS as +/* +work_ts.pks
+by Donald Bales on 12/15/2006
+Table WORK_T's methods. Contains all the supporting service +methods (functions and procedures) for table WORK_T. +*/ + +-- GLOBAL VARIABLES + +-- Keep track of the number of inserts and updates to made by set_row( ). +n_inserted number := 0; +n_updated number := 0; + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return WORK_T.id%TYPE; + +/* +Returns a WORK row for the specified criteria. + +There are three sets of criteria. You can retrieve a row by specifying:
+1. the primary key: work_id
+2. the unique id_context
+3. the code, name, and active_date
+ +If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_work in WORK_T%ROWTYPE) +return WORK_T%ROWTYPE; + +/* +Text-based help for this package. +*/ +PROCEDURE help; + +/* +Updates or inserts a row matching the passed row into table WORK_T. + +First, set_row() calls get row to try to find a matching row that already +exists in the database. So you need to set the work_id, id_context, +and code, name and active_date appropriately in order to prperly detect an +existing row. + +Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise, and new row is inserted, including the allocation of +a new primary key and id_context value. Upon inserting a new value, the +work_id and id_context values are updated in the passed row. +See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_work in out WORK_T%ROWTYPE); + +/* +Parametric version of set_row() +*/ +PROCEDURE set_row( +aiv_code in WORK_T.code%TYPE, +aiv_name in WORK_T.name%TYPE, +aid_active_date in WORK_T.active_date%TYPE, +aid_inactive_date in WORK_T.inactive_date%TYPE); + +/* +Performs unit tests for this package. +*/ +PROCEDURE test; + + +end WORK_TS; +/ +@se.sql WORK_TS diff --git a/Chapter09/solutions/worker_o.html b/Chapter09/solutions/worker_o.html new file mode 100644 index 0000000..19511ec --- /dev/null +++ b/Chapter09/solutions/worker_o.html @@ -0,0 +1,302 @@ + + +WORKER_O + + + +

Type WORKER_O

+

+worker_o.tps +by Don Bales on 12/15/2006 +Type WORKER_O's attributes and methods. +

+

+ + +
Attributes
+
+

+worker_o.tps +by Don Bales on 12/15/2006 +Type WORKER_O's attributes and methods. +

+id                                    number,
+worker_type_id                        number,
+external_id                           varchar2(30),
+first_name                            varchar2(30),
+middle_name                           varchar2(30),
+last_name                             varchar2(30),
+name                                  varchar2(100),
+birth_date                            date,
+gender_id                             number,
+
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Method Summary
get_ageGet the worker's current age
get_ageGet the worker's age on the specified date
get_ageCalculate a worker's age for the given birth date
get_ageCalculate a worker's current age for the given bith date
get_ageGet the specified worker's age at the given point in time
get_ageGet the specified worker's current age
get_birth_dateGet the specified worker's birth date
get_external_idGet the specified worker's external ID
get_formatted_nameCalculate the locale specific formatted name
get_formatted_nameGet the specified worker's formatted name
get_idGet the next primary key value for the table
get_idGet the specified worker's internal ID
get_rowGet the specified worker's row object
get_unformatted_nameCalculate the non-locale specific unformmated name
help,Display the help text for this TYPE
is_duplicateCheck to see if a worker with the same name, birth_date and
set_rowSet the specified worker's row object
test,Execute the test unit for this TYPE
to_varchar2The MAP function for this TYPE
worker_oA convenience constructor for this TYPE
worker_oA NULL values constructor for this TYPE
+


+ + +
Method Detail
+

get_age

+
+MEMBER FUNCTION get_age
+return                                number,
+
+

+Get the worker's current age. +

+
+

get_age

+
+MEMBER FUNCTION get_age(
+aid_on                                date)
+return                                number,
+
+

+Get the worker's age on the specified date. +

+
+

get_age

+
+STATIC FUNCTION get_age(
+aid_birth_date                 in     date,
+aid_on                         in     date)
+return                                number,
+
+

+Calculate a worker's age for the given birth date +and point in time. +

+
+

get_age

+
+STATIC FUNCTION get_age(
+aid_birth_date                 in     date)
+return                                number,
+
+

+Calculate a worker's current age for the given bith date. +

+
+

get_age

+
+STATIC FUNCTION get_age(
+ain_id                         in     number,
+aid_on                         in     date)
+return                                number,
+
+

+Get the specified worker's age at the given point in time. +

+
+

get_age

+
+STATIC FUNCTION get_age(
+ain_id                         in     number)
+return                                number,
+
+

+Get the specified worker's current age. +

+
+

get_birth_date

+
+STATIC FUNCTION get_birth_date(
+ain_id                         in     number)
+return                                date,
+
+

+Get the specified worker's birth date. +

+
+

get_external_id

+
+STATIC FUNCTION get_external_id
+return                                varchar2,
+
+

+Get the specified worker's external ID. +

+
+

get_formatted_name

+
+STATIC FUNCTION get_formatted_name(
+aiv_first_name                 in     varchar2,
+aiv_middle_name                in     varchar2,
+aiv_last_name                  in     varchar2)
+return                                varchar2,
+
+

+Calculate the locale specific formatted name. +

+
+

get_formatted_name

+
+STATIC FUNCTION get_formatted_name(
+ain_id                         in     number)
+return                                varchar2,
+
+

+Get the specified worker's formatted name. +

+
+

get_id

+
+STATIC FUNCTION get_id
+return                                number,
+
+

+Get the next primary key value for the table. +

+
+

get_id

+
+STATIC FUNCTION get_id(
+aiv_external_id                in     varchar2)
+return                                number,
+
+

+Get the specified worker's internal ID. +

+
+

get_row

+
+STATIC FUNCTION get_row(
+aio_worker                     in     WORKER_O)
+return                                WORKER_O,
+
+

+Get the specified worker's row object. +

+
+

get_unformatted_name

+
+STATIC FUNCTION get_unformatted_name(
+aiv_first_name                 in     varchar2,
+aiv_middle_name                in     varchar2,
+aiv_last_name                  in     varchar2)
+return                                varchar2,
+
+

+Calculate the non-locale specific unformmated name. +

+
+

help,

+
+MEMBER PROCEDURE help,
+
+

+Display the help text for this TYPE. +

+
+

is_duplicate

+
+STATIC FUNCTION is_duplicate(
+aiv_name                       in     varchar2,
+aid_birth_date                 in     varchar2,
+ain_gender_id                  in     varchar2)
+return                                boolean,
+
+

+Check to see if a worker with the same name, birth_date and +gender already exists in the database. +

+
+

set_row

+
+STATIC PROCEDURE set_row(
+aioo_worker                    in out WORKER_O),
+
+

+Set the specified worker's row object. +

+
+

test,

+
+MEMBER PROCEDURE test,
+
+

+Execute the test unit for this TYPE. +

+
+

to_varchar2

+
+MAP MEMBER FUNCTION to_varchar2
+return                                varchar2,
+
+

+The MAP function for this TYPE. +

+
+

worker_o

+
+CONSTRUCTOR FUNCTION worker_o(
+self                           in out worker_o,
+ain_worker_type_id             in     number,
+aiv_first_name                 in     varchar2,
+aiv_middle_name                in     varchar2,
+aiv_last_name                  in     varchar2,
+aid_birth_date                 in     date,
+ain_gender_id                  in     number)
+return                                self as result,
+
+

+A convenience constructor for this TYPE. +

+
+

worker_o

+
+CONSTRUCTOR FUNCTION worker_o(
+self                           in out worker_o)
+return                                self as result
+)
+
+

+A NULL values constructor for this TYPE. +

+
+ + diff --git a/Chapter09/solutions/worker_ts.html b/Chapter09/solutions/worker_ts.html new file mode 100644 index 0000000..15c038b --- /dev/null +++ b/Chapter09/solutions/worker_ts.html @@ -0,0 +1,226 @@ + + +WORKER_TS + + + +

Package WORKER_TS

+

+worker_ts.pks +Copyright by Don Bales on 12/15/2006 +Table WORKER_T's methods. +

+

+ + +
Global Constants and Variables
+
+

+Keep track of the number of inserts and updates +

+n_inserted                            number := 0;
+n_updated                             number := 0;
+
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Method Summary
get_age Calculate age based on the specified birth data and day
get_age Calcualte age based on the specified birth date and today
get_age Returns the age of the specified worker on the specified day
get_age Returns the age of the specified worker as of today
get_birth_date Returns the specified worker's birth date
get_external_id Returns the next available external ID value from its sequence
get_id Returns the next available primar key ID value from its sequence
get_id Returns the primary key ID value for the specified external ID value
get_formatted_name Returns a name properly formatted for the current locale
get_formatted_name Returns a name for the specified worker properly formatted for the current locale
get_row Returns a matching worker row
get_unformatted_name Returns an unformmated name
is_duplicate gender already exists in the database
help Text-based help for this package
set_row Insert or update the specified row into the database
test This package's test units
+


+ + +
Method Detail
+

get_age

+
+FUNCTION get_age(
+aid_birth_date                 in     WORKER_T.birth_date%TYPE,
+aid_on                         in     date)
+return                                number
+
+

+Calculate age based on the specified birth data and day +

+
+

get_age

+
+FUNCTION get_age(
+aid_birth_date                 in     WORKER_T.birth_date%TYPE)
+return                                number
+
+

+Calcualte age based on the specified birth date and today +

+
+

get_age

+
+FUNCTION get_age(
+ain_id                         in     WORKER_T.id%TYPE,
+aid_on                         in     date)
+return                                number
+
+

+Returns the age of the specified worker on the specified day +

+
+

get_age

+
+FUNCTION get_age(
+ain_id                         in     WORKER_T.id%TYPE)
+return                                number
+
+

+Returns the age of the specified worker as of today +

+
+

get_birth_date

+
+FUNCTION get_birth_date(
+ain_id                         in     WORKER_T.id%TYPE)
+return                                WORKER_T.birth_date%TYPE
+
+

+Returns the specified worker's birth date +

+
+

get_external_id

+
+FUNCTION get_external_id
+return                                WORKER_T.external_id%TYPE
+
+

+Returns the next available external ID value from its sequence +

+
+

get_id

+
+FUNCTION get_id
+return                                WORKER_T.id%TYPE
+
+

+Returns the next available primar key ID value from its sequence +

+
+

get_id

+
+FUNCTION get_id(
+aiv_external_id                in     WORKER_T.external_id%TYPE)
+return                                WORKER_T.id%TYPE
+
+

+Returns the primary key ID value for the specified external ID value +

+
+

get_formatted_name

+
+FUNCTION get_formatted_name(
+aiv_first_name                 in     WORKER_T.first_name%TYPE,
+aiv_middle_name                in     WORKER_T.middle_name%TYPE,
+aiv_last_name                  in     WORKER_T.last_name%TYPE)
+return                                WORKER_T.name%TYPE
+
+

+Returns a name properly formatted for the current locale +

+
+

get_formatted_name

+
+FUNCTION get_formatted_name(
+ain_id                         in     WORKER_T.id%TYPE)
+return                                WORKER_T.name%TYPE
+
+

+Returns a name for the specified worker properly formatted for the current locale +

+
+

get_row

+
+FUNCTION get_row(
+air_worker                     in     WORKER_T%ROWTYPE)
+return                                WORKER_T%ROWTYPE
+
+

+Returns a matching worker row +

+
+

get_unformatted_name

+
+FUNCTION get_unformatted_name(
+aiv_first_name                 in     WORKER_T.first_name%TYPE,
+aiv_middle_name                in     WORKER_T.middle_name%TYPE,
+aiv_last_name                  in     WORKER_T.last_name%TYPE)
+return                                WORKER_T.name%TYPE
+
+

+Returns an unformmated name +

+
+

is_duplicate

+
+FUNCTION is_duplicate(
+aiv_name                       in     WORKER_T.name%TYPE,
+aid_birth_date                 in     WORKER_T.birth_date%TYPE,
+ain_gender_id                  in     WORKER_T.gender_id%TYPE)
+return                                boolean
+
+

+gender already exists in the database +

+
+

help

+
+PROCEDURE help
+
+

+Text-based help for this package. "set serveroutput on" in SQL*Plus. +

+
+

set_row

+
+PROCEDURE set_row(
+aior_worker                    in out WORKER_T%ROWTYPE)
+
+

+Insert or update the specified row into the database +

+
+

test

+
+PROCEDURE test
+
+

+This package's test units +

+
+ + diff --git a/Chapter09/solutions/worker_ts.pks b/Chapter09/solutions/worker_ts.pks new file mode 100644 index 0000000..1bb9266 --- /dev/null +++ b/Chapter09/solutions/worker_ts.pks @@ -0,0 +1,99 @@ +create or replace PACKAGE WORKER_TS as +/* +worker_ts.pks +Copyright by Don Bales on 12/15/2006 +Table WORKER_T's methods. +*/ + +-- Keep track of the number of inserts and updates +n_inserted number := 0; +n_updated number := 0; + +-- Calculate age based on the specified birth data and day +FUNCTION get_age( +aid_birth_date in WORKER_T.birth_date%TYPE, +aid_on in date) +return number; + +-- Calcualte age based on the specified birth date and today +FUNCTION get_age( +aid_birth_date in WORKER_T.birth_date%TYPE) +return number; + +-- Returns the age of the specified worker on the specified day +FUNCTION get_age( +ain_id in WORKER_T.id%TYPE, +aid_on in date) +return number; + +-- Returns the age of the specified worker as of today +FUNCTION get_age( +ain_id in WORKER_T.id%TYPE) +return number; + +-- Returns the specified worker's birth date +FUNCTION get_birth_date( +ain_id in WORKER_T.id%TYPE) +return WORKER_T.birth_date%TYPE; + +-- Returns the next available external ID value from its sequence +FUNCTION get_external_id +return WORKER_T.external_id%TYPE; + +-- Returns the next available primar key ID value from its sequence +FUNCTION get_id +return WORKER_T.id%TYPE; + +-- Returns the primary key ID value for the specified external ID value +FUNCTION get_id( +aiv_external_id in WORKER_T.external_id%TYPE) +return WORKER_T.id%TYPE; + +-- Returns a name properly formatted for the current locale +FUNCTION get_formatted_name( +aiv_first_name in WORKER_T.first_name%TYPE, +aiv_middle_name in WORKER_T.middle_name%TYPE, +aiv_last_name in WORKER_T.last_name%TYPE) +return WORKER_T.name%TYPE; + +-- Returns a name for the specified worker properly formatted for the current locale +FUNCTION get_formatted_name( +ain_id in WORKER_T.id%TYPE) +return WORKER_T.name%TYPE; + +-- Returns a matching worker row +FUNCTION get_row( +air_worker in WORKER_T%ROWTYPE) +return WORKER_T%ROWTYPE; + +-- Returns an unformmated name +FUNCTION get_unformatted_name( +aiv_first_name in WORKER_T.first_name%TYPE, +aiv_middle_name in WORKER_T.middle_name%TYPE, +aiv_last_name in WORKER_T.last_name%TYPE) +return WORKER_T.name%TYPE; + +-- Returns TRUE if the specified combination of name, birth_date and +-- gender already exists in the database +FUNCTION is_duplicate( +aiv_name in WORKER_T.name%TYPE, +aid_birth_date in WORKER_T.birth_date%TYPE, +ain_gender_id in WORKER_T.gender_id%TYPE) +return boolean; + + +-- Text-based help for this package. "set serveroutput on" in SQL*Plus. +PROCEDURE help; + +-- Insert or update the specified row into the database +PROCEDURE set_row( +aior_worker in out WORKER_T%ROWTYPE); + +-- This package's test units +PROCEDURE test; + + +end WORKER_TS; +/ +@se.sql WORKER_TS + diff --git a/Chapter09/solutions/worker_type_o.html b/Chapter09/solutions/worker_type_o.html new file mode 100644 index 0000000..5006df0 --- /dev/null +++ b/Chapter09/solutions/worker_type_o.html @@ -0,0 +1,159 @@ + + +WORKER_TYPE_O + + + +

Type WORKER_TYPE_O

+

+worker_type_o.tps +by Don Bales on 12/15/2006 +Type WORKER_TYPE_O's attributes and methods. +

+

+ + +
Attributes
+
+

+worker_type_o.tps +by Don Bales on 12/15/2006 +Type WORKER_TYPE_O's attributes and methods. +

+id                                    number,
+code                                  varchar2(30),
+description                           varchar2(80),
+active_date                           date,
+inactive_date                         date,
+
+

+ + + + + + + + + + + + + + + + + + + + + + +
Method Summary
get_code_descr Gets the code and decription values for the specified work_type_id
get_code_id_descr date specified
get_code_id_descr Verifies the passed aiov_code value is currently an exact or like match
get_id Returns a newly allocated id value
get_id Returns the id for the specified code value
help, Test-based help for this package
test, Test units for this package
to_varchar2 A MAP function for sorting at the object level
worker_type_o with NULL values
worker_type_o for insert
+


+ + +
Method Detail
+

get_code_descr

+
+STATIC PROCEDURE get_code_descr(
+ain_id                         in     number,
+aov_code                          out varchar2,
+aov_description                   out varchar2 ),
+
+

+Gets the code and decription values for the specified work_type_id. +

+
+

get_code_id_descr

+
+STATIC PROCEDURE get_code_id_descr(
+aiov_code                      in out varchar2,
+aon_id                            out number,
+aov_description                   out varchar2,
+aid_on                         in     date ),
+
+

+date specified. +

+
+

get_code_id_descr

+
+STATIC PROCEDURE get_code_id_descr(
+aiov_code                      in out varchar2,
+aon_id                            out number,
+aov_description                   out varchar2 ),
+
+

+Verifies the passed aiov_code value is currently an exact or like match. +

+
+

get_id

+
+MEMBER FUNCTION get_id
+return                                number,
+
+

+Returns a newly allocated id value. +

+
+

get_id

+
+STATIC FUNCTION get_id(
+aiv_code                       in     varchar2 )
+return                                number,
+
+

+Returns the id for the specified code value. +

+
+

help,

+
+STATIC PROCEDURE help,
+
+

+Test-based help for this package. "set serveroutput on" in SQL*Plus. +

+
+

test,

+
+STATIC PROCEDURE test,
+
+

+Test units for this package. +

+
+

to_varchar2

+
+MAP MEMBER FUNCTION to_varchar2
+return                                varchar2,
+
+

+A MAP function for sorting at the object level. +

+
+

worker_type_o

+
+CONSTRUCTOR FUNCTION worker_type_o(
+self                           in out worker_type_o)
+return                                self as result,
+
+

+with NULL values. +

+
+

worker_type_o

+
+CONSTRUCTOR FUNCTION worker_type_o(
+self                           in out worker_type_o,
+aiv_code                       in     varchar2,
+aiv_description                in     varchar2)
+return                                self as result
+)
+
+

+for insert. +

+
+ + diff --git a/Chapter09/solutions/worker_type_ts.html b/Chapter09/solutions/worker_type_ts.html new file mode 100644 index 0000000..c5c73d9 --- /dev/null +++ b/Chapter09/solutions/worker_type_ts.html @@ -0,0 +1,105 @@ + + +WORKER_TYPE_TS + + + +

Package WORKER_TYPE_TS

+

+worker_type_ts.pks +by Don Bales on 12/15/2006 +Code Table WORKER_TYPE_T's methods. +

+

+ + + + + + + + + + + + + + + + +
Method Summary
get_code_descr Gets the code and decription values for the specified work_type_id
get_code_id_descr Verifies the passed aiov_code value is an exact or like match on the date specified
get_code_id_descr Verifies the passed aiov_code value is currently an exact or like match
get_id Returns a newly allocated id value
get_id Returns the id for the specified code value
help Test-based help for this package
test Test units for this package
+


+ + +
Method Detail
+

get_code_descr

+
+PROCEDURE get_code_descr(
+ain_id                         in     WORKER_TYPE_T.id%TYPE,
+aov_code                          out WORKER_TYPE_T.code%TYPE,
+aov_description                   out WORKER_TYPE_T.description%TYPE )
+
+

+Gets the code and decription values for the specified work_type_id. +

+
+

get_code_id_descr

+
+PROCEDURE get_code_id_descr(
+aiov_code                      in out WORKER_TYPE_T.code%TYPE,
+aon_id                            out WORKER_TYPE_T.id%TYPE,
+aov_description                   out WORKER_TYPE_T.description%TYPE,
+aid_on                         in     WORKER_TYPE_T.active_date%TYPE )
+
+

+Verifies the passed aiov_code value is an exact or like match on the date specified. +

+
+

get_code_id_descr

+
+PROCEDURE get_code_id_descr(
+aiov_code                      in out WORKER_TYPE_T.code%TYPE,
+aon_id                            out WORKER_TYPE_T.id%TYPE,
+aov_description                   out WORKER_TYPE_T.description%TYPE )
+
+

+Verifies the passed aiov_code value is currently an exact or like match. +

+
+

get_id

+
+FUNCTION get_id
+return                                WORKER_TYPE_T.id%TYPE
+
+

+Returns a newly allocated id value. +

+
+

get_id

+
+FUNCTION get_id(
+aiv_code                       in     WORKER_TYPE_T.code%TYPE )
+return                                WORKER_TYPE_T.id%TYPE
+
+

+Returns the id for the specified code value. +

+
+

help

+
+PROCEDURE help
+
+

+Test-based help for this package. "set serveroutput on" in SQL*Plus. +

+
+

test

+
+PROCEDURE test
+
+

+Test units for this package. +

+
+ + diff --git a/Chapter09/solutions/worker_type_ts.pks b/Chapter09/solutions/worker_type_ts.pks new file mode 100644 index 0000000..8d3d579 --- /dev/null +++ b/Chapter09/solutions/worker_type_ts.pks @@ -0,0 +1,61 @@ +create or replace PACKAGE WORKER_TYPE_TS as +/* +worker_type_ts.pks +by Don Bales on 12/15/2006 +Code Table WORKER_TYPE_T's methods. +*/ + + +-- Gets the code and decription values for the specified work_type_id. + +PROCEDURE get_code_descr( +ain_id in WORKER_TYPE_T.id%TYPE, +aov_code out WORKER_TYPE_T.code%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE ); + + +-- Verifies the passed aiov_code value is an exact or like match on the date specified. + +PROCEDURE get_code_id_descr( +aiov_code in out WORKER_TYPE_T.code%TYPE, +aon_id out WORKER_TYPE_T.id%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE, +aid_on in WORKER_TYPE_T.active_date%TYPE ); + + +-- Verifies the passed aiov_code value is currently an exact or like match. + +PROCEDURE get_code_id_descr( +aiov_code in out WORKER_TYPE_T.code%TYPE, +aon_id out WORKER_TYPE_T.id%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE ); + + +-- Returns a newly allocated id value. + +FUNCTION get_id +return WORKER_TYPE_T.id%TYPE; + + +-- Returns the id for the specified code value. + +FUNCTION get_id( +aiv_code in WORKER_TYPE_T.code%TYPE ) +return WORKER_TYPE_T.id%TYPE; + + + +-- Test-based help for this package. "set serveroutput on" in SQL*Plus. + +PROCEDURE help; + + +-- Test units for this package. + +PROCEDURE test; + + +end WORKER_TYPE_TS; +/ +@se.sql WORKER_TYPE_TS + diff --git a/Chapter09/solutions/workplace_type_ts.html b/Chapter09/solutions/workplace_type_ts.html new file mode 100644 index 0000000..9abb2e5 --- /dev/null +++ b/Chapter09/solutions/workplace_type_ts.html @@ -0,0 +1,105 @@ + + +WORKPLACE_TYPE_TS + + + +

Package WORKPLACE_TYPE_TS

+

+workplace_type_ts.pks +by Don Bales on 12/15/2006 +Table WORKPLACE_TYPE_T's methods. +

+

+ + + + + + + + + + + + + + + + +
Method Summary
get_code_descrGets the code and decription values for the specified id
get_code_id_descrVerifies that the passed code value is an exact or like match on the date specified
get_code_id_descrVerifies that the passed code value is currently an exact or like match
get_idReturns a new primary key id value for a row
get_idReturns the id for the specified code value
helpTest-based help for this package
testTest units for this package
+


+ + +
Method Detail
+

get_code_descr

+
+PROCEDURE get_code_descr(
+ain_id                         in     WORKPLACE_TYPE_T.id%TYPE,
+aov_code                          out WORKPLACE_TYPE_T.code%TYPE,
+aov_description                   out WORKPLACE_TYPE_T.description%TYPE)
+
+

+Gets the code and decription values for the specified id. +

+
+

get_code_id_descr

+
+PROCEDURE get_code_id_descr(
+aiov_code                      in out WORKPLACE_TYPE_T.code%TYPE,
+aon_id                            out WORKPLACE_TYPE_T.id%TYPE,
+aov_description                   out WORKPLACE_TYPE_T.description%TYPE,
+aid_on                         in     WORKPLACE_TYPE_T.active_date%TYPE)
+
+

+Verifies that the passed code value is an exact or like match on the date specified. +

+
+

get_code_id_descr

+
+PROCEDURE get_code_id_descr(
+aiov_code                      in out WORKPLACE_TYPE_T.code%TYPE,
+aon_id                            out WORKPLACE_TYPE_T.id%TYPE,
+aov_description                   out WORKPLACE_TYPE_T.description%TYPE)
+
+

+Verifies that the passed code value is currently an exact or like match. +

+
+

get_id

+
+FUNCTION get_id
+return                                WORKPLACE_TYPE_T.id%TYPE
+
+

+Returns a new primary key id value for a row. +

+
+

get_id

+
+FUNCTION get_id(
+aiv_code                       in     WORKPLACE_TYPE_T.code%TYPE)
+return                                WORKPLACE_TYPE_T.id%TYPE
+
+

+Returns the id for the specified code value. +

+
+

help

+
+PROCEDURE help
+
+

+Test-based help for this package. "set serveroutput on" in SQL*Plus. +

+
+

test

+
+PROCEDURE test
+
+

+Test units for this package. +

+
+ + diff --git a/Chapter09/solutions/workplace_type_ts.pks b/Chapter09/solutions/workplace_type_ts.pks new file mode 100644 index 0000000..be0c093 --- /dev/null +++ b/Chapter09/solutions/workplace_type_ts.pks @@ -0,0 +1,59 @@ +create or replace PACKAGE WORKPLACE_TYPE_TS as +/* +workplace_type_ts.pks +by Don Bales on 12/15/2006 +Table WORKPLACE_TYPE_T's methods. +*/ + +/* +Gets the code and decription values for the specified id. +*/ +PROCEDURE get_code_descr( +ain_id in WORKPLACE_TYPE_T.id%TYPE, +aov_code out WORKPLACE_TYPE_T.code%TYPE, +aov_description out WORKPLACE_TYPE_T.description%TYPE); + +/* +Verifies that the passed code value is an exact or like match on the date specified. +*/ +PROCEDURE get_code_id_descr( +aiov_code in out WORKPLACE_TYPE_T.code%TYPE, +aon_id out WORKPLACE_TYPE_T.id%TYPE, +aov_description out WORKPLACE_TYPE_T.description%TYPE, +aid_on in WORKPLACE_TYPE_T.active_date%TYPE); + +/* +Verifies that the passed code value is currently an exact or like match. +*/ +PROCEDURE get_code_id_descr( +aiov_code in out WORKPLACE_TYPE_T.code%TYPE, +aon_id out WORKPLACE_TYPE_T.id%TYPE, +aov_description out WORKPLACE_TYPE_T.description%TYPE); + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return WORKPLACE_TYPE_T.id%TYPE; + +/* +Returns the id for the specified code value. +*/ +FUNCTION get_id( +aiv_code in WORKPLACE_TYPE_T.code%TYPE) +return WORKPLACE_TYPE_T.id%TYPE; + +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + +/* +Test units for this package. +*/ +PROCEDURE test; + + +end WORKPLACE_TYPE_TS; +/ +@se.sql WORKPLACE_TYPE_TS diff --git a/Chapter09/stylesheet.css b/Chapter09/stylesheet.css new file mode 100644 index 0000000..cc1fa1e --- /dev/null +++ b/Chapter09/stylesheet.css @@ -0,0 +1,17 @@ +h2 { font-size: 140% } +h3 { font-size: 120% } + +table { border-collapse: collapse; border-color: gray; border-style: solid; border-width: 1; background-color: white; text-align: left; width: 100% } +th { border-color: gray; border-style: solid; border-width: 1; background-color: lightgrey; padding: 3; font-size: 125% } +td { border-color: gray; border-style: solid; border-width: 1; background-color: white; padding: 3; font-size: 100% } + +.method_name_td { width: 20% } +.method_name_span { font-size: 80%; font-family: Monospace, New Courier; } +.method_pre { font-size: 80%; font-family: Monospace, New Courier; } +.package_name_td { width: 20% } +.package_name_span { font-size: 80%; font-family: Monospace, New Courier; } +.first_sentence_td { } +.first_sentence_span { font-size: 80%; font-family: Helvetica, Arial, sans-serif; } +.comments_td { } +.comments_span { font-size: 80%; font-family: Helvetica, Arial, sans-serif; } +.comments_p { font-size: 80%; font-family: Helvetica, Arial, sans-serif; } diff --git a/Chapter09/text_help.pkb b/Chapter09/text_help.pkb new file mode 100644 index 0000000..e3158c6 --- /dev/null +++ b/Chapter09/text_help.pkb @@ -0,0 +1,149 @@ +create or replace PACKAGE BODY TEXT_HELP as +/* +test_help.pkb +by Donald J. Bales on 12/15/2006 +A package to produce text based help +*/ + +PROCEDURE help is + +begin + TEXT_HELP.process('TEXT_HELP'); +end help; + + +/* +A procedure to output formatted package or TYPE text +*/ +PROCEDURE out( +aiv_text in varchar2) is + +v_text varchar(255); +n_text number := 1; + +begin + if nvl(length(aiv_text), 0) < 256 then + v_text := aiv_text; + else + v_text := substr(aiv_text, 1, 252)||'...'; + end if; + if nvl(substr(v_text, 1, 1), chr(32)) = chr(32) then + if length(v_text) > 0 then + for i in 1..length(v_text) loop + if nvl(substr(v_text, i, 1), chr(32)) <> chr(32) then + n_text := i; + exit; + end if; + end loop; + end if; + SYS.DBMS_OUTPUT.put_line(chr(9)||substr(v_text, n_text)); + else + SYS.DBMS_OUTPUT.put_line(v_text); + end if; +end out; + + +PROCEDURE process( +aiv_object_name in varchar2) is + +cursor c1( +aiv_object_name in varchar2) is +select text +from SYS.USER_SOURCE +where name = upper(aiv_object_name) +and type in ('PACKAGE', 'TYPE') +order by line; + +b_method boolean := FALSE; +b_comment boolean := FALSE; +v_text SYS.USER_SOURCE.text%TYPE; + +begin + for r1 in c1(aiv_object_name) loop + v_text := replace(replace(r1.text, chr(13), NULL), chr(10), NULL); + if substr(ltrim(v_text), 1, 3) = '/* ' then + if nvl(instr(v_text, '*/'), 0) = 0 then + b_comment := TRUE; + end if; + out(substr(ltrim(v_text), 4)); + elsif substr(ltrim(v_text), 1, 2) = '/*' then + if nvl(instr(v_text, '*/'), 0) = 0 then + b_comment := TRUE; + end if; + out(substr(ltrim(v_text), 3)); + elsif b_comment and + substr(rtrim(v_text), -2, 2) = '*/' then + b_comment := FALSE; + out(substr(rtrim(v_text), 1, length(rtrim(v_text)) - 2)); + elsif b_comment then + out(v_text); + elsif substr(ltrim(v_text), 1, 3) = '-- ' then + out(substr(ltrim(v_text), 4)); + elsif substr(ltrim(v_text), 1, 2) = '--' then + out(substr(ltrim(v_text), 3)); + elsif upper(substr(ltrim(v_text), 1, 8)) = 'FUNCTION' or + upper(substr(ltrim(v_text), 1, 9)) = 'PROCEDURE' or + upper(substr(ltrim(v_text), 1, 15)) = 'MEMBER FUNCTION' or + upper(substr(ltrim(v_text), 1, 16)) = 'MEMBER PROCEDURE' or + upper(substr(ltrim(v_text), 1, 16)) = 'STATIC FUNCTION' or + upper(substr(ltrim(v_text), 1, 16)) = 'STATIC PROCEDURE' then + if nvl(instr(v_text, ';'), 0) = 0 then + b_method := TRUE; + end if; + out(v_text); + elsif b_method and + substr(rtrim(v_text), -1, 1) = ';' then + b_method := FALSE; + out(v_text); + elsif b_method then + out(v_text); + elsif c1%rowcount = 1 then + out(v_text); + elsif upper(substr(ltrim(v_text), 1, 3)) = 'END' then + out(chr(12)); -- form feed + exit; + else + out(v_text); + end if; + end loop; + SYS.DBMS_OUTPUT.new_line(); +end process; + + +PROCEDURE test is + +begin + pl('TEXT_HELP.test()'); + + TEST_TS.clear('TEXT_HELP'); + + TEST_TS.set_test('TEXT_HELP', 'help()', 1, + 'Test method help()' ); + begin + help(); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('TEXT_HELP', 'process()', 2, + 'Test method help()' ); + begin + process('TEXT_HELP'); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('TEXT_HELP', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end text_help; +/ +@be.sql diff --git a/Chapter09/text_help.pks b/Chapter09/text_help.pks new file mode 100644 index 0000000..65d3e5b --- /dev/null +++ b/Chapter09/text_help.pks @@ -0,0 +1,29 @@ +create or replace PACKAGE TEXT_HELP as +/* +test_help.pkb +by Donald J. Bales on 12/15/2006 +A package to produce text based help +*/ + +/* +The help text for this package. +*/ +PROCEDURE help; + + +/* +Generate help text for the specified object using its specification. +*/ +PROCEDURE process( +aiv_object_name in varchar2); + + +/* +The test unit for this package. +*/ +PROCEDURE test; + + +end text_help; +/ +@se.sql diff --git a/Chapter10/README.txt b/Chapter10/README.txt new file mode 100644 index 0000000..c9b0335 --- /dev/null +++ b/Chapter10/README.txt @@ -0,0 +1,155 @@ +README.txt for Chapter 10 +by Donald J. Bales on 4/15/2007 + +OBJECT NAME DESCRIPTION +--------------------------------------- ------------------------------------- +be.sql + +ci.sql + +code_table_text.tab + +desc.sql + +email_log.tab + +email_logs.pkb + +email_logs.pks + +emails.pkb + +emails.pks + +fe.sql + +incr.fun + +interface_status.tab + +interface_statuss,pkb.txt + +interface_statuss.pkb + +jdbc_example.txt + +last_test_results.sql + +last_test_results.txt + +logical_assignment_t.ins + +logical_assignment_ts.pkb + +logical_workplace_t.ins + +logical_workplace_ts.pkb + +logical_workplace_ts.pks + +login.sql + +on_demand_process.pkb + +on_demand_process.pks + +on_demand_process_log.tab + +on_demand_process_logs.pkb + +on_demand_process_logs.pks + +pe.sql + +physical_assignment_t.ins + +physical_assignment_ts.pkb + +physical_assignment_ts.pks + +physical_workplace_t.ins + +physical_workplace_ts.pkb + +physical_workplace_ts.pks + +pl.prc + +polling_process.pkb + +polling_process.pks + +polling_process.sql + +polling_process_queue.tab + +polling_process_queues.pkb + +polling_process_queues.pks + +polling_process_status.tab + +polling_process_statuss.pkb + +polling_process_statuss.pks + +report_staging_table_log.tab + +report_staging_table_logs.pkb + +report_staging_table_logs.pks + +report_staging_tables.pkb + +report_staging_tables.pks + +report_wkhst.tab + +report_wkhsts.get_report.sql + +report_wkhsts.pkb + +report_wkhsts.pks + +report_wkhsts.report.sql + +se.sql + +seed.sql + +to_boolean_number.fun + +top_100_names.pkb + +top_100_names.pks + +utl_smtp_example.sql + +weekly_interface.pkb + +weekly_interface.pks + +weekly_interface_status.tab + +weekly_interface_statuss.pkb + +weekly_interface_statuss.pks + +work_assignment_t.ins + +work_assignment_ts.pkb + +work_assignment_ts.pks + +work_t.ins + +work_ts.pkb + +work_ts.pks + +worker_ts.pkb + +worker_type_t.tab + +worker_type_ts.pkb + diff --git a/Chapter10/be.sql b/Chapter10/be.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter10/be.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter10/ci.sql b/Chapter10/ci.sql new file mode 100644 index 0000000..6dcc7e7 --- /dev/null +++ b/Chapter10/ci.sql @@ -0,0 +1,50 @@ +rem ci.sql +rem by Donald J. Bales on 12/15/2006 +rem Compile my invalid objects + +set feedback off; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +set serveroutput on size 1000000; + +spool ci.txt; +declare + +cursor c1 is +select object_type, + object_name +from SYS.USER_OBJECTS +where status = 'INVALID' +order by 1, 2; + +v_sql varchar2(100); + +begin + for r1 in c1 loop + begin + if r1.object_type = 'PACKAGE BODY' then + v_sql := 'alter PACKAGE '||r1.object_name||' compile BODY'; + elsif r1.object_type = 'TYPE BODY' then + v_sql := 'alter TYPE '||r1.object_name||' compile BODY'; + else + v_sql := 'alter '||r1.object_type||' '||r1.object_name||' compile'; + end if; + execute immediate v_sql; + pl(r1.object_type||' '||r1.object_name||' compiled successfully'); + exception + when OTHERS then + pl(SQLERRM||' on '||v_sql); + end; + end loop; +end; +/ + +spool off; + +set feedback on; + + + + \ No newline at end of file diff --git a/Chapter10/ci.txt b/Chapter10/ci.txt new file mode 100644 index 0000000..e69de29 diff --git a/Chapter10/compile_all.sql b/Chapter10/compile_all.sql new file mode 100644 index 0000000..12f8bc9 --- /dev/null +++ b/Chapter10/compile_all.sql @@ -0,0 +1,70 @@ +set echo on; +set linesize 1000; +set newpage 1; +set pagesize 32767; +set trimspool on; +spool compile_all.txt; +@pl.prc +@incr.fun +@to_boolean_number.fun +@email_log.tab +@interface_status.tab +@on_demand_process_log.tab +@polling_process_queue.tab +@polling_process_status.tab +@report_staging_table_log.tab +@report_wkhst.tab +@weekly_interface_status.tab +@worker_type_t.tab +@email_logs.pks +@emails.pks +@interface_statuss.pks +@logical_assignment_ts.pks +@logical_workplace_ts.pks +@on_demand_process.pks +@on_demand_process_logs.pks +@physical_assignment_ts.pks +@physical_workplace_ts.pks +@polling_process.pks +@polling_process_queues.pks +@polling_process_statuss.pks +@report_staging_table_logs.pks +@report_staging_tables.pks +@report_wkhsts.pks +@top_100_names.pks +@weekly_interface.pks +@weekly_interface_statuss.pks +@work_assignment_ts.pks +@work_ts.pks +@email_logs.pkb +@emails.pkb +@interface_statuss.pkb +@logical_assignment_ts.pkb +@logical_workplace_ts.pkb +@on_demand_process.pkb +@on_demand_process_logs.pkb +@physical_assignment_ts.pkb +@physical_workplace_ts.pkb +@polling_process.pkb +@polling_process_queues.pkb +@polling_process_statuss.pkb +@report_staging_table_logs.pkb +@report_staging_tables.pkb +@report_wkhsts.pkb +@top_100_names.pkb +@weekly_interface.pkb +@weekly_interface_statuss.pkb +@work_assignment_ts.pkb +@work_ts.pkb +@worker_ts.pkb +@worker_type_ts.pkb +@logical_workplace_t.ins +@logical_assignment_t.ins +@physical_workplace_t.ins +@physical_assignment_t.ins +@work_t.ins +@work_assignment_t.ins +spool off; +set echo off; +@ci.sql +@ci.sql diff --git a/Chapter10/desc.sql b/Chapter10/desc.sql new file mode 100644 index 0000000..45206dc --- /dev/null +++ b/Chapter10/desc.sql @@ -0,0 +1,6 @@ +define table_name="&1"; +set linesize 78; +prompt &table_name +desc &table_name +set linesize 1000; +undefine table_name \ No newline at end of file diff --git a/Chapter10/email_log.tab b/Chapter10/email_log.tab new file mode 100644 index 0000000..0b1f0e1 --- /dev/null +++ b/Chapter10/email_log.tab @@ -0,0 +1,29 @@ +rem email_log.tab +rem by Donald Bales on 12/15/2006 +rem Create an email log table + +execute drop_if_exists('TABLE', 'EMAIL_LOG'); +create table EMAIL_LOG ( +id number not null, +text varchar2(256), +unique_session_id varchar2(24) not null, +insert_user varchar2(30) default USER not null, +insert_date date default SYSDATE not null ) +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +alter table EMAIL_LOG add +constraint EMAIL_LOG_PK +primary key ( +id ) +using index +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +execute drop_if_exists('SEQUENCE', 'EMAIL_LOG_ID_SEQ'); +create sequence EMAIL_LOG_ID_SEQ +start with 1 order; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'EMAIL_LOG'); + +grant all on EMAIL_LOG to PUBLIC; diff --git a/Chapter10/email_logs.pkb b/Chapter10/email_logs.pkb new file mode 100644 index 0000000..c5b6dcc --- /dev/null +++ b/Chapter10/email_logs.pkb @@ -0,0 +1,42 @@ +create or replace package body EMAIL_LOGS as +/* +email_logs.pkb +by Donald J. Bales on 12/15/2006 +Table EMAIL_LOG's package +*/ + +FUNCTION get_id +return EMAIL_LOG.id%TYPE is + +n_id EMAIL_LOG.id%TYPE; + +begin + select EMAIL_LOG_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +PROCEDURE set_text( +aiv_text in EMAIL_LOG.text%TYPE) is + +pragma autonomous_transaction; + +begin + insert into EMAIL_LOG ( + id, + text, + unique_session_id ) + values ( + EMAIL_LOGS.get_id(), + aiv_text, + SYS.DBMS_SESSION.unique_session_id); + commit; +end set_text; + + +end EMAIL_LOGS; +/ +@be.sql EMAIL_LOGS; diff --git a/Chapter10/email_logs.pks b/Chapter10/email_logs.pks new file mode 100644 index 0000000..8fe9823 --- /dev/null +++ b/Chapter10/email_logs.pks @@ -0,0 +1,18 @@ +create or replace package EMAIL_LOGS as +/* +email_logs.pks +by Donald J. Bales on 12/15/2006 +Table EMAIL_LOG's package +*/ + +FUNCTION get_id +return EMAIL_LOG.id%TYPE; + + +PROCEDURE set_text( +aiv_text in EMAIL_LOG.text%TYPE); + + +end EMAIL_LOGS; +/ +@se.sql EMAIL_LOGS; diff --git a/Chapter10/emails.pkb b/Chapter10/emails.pkb new file mode 100644 index 0000000..9f3b214 --- /dev/null +++ b/Chapter10/emails.pkb @@ -0,0 +1,231 @@ +create or replace package body EMAILS as +/* +emails.pkb +by Donald J. Bales on 12/15/2006 +Package to send emails +*/ + +v_host varchar2(30) := 'smtp.sbcglobal.yahoo.com'; +v_domain varchar2(30) := 'sbcglobal.net'; +v_username varchar2(30) := ''; +v_password varchar2(30) := '
'||UTL_TCP.crlf);
+  for i in ait_lines.first..ait_lines.last loop
+    UTL_SMTP.WRITE_DATA(r_connection, ait_lines(i)||UTL_TCP.crlf);  
+  end loop;
+  t_log(incr(n_log)) := '...
'; + UTL_SMTP.WRITE_DATA(r_connection, ''||UTL_TCP.crlf); + + t_log(incr(n_log)) := 'close_data'; + r_reply := UTL_SMTP.CLOSE_DATA(r_connection); + t_log(incr(n_log)) := 'reply: '||r_reply.code||', '||r_reply.text; + n_close_data := r_reply.code; + v_close_data := r_reply.text; + + t_log(incr(n_log)) := 'quit'; + r_reply := UTL_SMTP.QUIT(r_connection); + t_log(incr(n_log)) := 'reply: '||r_reply.code||', '||r_reply.text; + + if n_close_data <> 250 then + for i in t_log.first..t_log.last loop + EMAIL_LOGS.set_text(t_log(i)); + end loop; + raise_application_error(-20000, 'Email not sent: '|| + to_char(n_close_data)||', '||v_close_data||' in EMAILS.send()'); + end if; +exception + when UTL_SMTP.TRANSIENT_ERROR then + v_sqlerrm := SQLERRM; + for i in t_log.first..t_log.last loop + EMAIL_LOGS.set_text(t_log(i)); + end loop; + EMAIL_LOGS.set_text(v_sqlerrm); + begin + UTL_SMTP.quit(r_connection); + exception + when OTHERS then + null; + end; + raise_application_error(-20001, v_sqlerrm||' in EMAILS.send()'); + when UTL_SMTP.PERMANENT_ERROR then + v_sqlerrm := SQLERRM; + for i in t_log.first..t_log.last loop + EMAIL_LOGS.set_text(t_log(i)); + end loop; + EMAIL_LOGS.set_text(v_sqlerrm); + begin + UTL_SMTP.quit(r_connection); + exception + when OTHERS then + null; + end; + raise_application_error(-20002, v_sqlerrm||' in EMAILS.send()'); +end send; + + +PROCEDURE set_domain( +aiv_domain in varchar2) is + +begin + v_domain := aiv_domain; +end set_domain; + + +PROCEDURE set_host( +aiv_host in varchar2) is + +begin + v_host := aiv_host; +end set_host; + + +PROCEDURE set_password( +aiv_password in varchar2) is + +begin + v_password := aiv_password; +end set_password; + + +PROCEDURE set_username( +aiv_username in varchar2) is + +begin + v_username := aiv_username; +end set_username; + + +PROCEDURE test is + +t_lines LINES; +n_line number := 0; + +begin + t_lines(incr(n_line)) := ''; + t_lines(incr(n_line)) := '

EMAILS.test()

'; + t_lines(incr(n_line)) := 'Did you get this test message sent at '|| + to_char(SYSDATE, 'HH:MI:SS')||' on '|| + rtrim(to_char(SYSDATE, 'Day'))||', '|| + rtrim(to_char(SYSDATE, 'Month'))||' '|| + to_char(SYSDATE, 'DD, YYYY')||'?'; + t_lines(incr(n_line)) := '
';
+  send(
+    '',
+    '',
+    'EMAILS.test()',
+    t_lines);
+end test;    
+
+
+end EMAILS;
+/
+@be.sql EMAILS
diff --git a/Chapter10/emails.pks b/Chapter10/emails.pks
new file mode 100644
index 0000000..c92ba98
--- /dev/null
+++ b/Chapter10/emails.pks
@@ -0,0 +1,52 @@
+create or replace package EMAILS as
+/*
+emails.pks
+by Donald J. Bales on 12/15/2006
+Package to send emails
+*/
+
+
+TYPE LINES is table of varchar2(2000) index by binary_integer;
+
+
+FUNCTION get_domain
+return                                varchar2;
+
+
+FUNCTION get_host
+return                                varchar2;
+
+
+FUNCTION get_username
+return                                varchar2;
+
+
+PROCEDURE send(
+aiv_from                       in     varchar2,
+aiv_to                         in     varchar2,
+aiv_subject                    in     varchar2,
+ait_lines                      in     LINES);
+
+
+PROCEDURE set_domain(
+aiv_domain                     in     varchar2);
+
+
+PROCEDURE set_host(
+aiv_host                       in     varchar2);
+
+
+PROCEDURE set_password(
+aiv_password                   in     varchar2);
+
+
+PROCEDURE set_username(
+aiv_username                   in     varchar2);
+
+
+PROCEDURE test;
+
+
+end EMAILS;
+/
+@be.sql EMAILS
diff --git a/Chapter10/fe.sql b/Chapter10/fe.sql
new file mode 100644
index 0000000..40be076
--- /dev/null
+++ b/Chapter10/fe.sql
@@ -0,0 +1 @@
+show errors
diff --git a/Chapter10/incr.fun b/Chapter10/incr.fun
new file mode 100644
index 0000000..5e2388d
--- /dev/null
+++ b/Chapter10/incr.fun
@@ -0,0 +1,15 @@
+create or replace function INCR(
+ain_number                     in out number)
+return                                number is
+/*
+incr.fun
+by Donald J. Bales on 12/15/2006
+A function that increments a numeric variable
+*/
+
+begin
+  ain_number := nvl(ain_number, 0) + 1;
+  return ain_number;
+end INCR;
+/
+@fe.sql INCR
diff --git a/Chapter10/interface_status.tab b/Chapter10/interface_status.tab
new file mode 100644
index 0000000..e65b985
--- /dev/null
+++ b/Chapter10/interface_status.tab
@@ -0,0 +1,27 @@
+rem interface_status.tab
+rem by Donald J. Bales on 12/15/2006
+rem A Table to hold the multi-part status for a multi-part process
+
+execute drop_if_exists('TABLE', 'INTERFACE_STATUS');
+create table INTERFACE_STATUS (
+id                             number                         not null,
+download_date                  date,
+upload_date                    date,
+insert_user                    varchar2(30)  default USER     not null,
+insert_date                    date          default SYSDATE  not null,
+update_user                    varchar2(30)  default USER     not null,
+update_date                    date          default SYSDATE  not null)
+tablespace USERS pctfree 20
+storage (initial 1M next 1M pctincrease 0);
+
+alter  table INTERFACE_STATUS add
+constraint   INTERFACE_STATUS_PK
+primary key (
+id )
+using index
+tablespace USERS pctfree 20
+storage (initial 1M next 1M pctincrease 0);
+
+-- A method will be used to calculate the primary key value
+
+execute SYS.DBMS_STATS.gather_table_stats(USER, 'INTERFACE_STATUS');
diff --git a/Chapter10/interface_statuss.pkb b/Chapter10/interface_statuss.pkb
new file mode 100644
index 0000000..264ec83
--- /dev/null
+++ b/Chapter10/interface_statuss.pkb
@@ -0,0 +1,121 @@
+create or replace package body INTERFACE_STATUSS as
+/*
+interface_statuss.pkb
+by Donald J. Bales on 12/15/2006
+Table INTERFACE_STATUS' routines
+*/
+
+
+-- This function will be used for the primary key instead of get_id
+
+FUNCTION get_week
+return                                number is
+
+begin
+  return to_char(SYSDATE, 'YYYYWW');
+end get_week;
+
+
+FUNCTION is_downloaded
+return                                boolean is
+
+pragma autonomous_transaction;
+
+d_download_date                       INTERFACE_STATUS.download_date%TYPE;
+
+begin
+  begin
+    select download_date
+    into   d_download_date
+    from   INTERFACE_STATUS
+    where  id = INTERFACE_STATUSS.get_week;
+  exception
+    when NO_DATA_FOUND then
+      d_download_date := NULL;
+  end;
+  
+  if d_download_date is not NULL then
+    return TRUE;
+  else
+    return FALSE;
+  end if;
+end is_downloaded;
+
+
+FUNCTION is_uploaded 
+return                                boolean is
+
+pragma autonomous_transaction;
+
+d_upload_date                         INTERFACE_STATUS.upload_date%TYPE;
+
+begin
+  begin
+    select upload_date
+    into   d_upload_date
+    from   INTERFACE_STATUS
+    where  id = INTERFACE_STATUSS.get_week;
+  exception
+    when NO_DATA_FOUND then
+      d_upload_date := NULL;
+  end;
+  
+  if d_upload_date is not NULL then
+    return TRUE;
+  else
+    return FALSE;
+  end if;
+end is_uploaded;
+
+
+PROCEDURE set_downloaded is
+
+pragma autonomous_transaction;
+
+begin
+  update INTERFACE_STATUS
+  set    download_date       = SYSDATE,
+         update_user         = USER,
+         update_date         = SYSDATE
+  where  id = INTERFACE_STATUSS.get_week;
+
+  if nvl(sql%rowcount, 0) = 0 then
+    insert into INTERFACE_STATUS (
+           id,
+           download_date )
+    values (
+           INTERFACE_STATUSS.get_week,
+           SYSDATE );
+  end if;
+  
+  commit;
+end set_downloaded;
+
+
+PROCEDURE set_uploaded is
+
+pragma autonomous_transaction;
+
+begin
+  update INTERFACE_STATUS
+  set    upload_date         = SYSDATE,
+         update_user         = USER,
+         update_date         = SYSDATE
+  where  id = INTERFACE_STATUSS.get_week;
+
+  if nvl(sql%rowcount, 0) = 0 then
+    insert into INTERFACE_STATUS (
+           id,
+           upload_date )
+    values (
+           INTERFACE_STATUSS.get_week,
+           SYSDATE );
+  end if;
+  
+  commit;
+end set_uploaded;
+
+
+end INTERFACE_STATUSS;
+/
+@be.sql INTERFACE_STATUSS
diff --git a/Chapter10/interface_statuss.pks b/Chapter10/interface_statuss.pks
new file mode 100644
index 0000000..d3abb9c
--- /dev/null
+++ b/Chapter10/interface_statuss.pks
@@ -0,0 +1,30 @@
+create or replace package INTERFACE_STATUSS as
+/*
+interface_statuss.pks
+by Donald J. Bales on 12/15/2006
+Table INTERFACE_STATUS' routines
+*/
+
+
+-- This function will be used for the primary key instead of get_id
+FUNCTION get_week
+return                                number;
+
+-- Return true if the interface has already downloaded
+FUNCTION is_downloaded
+return                                boolean;
+
+-- Return true if the interface has already uploaded
+FUNCTION is_uploaded
+return                                boolean;
+
+-- Set the status to downloaded
+PROCEDURE set_downloaded;
+
+-- Set the status to uploaded
+PROCEDURE set_uploaded;
+
+
+end INTERFACE_STATUSS;
+/
+@se.sql INTERFACE_STATUSS
diff --git a/Chapter10/jdbc_example.txt b/Chapter10/jdbc_example.txt
new file mode 100644
index 0000000..a50ff16
--- /dev/null
+++ b/Chapter10/jdbc_example.txt
@@ -0,0 +1,30 @@
+...
+int               duplicate = 0;
+CallableStatement cstmt     = null;
+
+try {
+  // Create the callable statement
+  cstmt = conn.prepareCall(
+    "{ ? = call to_boolean_number(is_duplicate(?, ?, ?)) }");
+    
+  // Register the OUT parameter
+  cstmt.registerOutParameter(1, Types.INTEGER);
+  
+  // Set the IN parameters
+  cstmt.setString(2, code);
+  cstmt.setString(3, name);  
+  cstmt.setTimestamp(4, activeDate);
+  
+  // Execute the stored procedure
+  cstmt.execute();
+  
+  duplicate = cstmt.getInt(1);
+}
+catch (SQLException e) {
+  System.err.println("SQL Error: " + e.getMessage());
+}
+finally {
+  if (cstmt != null)
+    try {  cstmt.close(); } catch (SQLException ignore) { }
+}
+...
diff --git a/Chapter10/last_test_results.sql b/Chapter10/last_test_results.sql
new file mode 100644
index 0000000..99051a3
--- /dev/null
+++ b/Chapter10/last_test_results.sql
@@ -0,0 +1,35 @@
+rem last_test_results.sql
+rem by Donald J. Bales on 12/15/2006
+rem Display the last test results
+
+set linesize 1000;
+set newpage  1;
+set pagesize 32767;
+set trimspool on;
+
+column test         format a34;
+column t#           format 99;
+column description  format a27;
+column result       format a7;
+
+spool last_test_results.txt;
+
+select object_name||
+       decode(substr(method_name, -1, 1), ')', '.', ' ')||
+       method_name test,
+       test_number t#,
+       description,
+       result
+from   TEST_T
+where  unique_session_id = SYS.DBMS_SESSION.unique_session_id
+and    object_name       = (
+select object_name
+from   TEST_T
+where  unique_session_id = SYS.DBMS_SESSION.unique_session_id
+and    test_id           = (
+select max(test_id)
+from   TEST_T
+where  unique_session_id = SYS.DBMS_SESSION.unique_session_id))
+order by test_id;
+
+spool off;
diff --git a/Chapter10/last_test_results.txt b/Chapter10/last_test_results.txt
new file mode 100644
index 0000000..8164331
--- /dev/null
+++ b/Chapter10/last_test_results.txt
@@ -0,0 +1,65 @@
+
+TEST                                T# DESCRIPTION                 RESULT
+---------------------------------- --- --------------------------- -------
+WORK_ASSIGNMENT_TS DELETE            0 Delete existing test entrie OK
+                                       s from WORK_ASSIGNMENT_T
+
+WORK_ASSIGNMENT_TS DELETE            1 Delete existing test entrie OK
+                                       s from WORK_T
+
+WORK_ASSIGNMENT_TS DELETE            2 Delete existing test entrie OK
+                                       s from WORKER_T
+
+WORK_ASSIGNMENT_TS INSERT            3 Insert WORKER_T test entrie OK
+                                       s using set_row()
+
+WORK_ASSIGNMENT_TS INSERT            4 Insert WORK_T test entries  OK
+                                       using set_row()
+
+WORK_ASSIGNMENT_TS.GET_ID()          5 Allocate the next primary k OK
+                                       ey value using get_id()
+
+WORK_ASSIGNMENT_TS.SET_ROW()         6 Insert history for v_TEST_3 OK
+                                       0 using set_row()
+
+WORK_ASSIGNMENT_TS.SET_ROW()         7 Insert history for V_TEST_3 OK
+                                       0_1 using set_row()
+
+WORK_ASSIGNMENT_TS.SET_ROW()         8 Insert history for V_TEST_3 OK
+                                       0_2 using set_row()
+
+WORK_ASSIGNMENT_TS.GET_WORK()        9 Get the current work workpl OK
+                                       ace for v_TEST_30
+
+WORK_ASSIGNMENT_TS.GET_WORK()       10 Get the work workplace on 6 OK
+                                       /30/1995 for v_TEST_30_1
+
+WORK_ASSIGNMENT_TS.GET_WORK()       11 Get the work workplace on 6 OK
+                                       /30/1995 for v_TEST_30_2
+
+WORK_ASSIGNMENT_TS.HELP()           12 Test help()                 OK
+WORK_ASSIGNMENT_TS.IS_ACTIVE()      13 Is there an active assignme OK
+                                       nt on 6/30/1995 for v_TEST_
+                                       30?
+
+WORK_ASSIGNMENT_TS.IS_ACTIVE()      14 Is there an active assignme OK
+                                       nt on 6/30/1995 for v_TEST_
+                                       30_1?
+
+WORK_ASSIGNMENT_TS.IS_ACTIVE()      15 Is there currently an activ OK
+                                       e assignment for v_TEST_30_
+                                       2?
+
+WORK_ASSIGNMENT_TS DELETE           16 Delete existing test entrie OK
+                                       s from WORK_ASSIGNMENT_T
+
+WORK_ASSIGNMENT_TS DELETE           17 Delete existing test entrie OK
+                                       s from WORK_T
+
+WORK_ASSIGNMENT_TS DELETE           18 Delete existing test entrie OK
+                                       s from WORKER_T
+
+WORK_ASSIGNMENT_TS                                                 SUCCESS
+
+20 rows selected.
+
diff --git a/Chapter10/logical_assignment_t.ins b/Chapter10/logical_assignment_t.ins
new file mode 100644
index 0000000..4a1fe10
--- /dev/null
+++ b/Chapter10/logical_assignment_t.ins
@@ -0,0 +1,118 @@
+declare
+
+-- Add worker history
+
+cursor c_logical_workplace is
+select l.id,
+       c1.code
+from   LOGICAL_WORKPLACE_T l,
+       WORKPLACE_TYPE_T c1
+where  l.workplace_type_id = c1.id       
+order by 1;
+
+cursor c_worker is
+select w.id
+from   WORKER_T w
+where  w.worker_type_id = (
+select c1.id
+from   WORKER_TYPE_T c1
+where  c1.code = 'E')
+order by w.birth_date desc,
+       w.id;
+
+r_logical_assignment                  LOGICAL_ASSIGNMENT_T%ROWTYPE;
+
+begin
+  LOGICAL_ASSIGNMENT_TS.n_inserted := 0;
+  LOGICAL_ASSIGNMENT_TS.n_updated  := 0;
+  
+  open c_worker;
+  
+  for r_logical_workplace in c_logical_workplace loop
+
+    if    c_logical_workplace%rowcount between  0 and  1 then
+      r_logical_assignment.id := NULL;
+      fetch c_worker into 
+        r_logical_assignment.worker_id;
+      exit when c_worker  %notfound;
+      r_logical_assignment.logical_workplace_id  :=
+        r_logical_workplace.id;
+      r_logical_assignment.active_date           := 
+        to_date('19600101', 'YYYYMMDD');
+      r_logical_assignment.inactive_date         := NULL;  
+      LOGICAL_ASSIGNMENT_TS.set_row(r_logical_assignment);
+    elsif c_logical_workplace%rowcount between  2 and  3 then
+      r_logical_assignment.id := NULL;
+      fetch c_worker into 
+        r_logical_assignment.worker_id;
+      exit when c_worker%notfound;
+      r_logical_assignment.logical_workplace_id  :=
+        r_logical_workplace.id;
+      r_logical_assignment.active_date           := 
+        to_date('19640101', 'YYYYMMDD');
+      r_logical_assignment.inactive_date         := NULL;  
+      LOGICAL_ASSIGNMENT_TS.set_row(r_logical_assignment);
+    elsif c_logical_workplace%rowcount between  4 and  7 then
+      r_logical_assignment.id := NULL;
+      fetch c_worker into 
+        r_logical_assignment.worker_id;
+      exit when c_worker%notfound;
+      r_logical_assignment.logical_workplace_id  :=
+        r_logical_workplace.id;
+      r_logical_assignment.active_date           := 
+        to_date('19680101', 'YYYYMMDD');
+      r_logical_assignment.inactive_date         := NULL;  
+      LOGICAL_ASSIGNMENT_TS.set_row(r_logical_assignment);
+    elsif c_logical_workplace%rowcount between  8 and 11 then
+      for i in 1..3652 loop
+        for j in 1..3652 loop
+          r_logical_assignment.id := NULL;
+          fetch c_worker into 
+            r_logical_assignment.worker_id;
+          exit when c_worker%notfound;
+          r_logical_assignment.logical_workplace_id  :=
+            r_logical_workplace.id;
+          r_logical_assignment.active_date           := 
+            to_date('19720101', 'YYYYMMDD')  + (30*i);
+          r_logical_assignment.inactive_date         := 
+            r_logical_assignment.active_date + (30*3652/j);
+          LOGICAL_ASSIGNMENT_TS.set_row(r_logical_assignment);
+        end loop;
+        exit when c_worker%notfound;
+      end loop;
+    else
+      for i in 1..3652 loop
+        for j in 1..3652 loop
+          r_logical_assignment.id := NULL;
+          fetch c_worker into 
+            r_logical_assignment.worker_id;
+          exit when c_worker%notfound;
+          r_logical_assignment.logical_workplace_id  :=
+            r_logical_workplace.id;
+          r_logical_assignment.active_date           := 
+            to_date('19760101', 'YYYYMMDD')  + (30*i);
+          r_logical_assignment.inactive_date         := 
+            r_logical_assignment.active_date + (30*3652/j);
+        end loop;
+        exit when c_worker%notfound;
+      end loop;
+      exit when c_worker%notfound;
+    end if;
+  end loop;
+   
+  if c_worker%notfound then
+    pl('I ran out of workers');
+  end if;
+  
+  close c_worker;
+  
+  update LOGICAL_ASSIGNMENT_T
+  set    inactive_date = NULL
+  where  inactive_date > SYSDATE;
+
+  commit;
+  pl(to_char(LOGICAL_ASSIGNMENT_TS.n_inserted)||' rows inserted.');
+  pl(to_char(LOGICAL_ASSIGNMENT_TS.n_updated)||' rows updated.');
+ end;
+ /
+ 
\ No newline at end of file
diff --git a/Chapter10/logical_assignment_ts.pkb b/Chapter10/logical_assignment_ts.pkb
new file mode 100644
index 0000000..dea2036
--- /dev/null
+++ b/Chapter10/logical_assignment_ts.pkb
@@ -0,0 +1,694 @@
+create or replace PACKAGE BODY LOGICAL_ASSIGNMENT_TS as
+/*
+logical_assignment_ts.pkb
+by Donald J. Bales on 12/15/2006
+Table LOGICAL_ASSIGNMENT_T's methods
+*/
+
+
+FUNCTION get_id
+return                                LOGICAL_ASSIGNMENT_T.id%TYPE is
+
+n_id                                  LOGICAL_ASSIGNMENT_T.id%TYPE;
+
+begin
+  select LOGICAL_ASSIGNMENT_ID_SEQ.nextval 
+  into   n_id
+  from   SYS.DUAL;
+
+  return n_id;
+end get_id;
+
+
+FUNCTION get_logical_workplace(
+ain_worker_id                  in     LOGICAL_ASSIGNMENT_T.worker_id%TYPE,
+aid_on                         in     LOGICAL_ASSIGNMENT_T.active_date%TYPE)
+return                                LOGICAL_WORKPLACE_T%ROWTYPE is
+
+r_logical_workplace                   LOGICAL_WORKPLACE_T%ROWTYPE;
+
+begin
+  select *
+  into   r_logical_workplace
+  from   LOGICAL_WORKPLACE_T
+  where  id = (
+  select logical_workplace_id
+  from   LOGICAL_ASSIGNMENT_T
+  where  worker_id = ain_worker_id
+  and    aid_on between active_date and nvl(inactive_date, DATES.d_MAX) );
+  
+  return r_logical_workplace;
+end get_logical_workplace;
+
+
+FUNCTION get_logical_workplace(
+ain_worker_id                  in     LOGICAL_ASSIGNMENT_T.worker_id%TYPE)
+return                                LOGICAL_WORKPLACE_T%ROWTYPE is
+
+begin
+  return get_logical_workplace(ain_worker_id, SYSDATE);
+end get_logical_workplace;
+
+
+FUNCTION get_row(
+air_logical_assignment         in     LOGICAL_ASSIGNMENT_T%ROWTYPE)
+return                                LOGICAL_ASSIGNMENT_T%ROWTYPE is
+
+r_logical_assignment                  LOGICAL_ASSIGNMENT_T%ROWTYPE;
+
+begin
+  if    air_logical_assignment.id is not NULL then
+    -- retrieve the row by the primary key
+    select *
+    into   r_logical_assignment
+    from   LOGICAL_ASSIGNMENT_T
+    where  id = air_logical_assignment.id;
+  else
+    -- retrieve the row by the worker_id and active_date
+    select *
+    into   r_logical_assignment
+    from   LOGICAL_ASSIGNMENT_T
+    where  worker_id   = air_logical_assignment.worker_id
+    and    active_date = air_logical_assignment.active_date;
+  end if;  
+  return r_logical_assignment;
+exception
+  when NO_DATA_FOUND then
+    raise;
+  when OTHERS then
+    raise_application_error(-20001, SQLERRM||
+      ' on select LOGICAL_ASSIGNMENT_T'||
+      ' in LOGICAL_ASSIGNMENT_TS.get_row()');
+end get_row;  
+
+
+PROCEDURE help is
+
+begin
+  TEXT_HELP.process('LOGICAL_ASSIGNMENT_TS');
+end help;
+
+
+FUNCTION is_active(
+ain_worker_id                  in     LOGICAL_ASSIGNMENT_T.worker_id%TYPE,
+aid_on                         in     date)
+return                                boolean is
+
+n_count                               number;
+
+begin
+ select count(1)
+ into   n_count
+ from   LOGICAL_ASSIGNMENT_T
+ where  worker_id       = ain_worker_id
+ and    aid_on    between active_date 
+                      and nvl(inactive_date, DATES.d_MAX);
+
+ if nvl(n_count,0) > 0 then
+  return TRUE;
+ else
+  return FALSE;
+ end if;
+end is_active;
+
+
+FUNCTION is_active(
+ain_worker_id                  in     LOGICAL_ASSIGNMENT_T.worker_id%TYPE)
+return                                boolean is
+
+begin
+ return is_active(ain_worker_id, SYSDATE);
+end is_active;
+
+
+FUNCTION is_history(
+ain_worker_id                  in     LOGICAL_ASSIGNMENT_T.worker_id%TYPE,
+aid_active_date                in     LOGICAL_ASSIGNMENT_T.active_date%TYPE,
+aid_inactive_date              in     LOGICAL_ASSIGNMENT_T.inactive_date%TYPE)
+return                                boolean is
+
+pragma autonomous_transaction;
+
+n_count                               number;
+
+begin
+  select count(1)
+  into   n_count
+  from   LOGICAL_ASSIGNMENT_T
+  where  worker_id                        = ain_worker_id
+  and    active_date                     <= 
+           nvl(aid_inactive_date, DATES.d_MAX)
+  and    nvl(inactive_date, DATES.d_MAX) >= aid_active_date;
+  commit; 
+
+  if nvl(n_count,0) > 0 then
+    return TRUE;
+  else
+    return FALSE;
+  end if;
+end is_history;
+
+
+PROCEDURE set_row(
+aior_logical_assignment        in out LOGICAL_ASSIGNMENT_T%ROWTYPE) is
+
+d_null                       constant date        := DATES.d_MIN;
+n_null                       constant number      := 0;
+v_null                       constant varchar2(1) := ' ';
+r_logical_assignment                  LOGICAL_ASSIGNMENT_T%ROWTYPE;
+
+begin
+  -- get the existing row
+  begin
+    r_logical_assignment := get_row(aior_logical_assignment);
+  exception
+    when NO_DATA_FOUND then
+      r_logical_assignment := NULL;
+  end;
+  -- if a row exists, update it if needed
+  if r_logical_assignment.id is not NULL then
+    aior_logical_assignment.id := r_logical_assignment.id;
+    aior_logical_assignment.worker_id             := r_logical_assignment.worker_id;
+    aior_logical_assignment.active_date           := r_logical_assignment.active_date;
+    if nvl(r_logical_assignment.logical_workplace_id, n_null) <> nvl(aior_logical_assignment.logical_workplace_id, n_null) or
+       nvl(r_logical_assignment.inactive_date,        d_null) <> nvl(aior_logical_assignment.inactive_date,        d_null) then
+      begin
+        update LOGICAL_ASSIGNMENT_T
+        set    logical_workplace_id  = aior_logical_assignment.logical_workplace_id,
+               inactive_date         = aior_logical_assignment.inactive_date
+        where  id = aior_logical_assignment.id;
+
+        n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0);
+      exception
+        when OTHERS then
+          raise_application_error( -20002, SQLERRM||
+            ' on update LOGICAL_ASSIGNMENT_T'||
+            ' in LOGICAL_ASSIGNMENT_TS.set_row()' );
+      end;
+    end if;
+  else
+  -- add the row if it does not exist
+    begin
+      if aior_logical_assignment.id is NULL then
+        aior_logical_assignment.id := get_id();
+      end if;
+      insert into LOGICAL_ASSIGNMENT_T (
+             id,
+             worker_id,
+             logical_workplace_id,
+             active_date,
+             inactive_date )
+      values (
+             aior_logical_assignment.id,
+             aior_logical_assignment.worker_id,
+             aior_logical_assignment.logical_workplace_id,
+             aior_logical_assignment.active_date,
+             aior_logical_assignment.inactive_date );
+
+      n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0);
+    exception
+      when OTHERS then
+        raise_application_error( -20003, SQLERRM||
+          ' on insert LOGICAL_ASSIGNMENT_T'||
+          ' in LOGICAL_ASSIGNMENT_TS.set_row()' );
+    end;
+  end if;
+end set_row;
+
+
+PROCEDURE test is
+
+n_logical_workplace_id                LOGICAL_WORKPLACE_T.id%TYPE;
+n_logical_workplace_id_1              LOGICAL_WORKPLACE_T.id%TYPE;
+n_logical_workplace_id_2              LOGICAL_WORKPLACE_T.id%TYPE;
+n_worker_id                           WORKER_T.id%TYPE;
+n_worker_id_1                         WORKER_T.id%TYPE;
+n_worker_id_2                         WORKER_T.id%TYPE;
+r_worker                              WORKER_T%ROWTYPE;
+r_logical_workplace                   LOGICAL_WORKPLACE_T%ROWTYPE;
+r_logical_assignment                  LOGICAL_ASSIGNMENT_T%ROWTYPE;
+
+begin
+  pl('LOGICAL_ASSIGNMENT_TS.test()');
+  
+  TEST_TS.clear('LOGICAL_ASSIGNMENT_TS');
+  
+  -- In order to make entries into an Intersection table
+  -- you first have to have entries in the two tables
+  -- for which an entry will create an intersection
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'DELETE', 0, 
+    'Delete existing test entries from LOGICAL_ASSIGNMENT_T');
+  begin
+    delete LOGICAL_ASSIGNMENT_T
+    where  logical_workplace_id in (
+    select logical_workplace_id
+    from   LOGICAL_WORKPLACE_T
+    where  code in (
+      TEST_TS.v_TEST_30,
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 ) );
+
+    delete LOGICAL_ASSIGNMENT_T
+    where  worker_id in (
+    select worker_id
+    from   WORKER_T
+    where  external_id in (  
+      TEST_TS.v_TEST_30,
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 ) );
+      
+    TEST_TS.ok();
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'DELETE', 1, 
+    'Delete existing test entries from LOGICAL_WORKPLACE_T');
+  begin
+    delete LOGICAL_WORKPLACE_T
+    where  code in (
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 );
+  
+    delete LOGICAL_WORKPLACE_T
+    where  code in (
+      TEST_TS.v_TEST_30 );
+  
+    TEST_TS.ok;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'DELETE', 2, 
+    'Delete existing test entries from WORKER_T');
+  begin
+    delete WORKER_T
+    where  external_id in (  
+      TEST_TS.v_TEST_30,
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 );
+  
+    TEST_TS.ok();
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'INSERT', 3, 
+    'Insert WORKER_T test entries using set_row()');
+  begin
+    r_worker.id             := WORKER_TS.get_id();
+    r_worker.worker_type_id := WORKER_TYPE_TS.get_id('E');
+    r_worker.external_id    := TEST_TS.v_TEST_30;
+    r_worker.first_name     := TEST_TS.v_TEST_30;
+    r_worker.middle_name    := TEST_TS.v_TEST_30;
+    r_worker.last_name      := TEST_TS.v_TEST_30;
+    r_worker.name           := WORKER_TS.get_formatted_name(
+      r_worker.first_name,
+      r_worker.middle_name,
+      r_worker.last_name);
+    r_worker.birth_date     := to_date('19800101', 'YYYYMMDD');   
+    r_worker.gender_id      := GENDER_TS.get_id('M');
+    WORKER_TS.set_row(r_worker);
+    n_worker_id             := r_worker.id;
+
+    r_worker.id             := WORKER_TS.get_id();
+    r_worker.worker_type_id := WORKER_TYPE_TS.get_id('E');
+    r_worker.external_id    := TEST_TS.v_TEST_30_1;
+    r_worker.first_name     := TEST_TS.v_TEST_30_1;
+    r_worker.middle_name    := TEST_TS.v_TEST_30_1;
+    r_worker.last_name      := TEST_TS.v_TEST_30_1;
+    r_worker.name           := WORKER_TS.get_formatted_name(
+      r_worker.first_name,
+      r_worker.middle_name,
+      r_worker.last_name);
+    r_worker.birth_date     := to_date('19700101', 'YYYYMMDD');   
+    r_worker.gender_id      := GENDER_TS.get_id('F');
+    WORKER_TS.set_row(r_worker);
+    n_worker_id_1           := r_worker.id;
+
+    r_worker.id             := WORKER_TS.get_id();
+    r_worker.worker_type_id := WORKER_TYPE_TS.get_id('C');
+    r_worker.external_id    := TEST_TS.v_TEST_30_2;
+    r_worker.first_name     := TEST_TS.v_TEST_30_2;
+    r_worker.middle_name    := TEST_TS.v_TEST_30_2;
+    r_worker.last_name      := TEST_TS.v_TEST_30_2;
+    r_worker.name           := WORKER_TS.get_formatted_name(
+      r_worker.first_name,
+      r_worker.middle_name,
+      r_worker.last_name);
+    r_worker.birth_date     := to_date('19600101', 'YYYYMMDD');   
+    r_worker.gender_id      := GENDER_TS.get_id('M');
+    WORKER_TS.set_row(r_worker);
+    n_worker_id_2           := r_worker.id;
+  
+    TEST_TS.ok();
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'INSERT', 4, 
+    'Insert LOGICAL_WORKPLACE_T test entries using set_row()');
+  begin
+    r_logical_workplace.id                   := 
+      LOGICAL_WORKPLACE_TS.get_id();
+    r_logical_workplace.parent_id            := NULL;
+    r_logical_workplace.id_context           := 
+      LOGICAL_WORKPLACE_TS.create_id_context(
+        r_logical_workplace.parent_id,
+        r_logical_workplace.id);
+    r_logical_workplace.workplace_type_id    := 
+      WORKPLACE_TYPE_TS.get_id('C');
+    r_logical_workplace.code                 := TEST_TS.v_TEST_30;
+    r_logical_workplace.name                 := TEST_TS.v_TEST_80;
+    r_logical_workplace.active_date          := TEST_TS.d_TEST_19000101;
+    r_logical_workplace.inactive_date        := NULL;
+    LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace);
+    n_logical_workplace_id                   :=
+      r_logical_workplace.id;
+
+    r_logical_workplace.id                   := 
+      LOGICAL_WORKPLACE_TS.get_id();
+    r_logical_workplace.parent_id            := 
+      n_logical_workplace_id;
+    r_logical_workplace.id_context           := 
+      LOGICAL_WORKPLACE_TS.create_id_context(
+        r_logical_workplace.parent_id,
+        r_logical_workplace.id);
+    r_logical_workplace.workplace_type_id    := 
+      WORKPLACE_TYPE_TS.get_id('B');
+    r_logical_workplace.code                 := TEST_TS.v_TEST_30_1;
+    r_logical_workplace.name                 := TEST_TS.v_TEST_80;
+    r_logical_workplace.active_date          := TEST_TS.d_TEST_19000101;
+    r_logical_workplace.inactive_date        := NULL;
+    LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace);
+    n_logical_workplace_id_1                 :=
+      r_logical_workplace.id;
+
+    r_logical_workplace.id                   := 
+      LOGICAL_WORKPLACE_TS.get_id();
+    r_logical_workplace.parent_id            := 
+      n_logical_workplace_id;
+    r_logical_workplace.id_context           := 
+      LOGICAL_WORKPLACE_TS.create_id_context(
+        r_logical_workplace.parent_id,
+        r_logical_workplace.id);
+    r_logical_workplace.workplace_type_id    := 
+      WORKPLACE_TYPE_TS.get_id('B');
+    r_logical_workplace.code                 := TEST_TS.v_TEST_30_2;
+    r_logical_workplace.name                 := TEST_TS.v_TEST_80;
+    r_logical_workplace.active_date          := TEST_TS.d_TEST_19000101;
+    r_logical_workplace.inactive_date        := NULL;
+    LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace);
+    n_logical_workplace_id_2                 :=
+      r_logical_workplace.id;
+
+    TEST_TS.ok();
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  -- Now that I have entries in the two tables being intersected
+  -- I can now start testing this package...
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'get_id()', 5, 
+    'Allocate the next primary key value using get_id()');
+  begin
+    r_logical_assignment.id := 
+      LOGICAL_ASSIGNMENT_TS.get_id();
+    
+    if nvl(r_logical_assignment.id, 0) > 0 then
+      TEST_TS.ok();
+    else
+      TEST_TS.error();
+    end if;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'set_row()', 6, 
+    'Insert history for v_TEST_30 using set_row()');
+  begin
+    r_logical_assignment.worker_id            := n_worker_id;
+    r_logical_assignment.logical_workplace_id := 
+      n_logical_workplace_id_2;
+    r_logical_assignment.active_date          := 
+      to_date('20000101', 'YYYYMMDD');
+    r_logical_assignment.inactive_date        := NULL;
+    LOGICAL_ASSIGNMENT_TS.set_row(r_logical_assignment);
+  
+    TEST_TS.ok;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'set_row()', 7, 
+    'Insert history for V_TEST_30_1 using set_row()');
+  begin
+    r_logical_assignment.id := 
+      LOGICAL_ASSIGNMENT_TS.get_id();
+    r_logical_assignment.worker_id            := n_worker_id_1;
+    r_logical_assignment.logical_workplace_id := 
+      n_logical_workplace_id_1;
+    r_logical_assignment.active_date          := 
+      to_date('19900101', 'YYYYMMDD');
+    r_logical_assignment.inactive_date        := 
+      to_date('19991231', 'YYYYMMDD');
+    LOGICAL_ASSIGNMENT_TS.set_row(r_logical_assignment);
+  
+    r_logical_assignment.id := 
+      LOGICAL_ASSIGNMENT_TS.get_id();
+    r_logical_assignment.worker_id            := n_worker_id_1;
+    r_logical_assignment.logical_workplace_id := 
+      n_logical_workplace_id_2;
+    r_logical_assignment.active_date          := 
+      to_date('20000101', 'YYYYMMDD');
+    r_logical_assignment.inactive_date        := NULL;
+    LOGICAL_ASSIGNMENT_TS.set_row(r_logical_assignment);
+  
+    TEST_TS.ok;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'set_row()', 8, 
+    'Insert history for V_TEST_30_2 using set_row()');
+  begin
+    r_logical_assignment.id := 
+      LOGICAL_ASSIGNMENT_TS.get_id();
+    r_logical_assignment.worker_id            := n_worker_id_2;
+    r_logical_assignment.logical_workplace_id := 
+      n_logical_workplace_id_1;
+    r_logical_assignment.active_date          := 
+      to_date('19800101', 'YYYYMMDD');
+    r_logical_assignment.inactive_date        := 
+      to_date('19891231', 'YYYYMMDD');
+    LOGICAL_ASSIGNMENT_TS.set_row(r_logical_assignment);
+  
+    r_logical_assignment.id := 
+      LOGICAL_ASSIGNMENT_TS.get_id();
+    r_logical_assignment.worker_id            := n_worker_id_2;
+    r_logical_assignment.logical_workplace_id := 
+      n_logical_workplace_id_2;
+    r_logical_assignment.active_date          := 
+      to_date('19900101', 'YYYYMMDD');
+    r_logical_assignment.inactive_date        := 
+      to_date('19901231', 'YYYYMMDD');
+    LOGICAL_ASSIGNMENT_TS.set_row(r_logical_assignment);
+  
+    TEST_TS.ok;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  -- Commit the deletes and inserts
+  commit;
+  
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 
+    'get_logical_workplace()', 9, 
+    'Get the current logical workplace for v_TEST_30');
+  begin
+    r_logical_workplace := NULL;
+    r_logical_workplace := get_logical_workplace(n_worker_id);
+  
+    if nvl(r_logical_workplace.id, 0) > 0 then
+      TEST_TS.ok();
+    else
+      TEST_TS.error();
+    end if;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 
+    'get_logical_workplace()', 10, 
+    'Get the logical workplace on 6/30/1995 for v_TEST_30_1');
+  begin
+    r_logical_workplace := NULL;
+    r_logical_workplace := get_logical_workplace(
+      n_worker_id_1,
+      to_date('19950630', 'YYYYMMDD'));
+  
+    if nvl(r_logical_workplace.id, 0) > 0 then
+      TEST_TS.ok();
+    else
+      TEST_TS.error();
+    end if;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 
+    'get_logical_workplace()', 11, 
+    'Get the logical workplace on 6/30/1995 for v_TEST_30_2');
+  begin
+    -- this should fail
+    r_logical_workplace := NULL;
+    r_logical_workplace := get_logical_workplace(
+      n_worker_id_2,
+      to_date('19950630', 'YYYYMMDD'));
+  
+    if nvl(r_logical_workplace.id, 0) > 0 then
+      TEST_TS.error();
+    else
+      TEST_TS.ok();
+    end if;
+  exception
+    when NO_DATA_FOUND then
+      TEST_TS.ok();
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'help()', 12, 
+    'Test help()');
+  begin
+    help();  
+  
+    TEST_TS.ok;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'is_active()', 13, 
+    'Is there an active assignment on 6/30/1995 for v_TEST_30?');
+    -- No
+  begin
+    if is_active(n_worker_id, to_date('19950630', 'YYYYMMDD')) then
+      TEST_TS.error();
+    else
+      TEST_TS.ok();
+    end if;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'is_active()', 14, 
+    'Is there an active assignment on 6/30/1995 for v_TEST_30_1?');
+    -- Yes
+  begin
+    if is_active(n_worker_id_1, to_date('19950630', 'YYYYMMDD')) then
+      TEST_TS.ok();
+    else
+      TEST_TS.error();
+    end if;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'is_active()', 15, 
+    'Is there currently an active assignment for v_TEST_30_2?');
+    -- No
+  begin
+    if is_active(n_worker_id_2) then
+      TEST_TS.error();
+    else
+      TEST_TS.ok();
+    end if;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  -- Now clean up after the tests by deleting the test entries
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'DELETE', 16, 
+    'Delete existing test entries from LOGICAL_ASSIGNMENT_T');
+  begin
+    delete LOGICAL_ASSIGNMENT_T
+    where  logical_workplace_id in (
+    select logical_workplace_id
+    from   LOGICAL_WORKPLACE_T
+    where  code in (
+      TEST_TS.v_TEST_30,
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 ) );
+
+    delete LOGICAL_ASSIGNMENT_T
+    where  worker_id in (
+    select worker_id
+    from   WORKER_T
+    where  external_id in (  
+      TEST_TS.v_TEST_30,
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 ) );
+      
+    TEST_TS.ok();
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'DELETE', 17, 
+    'Delete existing test entries from LOGICAL_WORKPLACE_T');
+  begin
+    delete LOGICAL_WORKPLACE_T
+    where  code in (
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 );
+  
+    delete LOGICAL_WORKPLACE_T
+    where  code in (
+      TEST_TS.v_TEST_30 );
+  
+    TEST_TS.ok;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', 'DELETE', 18, 
+    'Delete existing test entries from WORKER_T');
+  begin
+    delete WORKER_T
+    where  external_id in (  
+      TEST_TS.v_TEST_30,
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 );
+  
+    TEST_TS.ok();
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  commit;
+  TEST_TS.set_test('LOGICAL_ASSIGNMENT_TS', NULL, NULL, NULL);
+  TEST_TS.success();
+end test;
+
+
+end LOGICAL_ASSIGNMENT_TS;
+/
+@be.sql LOGICAL_ASSIGNMENT_TS
diff --git a/Chapter10/logical_assignment_ts.pks b/Chapter10/logical_assignment_ts.pks
new file mode 100644
index 0000000..422df99
--- /dev/null
+++ b/Chapter10/logical_assignment_ts.pks
@@ -0,0 +1,102 @@
+create or replace PACKAGE LOGICAL_ASSIGNMENT_TS as
+/*
+logical_assignment_ts.pks
+Copyright by Donald J. Bales on 12/15/2006
+Table LOGICAL_ASSIGNMENT_T's methods
+*/
+
+-- GLOBAL VARIABLES
+
+-- Keep track of the number of inserts and updates to made by set_row().
+n_inserted                            number := 0;
+n_updated                             number := 0;
+
+
+/*
+Returns a new primary key id value for a row.
+*/
+FUNCTION get_id
+return                                LOGICAL_ASSIGNMENT_T.id%TYPE;
+
+
+/*
+Returns a the LOGICAL_WORKPLACE row for the specified worker_id and on the specified date.
+*/
+FUNCTION get_logical_workplace(
+ain_worker_id                  in     LOGICAL_ASSIGNMENT_T.worker_id%TYPE,
+aid_on                         in     LOGICAL_ASSIGNMENT_T.active_date%TYPE)
+return                                LOGICAL_WORKPLACE_T%ROWTYPE;
+
+
+/*
+Returns a the current LOGICAL_WORKPLACE row for the specified worker_id.
+*/
+FUNCTION get_logical_workplace(
+ain_worker_id                  in     LOGICAL_ASSIGNMENT_T.worker_id%TYPE)
+return                                LOGICAL_WORKPLACE_T%ROWTYPE;
+
+
+/* 
+Returns a LOGICAL_ASSIGNMENT row for the specified criteria.
+
+There are two sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the woker_id and active_date
+
+If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_logical_assignment in LOGICAL_ASSIGNMENT_T%ROWTYPE) +return LOGICAL_ASSIGNMENT_T%ROWTYPE; + + +/* + Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + + +/* +Returns TRUE if the worker has a logical assignment on the specified date, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in LOGICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in date) +return boolean; + + +/* +Returns TRUE if the worker currently has a logical assignment, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in LOGICAL_ASSIGNMENT_T.worker_id%TYPE) +return boolean; + + +/* +Updates or inserts a row matching the passed row into table LOGICAL_WORKPLACE_T. +
+First, set_row( ) calls get_row( ) to try to find a matching row that already +exists in the database. So you need to set the id, or worked_id +and active_date appropriately in order to properly detect an existing row.
+
+Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise a new row is inserted, including the allocation of +a new primary key value. Upon inserting a new value, the id +value is updated in the passed row.
+See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_logical_assignment in out LOGICAL_ASSIGNMENT_T%ROWTYPE); + + +/* +The test unit for this package. +*/ +PROCEDURE test; + + +end LOGICAL_ASSIGNMENT_TS; +/ +@be.sql LOGICAL_ASSIGNMENT_TS diff --git a/Chapter10/logical_workplace_t.ins b/Chapter10/logical_workplace_t.ins new file mode 100644 index 0000000..c80f289 --- /dev/null +++ b/Chapter10/logical_workplace_t.ins @@ -0,0 +1,348 @@ + + + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + NULL, + to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'VDMI', + 'VERY DIRTY MANUFACTURING, INC.', + to_date('19600101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t +where t.code = 'C'; + + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'SALE', + 'SALES', + to_date('19640101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'B' +and p.code = 'VDMI' +and p.name = 'VERY DIRTY MANUFACTURING, INC.' +and p.active_date = to_date('19600101', 'YYYYMMDD'); + + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'MKTG', + 'MARKETING', + to_date('19640101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'B' +and p.code = 'VDMI' +and p.name = 'VERY DIRTY MANUFACTURING, INC.' +and p.active_date = to_date('19600101', 'YYYYMMDD'); + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'ACCT', + 'ACCOUNTING', + to_date('19680101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'B' +and p.code = 'VDMI' +and p.name = 'VERY DIRTY MANUFACTURING, INC.' +and p.active_date = to_date('19600101', 'YYYYMMDD'); + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'PDEV', + 'PRODUCT DEVELOPMENT', + to_date('19680101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'B' +and p.code = 'VDMI' +and p.name = 'VERY DIRTY MANUFACTURING, INC.' +and p.active_date = to_date('19600101', 'YYYYMMDD'); + + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'MFG', + 'MANUFACTURING', + to_date('19680101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'B' +and p.code = 'VDMI' +and p.name = 'VERY DIRTY MANUFACTURING, INC.' +and p.active_date = to_date('19600101', 'YYYYMMDD'); + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'CHEM', + 'CHEMICALS', + to_date('19680101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'D' +and p.code = 'MFG' +and p.name = 'MANUFACTURING' +and p.active_date = to_date('19680101', 'YYYYMMDD'); + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'BIO', + 'BIOLOGICALS', + to_date('19720101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'D' +and p.code = 'MFG' +and p.name = 'MANUFACTURING' +and p.active_date = to_date('19680101', 'YYYYMMDD'); + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'METL', + 'METALS', + to_date('19720101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'D' +and p.code = 'MFG' +and p.name = 'MANUFACTURING' +and p.active_date = to_date('19680101', 'YYYYMMDD'); + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'RUSE', + 'REUSABLES', + to_date('19720101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'D' +and p.code = 'MFG' +and p.name = 'MANUFACTURING' +and p.active_date = to_date('19680101', 'YYYYMMDD'); + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'DISP', + 'DISPOSABLES', + to_date('19720101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'D' +and p.code = 'MFG' +and p.name = 'MANUFACTURING' +and p.active_date = to_date('19680101', 'YYYYMMDD'); + + +insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date ) +select LOGICAL_WORKPLACE_ID_SEQ.nextval, + p.id, + p.id_context||'.'||to_char(LOGICAL_WORKPLACE_ID_SEQ.currval), + t.id, + 'HR', + 'HUMAN RESOURCES', + to_date('19720101', 'YYYYMMDD') +from WORKPLACE_TYPE_T t, + LOGICAL_WORKPLACE_T p +where t.code = 'B' +and p.code = 'VDMI' +and p.name = 'VERY DIRTY MANUFACTURING, INC.' +and p.active_date = to_date('19600101', 'YYYYMMDD'); + +commit; + +-- but no IT? +declare + +r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; +n_IT_id LOGICAL_WORKPLACE_T.id%TYPE; +n_VDMI_id LOGICAL_WORKPLACE_T.id%TYPE; + +begin + -- first, get the company's id + -- set the record up to search by the code, name, and active_date + r_logical_workplace.code := 'VDMI'; + r_logical_workplace.name := 'VERY DIRTY MANUFACTURING, INC.'; + r_logical_workplace.active_date := to_date('19600101', 'YYYYMMDD'); + + r_logical_workplace := LOGICAL_WORKPLACE_TS.get_row(r_logical_workplace); + + n_VDMI_id := r_logical_workplace.id; + + -- now that we have our company's id, let's add IT + + r_logical_workplace.active_date := to_date('19720101', 'YYYYMMDD'); + + r_logical_workplace.id := NULL; + r_logical_workplace.parent_id := n_VDMI_id; + r_logical_workplace.id_context := NULL; + r_logical_workplace.workplace_type_id := WORKPLACE_TYPE_TS.get_id('B'); + r_logical_workplace.code := 'IT'; + r_logical_workplace.name := 'IRRITATING TECHNOLOGY'; + LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + + n_IT_id := + r_logical_workplace.id; + + r_logical_workplace.active_date := to_date('19760101', 'YYYYMMDD'); + + r_logical_workplace.id := NULL; + r_logical_workplace.parent_id := n_IT_id; + r_logical_workplace.id_context := NULL; + r_logical_workplace.workplace_type_id := WORKPLACE_TYPE_TS.get_id('D'); + r_logical_workplace.code := 'DP'; + r_logical_workplace.name := 'DEPRESSED PROCESSING'; + LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + + r_logical_workplace.id := NULL; + r_logical_workplace.parent_id := n_IT_id; + r_logical_workplace.id_context := NULL; + r_logical_workplace.workplace_type_id := WORKPLACE_TYPE_TS.get_id('D'); + r_logical_workplace.code := 'HSUP'; + r_logical_workplace.name := 'HARDWEAR SUPPORT'; + LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + + r_logical_workplace.id := NULL; + r_logical_workplace.parent_id := n_IT_id; + r_logical_workplace.id_context := NULL; + r_logical_workplace.workplace_type_id := WORKPLACE_TYPE_TS.get_id('D'); + r_logical_workplace.code := 'SDEV'; + r_logical_workplace.name := 'SOFTWEAR DEVELOPMENT'; + LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + + r_logical_workplace.id := NULL; + r_logical_workplace.parent_id := n_IT_id; + r_logical_workplace.id_context := NULL; + r_logical_workplace.workplace_type_id := WORKPLACE_TYPE_TS.get_id('D'); + r_logical_workplace.code := 'SINT'; + r_logical_workplace.name := 'SILLINESS INTEGRATION'; + LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + + r_logical_workplace.id := NULL; + r_logical_workplace.parent_id := n_IT_id; + r_logical_workplace.id_context := NULL; + r_logical_workplace.workplace_type_id := WORKPLACE_TYPE_TS.get_id('D'); + r_logical_workplace.code := 'SSUP'; + r_logical_workplace.name := 'SOFTWEAR SUPPORT'; + LOGICAL_WORKPLACE_TS.set_row(r_logical_workplace); + +end; +/ + +commit; diff --git a/Chapter10/logical_workplace_ts.pkb b/Chapter10/logical_workplace_ts.pkb new file mode 100644 index 0000000..e30b74b --- /dev/null +++ b/Chapter10/logical_workplace_ts.pkb @@ -0,0 +1,581 @@ +create or replace PACKAGE BODY LOGICAL_WORKPLACE_TS as +/* +logical_workplace_ts.pkb +Copyright by Donald J. Bales on 12/15/2006 +Table LOGICAL_WORKPLACE_T's methods +*/ + + +FUNCTION create_id_context( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +v_id_context LOGICAL_WORKPLACE_T.id_context%TYPE; + +begin + v_id_context := get_id_context(ain_parent_id); + + if v_id_context is not NULL then + return substr(v_id_context||'.'||to_char(ain_id), 1, 2000); + else + return to_char(ain_id); + end if; +end create_id_context; + + +FUNCTION get_code_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +cursor c_code_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) is +select upper(code) code +from LOGICAL_WORKPLACE_T +connect by prior parent_id = id +start with id = ain_id +order by level desc; + +v_code_context varchar2(2000); + +begin + for r_code_context in c_code_context(ain_id) loop + v_code_context := substr(v_code_context||'.'||r_code_context.code, 1, 2000); + end loop; + return v_code_context; +end get_code_context; + + +FUNCTION get_id +return LOGICAL_WORKPLACE_T.id%TYPE is + +n_id LOGICAL_WORKPLACE_T.id%TYPE; + +begin + select LOGICAL_WORKPLACE_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_id_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +v_id_context LOGICAL_WORKPLACE_T.id_context%TYPE; + +begin + if ain_id is not NULL then + select id_context + into v_id_context + from LOGICAL_WORKPLACE_T + where id = ain_id; + end if; + + return v_id_context; +end get_id_context; + + +FUNCTION get_name_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +cursor c_name_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) is +select initcap(name) name +from LOGICAL_WORKPLACE_T +connect by prior parent_id = id +start with id = ain_id +order by level desc; + +v_name_context varchar2(2000); + +begin + for r_name_context in c_name_context(ain_id) loop + v_name_context := substr(v_name_context||'.'||r_name_context.name, 1, 2000); + end loop; + return v_name_context; +end get_name_context; + + +FUNCTION get_row( +air_logical_workplace in LOGICAL_WORKPLACE_T%ROWTYPE) +return LOGICAL_WORKPLACE_T%ROWTYPE is + +r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; + +begin + if air_logical_workplace.id is not NULL then + --pl('retrieve the row by the primary key'); + select * + into r_logical_workplace + from LOGICAL_WORKPLACE_T + where id = air_logical_workplace.id; + elsif air_logical_workplace.id_context is not NULL then + --pl('retrieve the row by the id_context unique key'); + select * + into r_logical_workplace + from LOGICAL_WORKPLACE_T + where id_context = air_logical_workplace.id_context; + else + --pl('retrieve the row by the code, name, and active_date'); + select * + into r_logical_workplace + from LOGICAL_WORKPLACE_T + where code = air_logical_workplace.code + and name = air_logical_workplace.name + and active_date = air_logical_workplace.active_date; + end if; + return r_logical_workplace; +exception + when NO_DATA_FOUND then + raise; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select LOGICAL_WORKPLACE_T'|| + ' in LOGICAL_WORKPLACE_TS.get_row()'); +end get_row; + + +PROCEDURE inactivate( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE, +aid_inactive_date in LOGICAL_WORKPLACE_T.inactive_date%TYPE) is + +begin + update LOGICAL_WORKPLACE_T + set inactive_date = aid_inactive_date + where id = ain_id; +end inactivate; + + +FUNCTION is_duplicate( +aiv_code in LOGICAL_WORKPLACE_T.code%TYPE, +aiv_name in LOGICAL_WORKPLACE_T.name%TYPE, +aid_active_date in LOGICAL_WORKPLACE_T.active_date%TYPE) +return boolean is + +n_count number; + +begin + --pl('retrieve the row by the code, name, and active_date'); + select count(1) + into n_count + from LOGICAL_WORKPLACE_T + where code = aiv_code + and name = aiv_name + and trunc(active_date) = trunc(aid_active_date); + + if nvl(n_count, 0) > 0 then + return TRUE; + else + return FALSE; + end if; +end is_duplicate; + + +FUNCTION set_row( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +ain_workplace_type_id in LOGICAL_WORKPLACE_T.workplace_type_id%TYPE, +aiv_code in LOGICAL_WORKPLACE_T.code%TYPE, +aiv_name in LOGICAL_WORKPLACE_T.name%TYPE, +aid_active_date in LOGICAL_WORKPLACE_T.active_date%TYPE) +return LOGICAL_WORKPLACE_T.id%TYPE is + +r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; + +begin + r_logical_workplace.id := NULL; + r_logical_workplace.id_context := NULL; + r_logical_workplace.parent_id := ain_parent_id; + r_logical_workplace.workplace_type_id := ain_workplace_type_id; + r_logical_workplace.code := aiv_code; + r_logical_workplace.name := aiv_name; + r_logical_workplace.active_date := aid_active_date; + set_row(r_logical_workplace); + + return r_logical_workplace.id; +end set_row; + + +-- PROCEDURES + +PROCEDURE help is + +begin + TEXT_HELP.process('LOGICAL_WORKPLACE_TS'); +end help; + + +PROCEDURE set_row( +aior_logical_workplace in out LOGICAL_WORKPLACE_T%ROWTYPE) is + +d_null constant date := DATES.d_MIN; +n_null constant number := 0; +v_null constant varchar2(1) := ' '; +r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; + +begin + -- get the existing row + begin + r_logical_workplace := get_row(aior_logical_workplace); + exception + when NO_DATA_FOUND then + r_logical_workplace := NULL; + end; + -- if a row exists, update it if needed + if r_logical_workplace.id is not NULL then + aior_logical_workplace.id := r_logical_workplace.id; + aior_logical_workplace.parent_id := r_logical_workplace.parent_id; + aior_logical_workplace.id_context := r_logical_workplace.id_context; + if nvl(r_logical_workplace.workplace_type_id, n_null) <> nvl(aior_logical_workplace.workplace_type_id, n_null) or + nvl(r_logical_workplace.code, v_null) <> nvl(aior_logical_workplace.code, v_null) or + nvl(r_logical_workplace.name, v_null) <> nvl(aior_logical_workplace.name, v_null) or + nvl(r_logical_workplace.active_date, d_null) <> nvl(aior_logical_workplace.active_date, d_null) or + nvl(r_logical_workplace.inactive_date, d_null) <> nvl(aior_logical_workplace.inactive_date, d_null) then + begin + update LOGICAL_WORKPLACE_T + set workplace_type_id = aior_logical_workplace.workplace_type_id, + code = aior_logical_workplace.code, + name = aior_logical_workplace.name, + active_date = aior_logical_workplace.active_date, + inactive_date = aior_logical_workplace.inactive_date + where id = aior_logical_workplace.id; + + n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20002, SQLERRM|| + ' on update LOGICAL_WORKPLACE_T'|| + ' in LOGICAL_WORKPLACE_TS.set_row()' ); + end; + end if; + else + -- add the row if it does not exist + begin + if aior_logical_workplace.id is NULL then + aior_logical_workplace.id := get_id(); + end if; + aior_logical_workplace.id_context := + create_id_context( + aior_logical_workplace.parent_id, + aior_logical_workplace.id ); + insert into LOGICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date, + inactive_date ) + values ( + aior_logical_workplace.id, + aior_logical_workplace.parent_id, + aior_logical_workplace.id_context, + aior_logical_workplace.workplace_type_id, + aior_logical_workplace.code, + aior_logical_workplace.name, + aior_logical_workplace.active_date, + aior_logical_workplace.inactive_date ); + + n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20003, SQLERRM|| + ' on insert LOGICAL_WORKPLACE_T'|| + ' in LOGICAL_WORKPLACE_TS.set_row()' ); + end; + end if; +end set_row; + + +PROCEDURE test is + +/* +LOGICAL_WORKPLACE_T + Name Null? Type + ---------------------------------------- -------- ------------- + LOGICAL_WORKPLACE_ID NOT NULL NUMBER + PARENT_ID NUMBER + ID_CONTEXT NOT NULL VARCHAR2(100) + WORKPLACE_TYPE_ID NOT NULL NUMBER + CODE NOT NULL VARCHAR2(30) + NAME NOT NULL VARCHAR2(80) + ACTIVE_DATE NOT NULL DATE + INACTIVE_DATE DATE +*/ + +v_id_context LOGICAL_WORKPLACE_T.id_context%TYPE; +r_logical_workplace LOGICAL_WORKPLACE_T%ROWTYPE; + +begin + pl('LOGICAL_WORKPLACE_TS.test()'); + + TEST_TS.clear('LOGICAL_WORKPLACE_TS'); + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'DELETE', 0, + 'Delete existing test entries'); + begin + delete LOGICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + + delete LOGICAL_WORKPLACE_T + where code = TEST_TS.v_TEST_30; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'get_id()', 1, + 'Allocate the next primary key value'); + begin + r_logical_workplace.id := get_id(); + + if r_logical_workplace.id > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', + 'create_id_context()', 2, 'Create an ID context value'); + begin + r_logical_workplace.parent_id := NULL; + r_logical_workplace.id_context := + create_id_context( + r_logical_workplace.parent_id, + r_logical_workplace.id); + + if r_logical_workplace.id_context = + to_char(r_logical_workplace.id) then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'set_row()', 3, + 'Insert parent test entry'); + begin + r_logical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('C'); + r_logical_workplace.code := + TEST_TS.v_TEST_30; + r_logical_workplace.name := + TEST_TS.v_TEST_80; + r_logical_workplace.active_date := + TEST_TS.d_TEST_19000101; + r_logical_workplace.inactive_date := NULL; + set_row(r_logical_workplace); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'set_row()', 4, + 'Insert child entries'); + begin + r_logical_workplace.parent_id := + r_logical_workplace.id; + r_logical_workplace.id := get_id(); + r_logical_workplace.id_context := + create_id_context( + r_logical_workplace.parent_id, + r_logical_workplace.id); + -- save this value for testing get_row() + v_id_context := + r_logical_workplace.id_context; + r_logical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('B'); + r_logical_workplace.code := + TEST_TS.v_TEST_30_1; + r_logical_workplace.name := + TEST_TS.v_TEST_80; + set_row(r_logical_workplace); + + + r_logical_workplace.id := get_id(); + r_logical_workplace.id_context := + create_id_context( + r_logical_workplace.parent_id, + r_logical_workplace.id); + r_logical_workplace.code := + TEST_TS.v_TEST_30_2; + set_row(r_logical_workplace); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'get_code_context()', 5, + 'Get the code context for v_TEST_30_2'); + begin + pl(get_code_context( + r_logical_workplace.id)); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'get_name_context()', 6, + 'Get the name context for v_TEST_30_2'); + begin + pl(get_name_context( + r_logical_workplace.id)); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'get_row()', 7, + 'Get the row using the id for v_TEST_30_2'); + begin +-- r_logical_workplace.id := NULL; + r_logical_workplace.parent_id := NULL; + r_logical_workplace.id_context := NULL; + r_logical_workplace.workplace_type_id := NULL; + r_logical_workplace.code := NULL; + r_logical_workplace.name := NULL; + r_logical_workplace.active_date := NULL; + r_logical_workplace.inactive_date := NULL; + + r_logical_workplace := get_row(r_logical_workplace); + + if r_logical_workplace.id_context is not NULL then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'get_row()', 8, + 'Get the row using the id_context for v_TEST_30_1'); + begin + r_logical_workplace.id := NULL; + r_logical_workplace.parent_id := NULL; + r_logical_workplace.id_context := + v_id_context; + r_logical_workplace.workplace_type_id := NULL; + r_logical_workplace.code := NULL; + r_logical_workplace.name := NULL; + r_logical_workplace.active_date := NULL; + r_logical_workplace.inactive_date := NULL; + + r_logical_workplace := get_row(r_logical_workplace); + + if r_logical_workplace.id is not NULL then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + pl('v_id_context="'||v_id_context||'"'); + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'get_row()', 9, + 'Get the row using the code for v_TEST_30'); + begin + r_logical_workplace.id := NULL; + r_logical_workplace.parent_id := NULL; + r_logical_workplace.id_context := NULL; + r_logical_workplace.workplace_type_id := NULL; + r_logical_workplace.code := + TEST_TS.v_TEST_30; + r_logical_workplace.name := + TEST_TS.v_TEST_80; + r_logical_workplace.active_date := + TEST_TS.d_TEST_19000101; + r_logical_workplace.inactive_date := NULL; + + r_logical_workplace := get_row(r_logical_workplace); + + if r_logical_workplace.id is not NULL then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'help()', 10, + 'Display the help text'); + begin + help(); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'is_duplicate()', 11, + 'Is this a duplicate? It should be!'); + begin + if is_duplicate( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101) then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', 'DELETE', 12, + 'Delete test entries'); + begin + delete LOGICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + + delete LOGICAL_WORKPLACE_T + where code = TEST_TS.v_TEST_30; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + commit; + TEST_TS.set_test('LOGICAL_WORKPLACE_TS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end LOGICAL_WORKPLACE_TS; +/ +@be.sql LOGICAL_WORKPLACE_TS + diff --git a/Chapter10/logical_workplace_ts.pks b/Chapter10/logical_workplace_ts.pks new file mode 100644 index 0000000..f6aa70e --- /dev/null +++ b/Chapter10/logical_workplace_ts.pks @@ -0,0 +1,120 @@ +create or replace PACKAGE LOGICAL_WORKPLACE_TS as +/* +logical_workplace_ts.pks
+Copyright by Don Bales on 12/15/2006
+Table LOGICAL_WORKPLACE_T's methods. Contains all the supporting service +methods (functions and procedures) for table LOGICAL_WORKPLACE_T. +*/ + +-- GLOBAL VARIABLES + +-- Keep track of the number of inserts and updates to made by set_row( ). +n_inserted number := 0; +n_updated number := 0; + + +/* +Returns an id_context for the specified parent_id and logical_workplace_id. +Whatever creates a new row must also call this mehtod to create an appropriate +id_context value. Method set_row( ) does this for you. +*/ +FUNCTION create_id_context( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2; + + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return LOGICAL_WORKPLACE_T.id%TYPE; + + +/* +Returns the value of a context for the code values in the logical workplace assignment. +*/ +FUNCTION get_code_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2; + + +/* +Returns the value of a context for the id values in the logical workplace assignment. +*/ +FUNCTION get_id_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2; + + +/* +Returns the value of a context for the name values in the logical workplace assignment. +*/ +FUNCTION get_name_context( +ain_id in LOGICAL_WORKPLACE_T.id%TYPE) +return varchar2; + + +/* +Returns a LOGICAL_WORKPLACE row for the specified criteria. + +There are three sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the unique id_context
+3. the code, name, and active_date
+ +If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_logical_workplace in LOGICAL_WORKPLACE_T%ROWTYPE) +return LOGICAL_WORKPLACE_T%ROWTYPE; + + +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + + +/* +Updates or inserts a row matching the passed parameters into table LOGICAL_WORKPLACE_T. +See PROCEDURE set_row( ). +*/ +FUNCTION set_row( +ain_parent_id in LOGICAL_WORKPLACE_T.parent_id%TYPE, +ain_workplace_type_id in LOGICAL_WORKPLACE_T.workplace_type_id%TYPE, +aiv_code in LOGICAL_WORKPLACE_T.code%TYPE, +aiv_name in LOGICAL_WORKPLACE_T.name%TYPE, +aid_active_date in LOGICAL_WORKPLACE_T.active_date%TYPE) +return LOGICAL_WORKPLACE_T.id%TYPE; + + +/* +Updates or inserts a row matching the passed row into table LOGICAL_WORKPLACE_T. + +First, set_row() calls get row to try to find a matching row that already +exists in the database. So you need to set the id, id_context, +and code, name and active_date appropriately in order to prperly detect an +existing row. + +Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise, and new row is inserted, including the allocation of +a new primary key and id_context value. Upon inserting a new value, the +id and id_context values are updated in the passed row. +See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_logical_workplace in out LOGICAL_WORKPLACE_T%ROWTYPE); + + +/* +Performs unit tests for this package. +*/ +PROCEDURE test; + + +end LOGICAL_WORKPLACE_TS; +/ +@se.sql LOGICAL_WORKPLACE_TS + diff --git a/Chapter10/login.sql b/Chapter10/login.sql new file mode 100644 index 0000000..f347bdd --- /dev/null +++ b/Chapter10/login.sql @@ -0,0 +1,7 @@ +set linesize 1000; +set newpage 1; +set pagesize 32767; +set serveroutput on size 1000000; +set trimspool on; +alter session set nls_date_format = 'SYYYYMMDD HH24MISS'; +prompt BPS' default settings loaded successfully! diff --git a/Chapter10/on_demand_process.pkb b/Chapter10/on_demand_process.pkb new file mode 100644 index 0000000..2c5bb7b --- /dev/null +++ b/Chapter10/on_demand_process.pkb @@ -0,0 +1,81 @@ +create or replace package body ON_DEMAND_PROCESS as +/* +on_demand_process.pkb +by Donald J. Bales on 12/15/2006 + +On-demand Data Processing (ON_DEMAND): +An example of an on-demand data processing package +designed to truncate report staging tables +*/ + +PROCEDURE help is + +begin + TEXT_HELP.process('ON_DEMAND_PROCESS'); +end help; + + +PROCEDURE process is + +n_selected number := 0; +n_inserted number := 0; +n_updated number := 0; +n_deleted number := 0; + +begin + ON_DEMAND_PROCESS_LOGS.start_logging('ON_DEMAND_PROCESS', 'process'); + + -- *** Now do all your groovy data processing here! *** + + pl('OK man, I did my goovy data processing thing!'); + + -- *** End of your groovy data processing section. *** + + ON_DEMAND_PROCESS_LOGS.stop_logging( + n_selected, n_inserted, n_updated, n_deleted, NULL); +exception + when OTHERS then + ON_DEMAND_PROCESS_LOGS.stop_logging( + n_selected, n_inserted, n_updated, n_deleted, SQLERRM); + raise; +end process; + + +PROCEDURE test is + +begin + -- Send feedback that the test ran + pl('ON_DEMAND_PROCESS.test()'); + + -- Clear the last set of test results + TEST_TS.clear('ON_DEMAND_PROCESS'); + + -- Tests + TEST_TS.set_test('ON_DEMAND_PROCESS', 'help', 0, + 'Test help'); + begin + help(); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('ON_DEMAND_PROCESS', 'process', 1, + 'This method cannot be tested by test(), please test it manually.'); + begin + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('ON_DEMAND_PROCESS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end ON_DEMAND_PROCESS; +/ +@be.sql diff --git a/Chapter10/on_demand_process.pks b/Chapter10/on_demand_process.pks new file mode 100644 index 0000000..4109d8d --- /dev/null +++ b/Chapter10/on_demand_process.pks @@ -0,0 +1,22 @@ +create or replace package ON_DEMAND_PROCESS as +/* +on_demand_process.pks +by Donald J. Bales on 12/15/2006 + +On-demand Data Processing (ON_DEMAND): +An example of an on-demand data processing package +designed to truncate report staging tables +*/ + +PROCEDURE help; + + +PROCEDURE process; + + +PROCEDURE test; + + +end ON_DEMAND_PROCESS; +/ +@se.sql diff --git a/Chapter10/on_demand_process_log.tab b/Chapter10/on_demand_process_log.tab new file mode 100644 index 0000000..c3582fb --- /dev/null +++ b/Chapter10/on_demand_process_log.tab @@ -0,0 +1,37 @@ +rem on_demand_process_log.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a log table for on-demand data processing packages + +execute drop_if_exists('TABLE', 'ON_DEMAND_PROCESS_LOG'); +create table ON_DEMAND_PROCESS_LOG ( +id number not null, +object_name varchar2(30) not null, +method_name varchar2(30) not null, +rows_selected number, +rows_inserted number, +rows_updated number, +rows_deleted number, +result varchar2(256), +elapsed_time number, +insert_user varchar2(30) default USER not null, +insert_date date default SYSDATE not null, +update_user varchar2(30) default USER not null, +update_date date default SYSDATE not null) +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +alter table ON_DEMAND_PROCESS_LOG add +constraint ON_DEMAND_PROCESS_LOG_PK +primary key ( +id ) +using index +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +execute drop_if_exists('SEQUENCE', 'ON_DEMAND_PROCESS_LOG_ID_SEQ'); +create sequence ON_DEMAND_PROCESS_LOG_ID_SEQ +start with 1 order; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'ON_DEMAND_PROCESS_LOG'); + +grant select on ON_DEMAND_PROCESS_LOG to public; diff --git a/Chapter10/on_demand_process_logs.pkb b/Chapter10/on_demand_process_logs.pkb new file mode 100644 index 0000000..4a1b05a --- /dev/null +++ b/Chapter10/on_demand_process_logs.pkb @@ -0,0 +1,163 @@ +create or replace package body ON_DEMAND_PROCESS_LOGS as +/* +on_demand_process_logs.pkb +by Donald J. Bales on 12/15/2006 + +Table ON_DEMAND_PROCESS_LOG routines +*/ + + +-- Instance variables to hold log information between start and stop + +n_id ON_DEMAND_PROCESS_LOG.id%TYPE; +n_start number; + + +FUNCTION get_id +return ON_DEMAND_PROCESS_LOG.id%TYPE is + +n_id ON_DEMAND_PROCESS_LOG.id%TYPE; + +begin + select ON_DEMAND_PROCESS_LOG_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +PROCEDURE help is + +begin + TEXT_HELP.process('ON_DEMAND_PROCESS_LOGS'); +end help; + + +PROCEDURE start_logging( +aiv_object_name in ON_DEMAND_PROCESS_LOG.object_name%TYPE, +aiv_method_name in ON_DEMAND_PROCESS_LOG.method_name%TYPE) is + +pragma autonomous_transaction; + +begin + n_start := to_number(to_char(SYSDATE, 'SSSSS')); + n_id := get_id(); + + insert into ON_DEMAND_PROCESS_LOG ( + id, + object_name, + method_name ) + values ( + n_id, + upper(aiv_object_name), + upper(aiv_method_name) ); + commit; +end start_logging; + + +PROCEDURE stop_logging( +ain_rows_selected in ON_DEMAND_PROCESS_LOG.rows_selected%TYPE, +ain_rows_inserted in ON_DEMAND_PROCESS_LOG.rows_inserted%TYPE, +ain_rows_updated in ON_DEMAND_PROCESS_LOG.rows_updated%TYPE, +ain_rows_deleted in ON_DEMAND_PROCESS_LOG.rows_deleted%TYPE, +aiv_result in ON_DEMAND_PROCESS_LOG.result%TYPE) is + +pragma autonomous_transaction; + +n_elapsed_time number; + +begin + n_elapsed_time := to_number(to_char(SYSDATE, 'SSSSS')) - n_start; + + update ON_DEMAND_PROCESS_LOG + set rows_selected = ain_rows_selected, + rows_inserted = ain_rows_inserted, + rows_updated = ain_rows_updated, + rows_deleted = ain_rows_deleted, + result = aiv_result, + elapsed_time = n_elapsed_time, + update_user = USER, + update_date = SYSDATE + where id = n_id; + commit; + + n_id := NULL; + + -- Display the results + if ain_rows_selected is not null then + pl(to_char(ain_rows_selected)||' rows selected.'); + end if; + if ain_rows_inserted is not null then + pl(to_char(ain_rows_inserted)||' rows inserted.'); + end if; + if ain_rows_updated is not null then + pl(to_char(ain_rows_updated)||' rows updated.'); + end if; + if ain_rows_deleted is not null then + pl(to_char(ain_rows_deleted)||' rows deleted.'); + end if; + if aiv_result is not null then + pl(aiv_result); + end if; + pl('Elapsed time: '||to_char(n_elapsed_time)||' seconds.'); +end stop_logging; + + +PROCEDURE stop_logging( +aiv_result in ON_DEMAND_PROCESS_LOG.result%TYPE) is + +begin + stop_logging(NULL, NULL, NULL, NULL, aiv_result); +end stop_logging; + + +PROCEDURE stop_logging is + +begin + stop_logging(NULL, NULL, NULL, NULL, NULL); +end stop_logging; + + +PROCEDURE test is + +begin + -- Send feedback that the test ran + pl('ON_DEMAND_PROCESS_LOGS.test()'); + + -- Clear the last set of test results + TEST_TS.clear('ON_DEMAND_PROCESS_LOGS'); + + -- Tests + TEST_TS.set_test('ON_DEMAND_PROCESS_LOGS', 'start_logging()', 0, + 'start logging'); + begin + start_logging('ON_DEMAND_PROCESS_LOGS', 'test'); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('ON_DEMAND_PROCESS_LOGS', 'stop_logging()', 1, + 'stop logging'); + begin + SYS.DBMS_LOCK.sleep(3); + + stop_logging(); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('ON_DEMAND_PROCESS_LOGS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end ON_DEMAND_PROCESS_LOGS; +/ +@be.sql diff --git a/Chapter10/on_demand_process_logs.pks b/Chapter10/on_demand_process_logs.pks new file mode 100644 index 0000000..8422e34 --- /dev/null +++ b/Chapter10/on_demand_process_logs.pks @@ -0,0 +1,44 @@ +create or replace package ON_DEMAND_PROCESS_LOGS as +/* +on_demand_process_logs.pks +by Donald J. Bales on 12/15/2006 +Table ON_DEMAND_PROCESS_LOG routines +*/ + + +-- Display this packages help text. + +PROCEDURE help; + +-- Start logging the use of an on-demand data processing process + +PROCEDURE start_logging( +aiv_object_name in ON_DEMAND_PROCESS_LOG.object_name%TYPE, +aiv_method_name in ON_DEMAND_PROCESS_LOG.method_name%TYPE); + +-- Stop logging the use of an on-demand data processing process + +PROCEDURE stop_logging( +ain_rows_selected in ON_DEMAND_PROCESS_LOG.rows_selected%TYPE, +ain_rows_inserted in ON_DEMAND_PROCESS_LOG.rows_inserted%TYPE, +ain_rows_updated in ON_DEMAND_PROCESS_LOG.rows_updated%TYPE, +ain_rows_deleted in ON_DEMAND_PROCESS_LOG.rows_deleted%TYPE, +aiv_result in ON_DEMAND_PROCESS_LOG.result%TYPE); + +-- Stop logging the use of an on-demand data processing process + +PROCEDURE stop_logging( +aiv_result in ON_DEMAND_PROCESS_LOG.result%TYPE); + +-- Stop logging the use of an on-demand data processing process + +PROCEDURE stop_logging; + +-- Test the methods in this package + +PROCEDURE test; + + +end ON_DEMAND_PROCESS_LOGS; +/ +@se.sql diff --git a/Chapter10/pe.sql b/Chapter10/pe.sql new file mode 100644 index 0000000..40be076 --- /dev/null +++ b/Chapter10/pe.sql @@ -0,0 +1 @@ +show errors diff --git a/Chapter10/physical_assignment_t.ins b/Chapter10/physical_assignment_t.ins new file mode 100644 index 0000000..0509587 --- /dev/null +++ b/Chapter10/physical_assignment_t.ins @@ -0,0 +1,150 @@ +declare + +-- Add worker history + +cursor c_logical_assignment is +select a.worker_id, + a.active_date, + a.inactive_date, + w.code +from LOGICAL_ASSIGNMENT_T a, + LOGICAL_WORKPLACE_T w +where a.logical_workplace_id = w.id +order by 1; + +n_random number; +r_physical_assignment PHYSICAL_ASSIGNMENT_T%ROWTYPE; + +FUNCTION get_id( +aiv_code in PHYSICAL_WORKPLACE_T.code%TYPE) +return PHYSICAL_WORKPLACE_T.id%TYPE is + +n_id PHYSICAL_WORKPLACE_T.id%TYPE; + +begin + select id + into n_id + from PHYSICAL_WORKPLACE_T + where code = aiv_code; + + return n_id; +end get_id; + +FUNCTION random( +ain_min in number, +ain_max in number ) +return number is + +begin + return round(SYS.DBMS_RANDOM.value(ain_min, ain_max), 0); +end random; + +begin + PHYSICAL_ASSIGNMENT_TS.n_inserted := 0; + PHYSICAL_ASSIGNMENT_TS.n_updated := 0; + + for r_logical_assignment in c_logical_assignment loop + r_physical_assignment.id := NULL; + r_physical_assignment.worker_id := r_logical_assignment.worker_id; + + if r_logical_assignment.code = 'VDMI' then + r_physical_assignment.physical_workplace_id := get_id('NNJ'); + elsif r_logical_assignment.code = 'SALE' then + r_physical_assignment.physical_workplace_id := get_id('NNJ'); + elsif r_logical_assignment.code = 'MKTG' then + r_physical_assignment.physical_workplace_id := get_id('NNJ'); + elsif r_logical_assignment.code = 'ACCT' then + r_physical_assignment.physical_workplace_id := get_id('NNJ'); + elsif r_logical_assignment.code = 'PDEV' then + r_physical_assignment.physical_workplace_id := get_id('GIN'); + elsif r_logical_assignment.code = 'MFG' then + r_physical_assignment.physical_workplace_id := get_id('NNJ'); + elsif r_logical_assignment.code = 'CHEM' then + r_physical_assignment.physical_workplace_id := get_id('NNJ'); + n_random := random(1, 3); + if c_logical_assignment%rowcount > 18 then + if n_random = 1 then + r_physical_assignment.physical_workplace_id := get_id('CHEM'); + elsif n_random = 2 then + r_physical_assignment.physical_workplace_id := get_id('MIX1'); + else + r_physical_assignment.physical_workplace_id := get_id('DIS1'); + end if; + end if; + elsif r_logical_assignment.code = 'BIO' then + r_physical_assignment.physical_workplace_id := get_id('LCA'); + n_random := random(1, 3); + if c_logical_assignment%rowcount > 18 then + if n_random = 1 then + r_physical_assignment.physical_workplace_id := get_id('GRV1'); + elsif n_random = 2 then + r_physical_assignment.physical_workplace_id := get_id('DST2'); + else + r_physical_assignment.physical_workplace_id := get_id('INC1'); + end if; + end if; + elsif r_logical_assignment.code = 'METL' then + r_physical_assignment.physical_workplace_id := get_id('NNJ'); + n_random := random(1, 3); + if c_logical_assignment%rowcount > 18 then + if n_random = 1 then + r_physical_assignment.physical_workplace_id := get_id('METL'); + elsif n_random = 2 then + r_physical_assignment.physical_workplace_id := get_id('SEP1'); + else + r_physical_assignment.physical_workplace_id := get_id('CRS1'); + end if; + end if; + elsif r_logical_assignment.code = 'RUSE' then + r_physical_assignment.physical_workplace_id := get_id('GIN'); + n_random := random(1, 3); + if c_logical_assignment%rowcount > 18 then + if n_random = 1 then + r_physical_assignment.physical_workplace_id := get_id('RUSE'); + elsif n_random = 2 then + r_physical_assignment.physical_workplace_id := get_id('SEP3'); + else + r_physical_assignment.physical_workplace_id := get_id('CRS3'); + end if; + end if; + elsif r_logical_assignment.code = 'DISP' then + r_physical_assignment.physical_workplace_id := get_id('GIN'); + n_random := random(1, 3); + if c_logical_assignment%rowcount > 18 then + if n_random = 1 then + r_physical_assignment.physical_workplace_id := get_id('DISP'); + elsif n_random = 2 then + r_physical_assignment.physical_workplace_id := get_id('SEP2'); + else + r_physical_assignment.physical_workplace_id := get_id('CRS2'); + end if; + end if; + elsif r_logical_assignment.code = 'HR' then + r_physical_assignment.physical_workplace_id := get_id('NNJ'); + elsif r_logical_assignment.code = 'IT' then + r_physical_assignment.physical_workplace_id := get_id('NNJ'); + elsif r_logical_assignment.code = 'DP' then + r_physical_assignment.physical_workplace_id := get_id('NNJ'); + elsif r_logical_assignment.code = 'HSUP' then + r_physical_assignment.physical_workplace_id := get_id('NNJ'); + elsif r_logical_assignment.code = 'SDEV' then + r_physical_assignment.physical_workplace_id := get_id('NNJ'); + elsif r_logical_assignment.code = 'SINT' then + r_physical_assignment.physical_workplace_id := get_id('NNJ'); + elsif r_logical_assignment.code = 'SSUP' then + r_physical_assignment.physical_workplace_id := get_id('NNJ'); + else + raise_application_error(-20000, 'Unsupported code'); + end if; + + r_physical_assignment.active_date := r_logical_assignment.active_date; + r_physical_assignment.inactive_date := r_logical_assignment.inactive_date; + PHYSICAL_ASSIGNMENT_TS.set_row(r_physical_assignment); + end loop; + + commit; + pl(to_char(PHYSICAL_ASSIGNMENT_TS.n_inserted)||' rows inserted.'); + pl(to_char(PHYSICAL_ASSIGNMENT_TS.n_updated)||' rows updated.'); + end; + / + \ No newline at end of file diff --git a/Chapter10/physical_assignment_ts.pkb b/Chapter10/physical_assignment_ts.pkb new file mode 100644 index 0000000..d5f8afc --- /dev/null +++ b/Chapter10/physical_assignment_ts.pkb @@ -0,0 +1,694 @@ +create or replace PACKAGE BODY PHYSICAL_ASSIGNMENT_TS as +/* +physical_assignment_ts.pkb +by Donald J. Bales on 12/15/2006 +Table PHYSICAL_ASSIGNMENT_T's methods +*/ + + +FUNCTION get_id +return PHYSICAL_ASSIGNMENT_T.id%TYPE is + +n_id PHYSICAL_ASSIGNMENT_T.id%TYPE; + +begin + select PHYSICAL_ASSIGNMENT_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_physical_workplace( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in PHYSICAL_ASSIGNMENT_T.active_date%TYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE is + +r_physical_workplace PHYSICAL_WORKPLACE_T%ROWTYPE; + +begin + select * + into r_physical_workplace + from PHYSICAL_WORKPLACE_T + where id = ( + select physical_workplace_id + from PHYSICAL_ASSIGNMENT_T + where worker_id = ain_worker_id + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX) ); + + return r_physical_workplace; +end get_physical_workplace; + + +FUNCTION get_physical_workplace( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE is + +begin + return get_physical_workplace(ain_worker_id, SYSDATE); +end get_physical_workplace; + + +FUNCTION get_row( +air_physical_assignment in PHYSICAL_ASSIGNMENT_T%ROWTYPE) +return PHYSICAL_ASSIGNMENT_T%ROWTYPE is + +r_physical_assignment PHYSICAL_ASSIGNMENT_T%ROWTYPE; + +begin + if air_physical_assignment.id is not NULL then + -- retrieve the row by the primary key + select * + into r_physical_assignment + from PHYSICAL_ASSIGNMENT_T + where id = air_physical_assignment.id; + else + -- retrieve the row by the worker_id and active_date + select * + into r_physical_assignment + from PHYSICAL_ASSIGNMENT_T + where worker_id = air_physical_assignment.worker_id + and active_date = air_physical_assignment.active_date; + end if; + return r_physical_assignment; +exception + when NO_DATA_FOUND then + raise; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select PHYSICAL_ASSIGNMENT_T'|| + ' in PHYSICAL_ASSIGNMENT_TS.get_row()'); +end get_row; + + +PROCEDURE help is + +begin + TEXT_HELP.process('PHYSICAL_ASSIGNMENT_TS'); +end help; + + +FUNCTION is_active( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in date) +return boolean is + +n_count number; + +begin + select count(1) + into n_count + from PHYSICAL_ASSIGNMENT_T + where worker_id = ain_worker_id + and aid_on between active_date + and nvl(inactive_date, DATES.d_MAX); + + if nvl(n_count,0) > 0 then + return TRUE; + else + return FALSE; + end if; +end is_active; + + +FUNCTION is_active( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE) +return boolean is + +begin + return is_active(ain_worker_id, SYSDATE); +end is_active; + + +FUNCTION is_history( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_active_date in PHYSICAL_ASSIGNMENT_T.active_date%TYPE, +aid_inactive_date in PHYSICAL_ASSIGNMENT_T.inactive_date%TYPE) +return boolean is + +pragma autonomous_transaction; + +n_count number; + +begin + select count(1) + into n_count + from PHYSICAL_ASSIGNMENT_T + where worker_id = ain_worker_id + and active_date <= + nvl(aid_inactive_date, DATES.d_MAX) + and nvl(inactive_date, DATES.d_MAX) >= aid_active_date; + commit; + + if nvl(n_count,0) > 0 then + return TRUE; + else + return FALSE; + end if; +end is_history; + + +PROCEDURE set_row( +aior_physical_assignment in out PHYSICAL_ASSIGNMENT_T%ROWTYPE) is + +d_null constant date := DATES.d_MIN; +n_null constant number := 0; +v_null constant varchar2(1) := ' '; +r_physical_assignment PHYSICAL_ASSIGNMENT_T%ROWTYPE; + +begin + -- get the existing row + begin + r_physical_assignment := get_row(aior_physical_assignment); + exception + when NO_DATA_FOUND then + r_physical_assignment := NULL; + end; + -- if a row exists, update it if needed + if r_physical_assignment.id is not NULL then + aior_physical_assignment.id := r_physical_assignment.id; + aior_physical_assignment.worker_id := r_physical_assignment.worker_id; + aior_physical_assignment.active_date := r_physical_assignment.active_date; + if nvl(r_physical_assignment.physical_workplace_id, n_null) <> nvl(aior_physical_assignment.physical_workplace_id, n_null) or + nvl(r_physical_assignment.inactive_date, d_null) <> nvl(aior_physical_assignment.inactive_date, d_null) then + begin + update PHYSICAL_ASSIGNMENT_T + set physical_workplace_id = aior_physical_assignment.physical_workplace_id, + inactive_date = aior_physical_assignment.inactive_date + where id = aior_physical_assignment.id; + + n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20002, SQLERRM|| + ' on update PHYSICAL_ASSIGNMENT_T'|| + ' in PHYSICAL_ASSIGNMENT_TS.set_row()' ); + end; + end if; + else + -- add the row if it does not exist + begin + if aior_physical_assignment.id is NULL then + aior_physical_assignment.id := get_id(); + end if; + insert into PHYSICAL_ASSIGNMENT_T ( + id, + worker_id, + physical_workplace_id, + active_date, + inactive_date ) + values ( + aior_physical_assignment.id, + aior_physical_assignment.worker_id, + aior_physical_assignment.physical_workplace_id, + aior_physical_assignment.active_date, + aior_physical_assignment.inactive_date ); + + n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20003, SQLERRM|| + ' on insert PHYSICAL_ASSIGNMENT_T'|| + ' in PHYSICAL_ASSIGNMENT_TS.set_row()' ); + end; + end if; +end set_row; + + +PROCEDURE test is + +n_physical_workplace_id PHYSICAL_WORKPLACE_T.id%TYPE; +n_physical_workplace_id_1 PHYSICAL_WORKPLACE_T.id%TYPE; +n_physical_workplace_id_2 PHYSICAL_WORKPLACE_T.id%TYPE; +n_worker_id WORKER_T.id%TYPE; +n_worker_id_1 WORKER_T.id%TYPE; +n_worker_id_2 WORKER_T.id%TYPE; +r_worker WORKER_T%ROWTYPE; +r_physical_workplace PHYSICAL_WORKPLACE_T%ROWTYPE; +r_physical_assignment PHYSICAL_ASSIGNMENT_T%ROWTYPE; + +begin + pl('PHYSICAL_ASSIGNMENT_TS.test()'); + + TEST_TS.clear('PHYSICAL_ASSIGNMENT_TS'); + + -- In order to make entries into an Intersection table + -- you first have to have entries in the two tables + -- for which an entry will create an intersection + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'DELETE', 0, + 'Delete existing test entries from PHYSICAL_ASSIGNMENT_T'); + begin + delete PHYSICAL_ASSIGNMENT_T + where physical_workplace_id in ( + select physical_workplace_id + from PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ) ); + + delete PHYSICAL_ASSIGNMENT_T + where worker_id in ( + select worker_id + from WORKER_T + where external_id in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ) ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'DELETE', 1, + 'Delete existing test entries from PHYSICAL_WORKPLACE_T'); + begin + delete PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ); + + delete PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30 ); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'DELETE', 2, + 'Delete existing test entries from WORKER_T'); + begin + delete WORKER_T + where external_id in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'INSERT', 3, + 'Insert WORKER_T test entries using set_row()'); + begin + r_worker.id := WORKER_TS.get_id(); + r_worker.worker_type_id := WORKER_TYPE_TS.get_id('E'); + r_worker.external_id := TEST_TS.v_TEST_30; + r_worker.first_name := TEST_TS.v_TEST_30; + r_worker.middle_name := TEST_TS.v_TEST_30; + r_worker.last_name := TEST_TS.v_TEST_30; + r_worker.name := WORKER_TS.get_formatted_name( + r_worker.first_name, + r_worker.middle_name, + r_worker.last_name); + r_worker.birth_date := to_date('19800101', 'YYYYMMDD'); + r_worker.gender_id := GENDER_TS.get_id('M'); + WORKER_TS.set_row(r_worker); + n_worker_id := r_worker.id; + + r_worker.id := WORKER_TS.get_id(); + r_worker.worker_type_id := WORKER_TYPE_TS.get_id('E'); + r_worker.external_id := TEST_TS.v_TEST_30_1; + r_worker.first_name := TEST_TS.v_TEST_30_1; + r_worker.middle_name := TEST_TS.v_TEST_30_1; + r_worker.last_name := TEST_TS.v_TEST_30_1; + r_worker.name := WORKER_TS.get_formatted_name( + r_worker.first_name, + r_worker.middle_name, + r_worker.last_name); + r_worker.birth_date := to_date('19700101', 'YYYYMMDD'); + r_worker.gender_id := GENDER_TS.get_id('F'); + WORKER_TS.set_row(r_worker); + n_worker_id_1 := r_worker.id; + + r_worker.id := WORKER_TS.get_id(); + r_worker.worker_type_id := WORKER_TYPE_TS.get_id('C'); + r_worker.external_id := TEST_TS.v_TEST_30_2; + r_worker.first_name := TEST_TS.v_TEST_30_2; + r_worker.middle_name := TEST_TS.v_TEST_30_2; + r_worker.last_name := TEST_TS.v_TEST_30_2; + r_worker.name := WORKER_TS.get_formatted_name( + r_worker.first_name, + r_worker.middle_name, + r_worker.last_name); + r_worker.birth_date := to_date('19600101', 'YYYYMMDD'); + r_worker.gender_id := GENDER_TS.get_id('M'); + WORKER_TS.set_row(r_worker); + n_worker_id_2 := r_worker.id; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'INSERT', 4, + 'Insert PHYSICAL_WORKPLACE_T test entries using set_row()'); + begin + r_physical_workplace.id := + PHYSICAL_WORKPLACE_TS.get_id(); + r_physical_workplace.parent_id := NULL; + r_physical_workplace.id_context := + PHYSICAL_WORKPLACE_TS.create_id_context( + r_physical_workplace.parent_id, + r_physical_workplace.id); + r_physical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('C'); + r_physical_workplace.code := TEST_TS.v_TEST_30; + r_physical_workplace.name := TEST_TS.v_TEST_80; + r_physical_workplace.active_date := TEST_TS.d_TEST_19000101; + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + n_physical_workplace_id := + r_physical_workplace.id; + + r_physical_workplace.id := + PHYSICAL_WORKPLACE_TS.get_id(); + r_physical_workplace.parent_id := + n_physical_workplace_id; + r_physical_workplace.id_context := + PHYSICAL_WORKPLACE_TS.create_id_context( + r_physical_workplace.parent_id, + r_physical_workplace.id); + r_physical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('B'); + r_physical_workplace.code := TEST_TS.v_TEST_30_1; + r_physical_workplace.name := TEST_TS.v_TEST_80; + r_physical_workplace.active_date := TEST_TS.d_TEST_19000101; + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + n_physical_workplace_id_1 := + r_physical_workplace.id; + + r_physical_workplace.id := + PHYSICAL_WORKPLACE_TS.get_id(); + r_physical_workplace.parent_id := + n_physical_workplace_id; + r_physical_workplace.id_context := + PHYSICAL_WORKPLACE_TS.create_id_context( + r_physical_workplace.parent_id, + r_physical_workplace.id); + r_physical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('B'); + r_physical_workplace.code := TEST_TS.v_TEST_30_2; + r_physical_workplace.name := TEST_TS.v_TEST_80; + r_physical_workplace.active_date := TEST_TS.d_TEST_19000101; + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + n_physical_workplace_id_2 := + r_physical_workplace.id; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Now that I have entries in the two tables being intersected + -- I can now start testing this package... + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'get_id()', 5, + 'Allocate the next primary key value using get_id()'); + begin + r_physical_assignment.id := + PHYSICAL_ASSIGNMENT_TS.get_id(); + + if nvl(r_physical_assignment.id, 0) > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'set_row()', 6, + 'Insert history for v_TEST_30 using set_row()'); + begin + r_physical_assignment.worker_id := n_worker_id; + r_physical_assignment.physical_workplace_id := + n_physical_workplace_id_2; + r_physical_assignment.active_date := + to_date('20000101', 'YYYYMMDD'); + r_physical_assignment.inactive_date := NULL; + PHYSICAL_ASSIGNMENT_TS.set_row(r_physical_assignment); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'set_row()', 7, + 'Insert history for V_TEST_30_1 using set_row()'); + begin + r_physical_assignment.id := + PHYSICAL_ASSIGNMENT_TS.get_id(); + r_physical_assignment.worker_id := n_worker_id_1; + r_physical_assignment.physical_workplace_id := + n_physical_workplace_id_1; + r_physical_assignment.active_date := + to_date('19900101', 'YYYYMMDD'); + r_physical_assignment.inactive_date := + to_date('19991231', 'YYYYMMDD'); + PHYSICAL_ASSIGNMENT_TS.set_row(r_physical_assignment); + + r_physical_assignment.id := + PHYSICAL_ASSIGNMENT_TS.get_id(); + r_physical_assignment.worker_id := n_worker_id_1; + r_physical_assignment.physical_workplace_id := + n_physical_workplace_id_2; + r_physical_assignment.active_date := + to_date('20000101', 'YYYYMMDD'); + r_physical_assignment.inactive_date := NULL; + PHYSICAL_ASSIGNMENT_TS.set_row(r_physical_assignment); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'set_row()', 8, + 'Insert history for V_TEST_30_2 using set_row()'); + begin + r_physical_assignment.id := + PHYSICAL_ASSIGNMENT_TS.get_id(); + r_physical_assignment.worker_id := n_worker_id_2; + r_physical_assignment.physical_workplace_id := + n_physical_workplace_id_1; + r_physical_assignment.active_date := + to_date('19800101', 'YYYYMMDD'); + r_physical_assignment.inactive_date := + to_date('19891231', 'YYYYMMDD'); + PHYSICAL_ASSIGNMENT_TS.set_row(r_physical_assignment); + + r_physical_assignment.id := + PHYSICAL_ASSIGNMENT_TS.get_id(); + r_physical_assignment.worker_id := n_worker_id_2; + r_physical_assignment.physical_workplace_id := + n_physical_workplace_id_2; + r_physical_assignment.active_date := + to_date('19900101', 'YYYYMMDD'); + r_physical_assignment.inactive_date := + to_date('19901231', 'YYYYMMDD'); + PHYSICAL_ASSIGNMENT_TS.set_row(r_physical_assignment); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Commit the deletes and inserts + commit; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', + 'get_physical_workplace()', 9, + 'Get the current physical workplace for v_TEST_30'); + begin + r_physical_workplace := NULL; + r_physical_workplace := get_physical_workplace(n_worker_id); + + if nvl(r_physical_workplace.id, 0) > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', + 'get_physical_workplace()', 10, + 'Get the physical workplace on 6/30/1995 for v_TEST_30_1'); + begin + r_physical_workplace := NULL; + r_physical_workplace := get_physical_workplace( + n_worker_id_1, + to_date('19950630', 'YYYYMMDD')); + + if nvl(r_physical_workplace.id, 0) > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', + 'get_physical_workplace()', 11, + 'Get the physical workplace on 6/30/1995 for v_TEST_30_2'); + begin + -- this should fail + r_physical_workplace := NULL; + r_physical_workplace := get_physical_workplace( + n_worker_id_2, + to_date('19950630', 'YYYYMMDD')); + + if nvl(r_physical_workplace.id, 0) > 0 then + TEST_TS.error(); + else + TEST_TS.ok(); + end if; + exception + when NO_DATA_FOUND then + TEST_TS.ok(); + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'help()', 12, + 'Test help()'); + begin + help(); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'is_active()', 13, + 'Is there an active assignment on 6/30/1995 for v_TEST_30?'); + -- No + begin + if is_active(n_worker_id, to_date('19950630', 'YYYYMMDD')) then + TEST_TS.error(); + else + TEST_TS.ok(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'is_active()', 14, + 'Is there an active assignment on 6/30/1995 for v_TEST_30_1?'); + -- Yes + begin + if is_active(n_worker_id_1, to_date('19950630', 'YYYYMMDD')) then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'is_active()', 15, + 'Is there currently an active assignment for v_TEST_30_2?'); + -- No + begin + if is_active(n_worker_id_2) then + TEST_TS.error(); + else + TEST_TS.ok(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Now clean up after the tests by deleting the test entries + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'DELETE', 16, + 'Delete existing test entries from PHYSICAL_ASSIGNMENT_T'); + begin + delete PHYSICAL_ASSIGNMENT_T + where physical_workplace_id in ( + select physical_workplace_id + from PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ) ); + + delete PHYSICAL_ASSIGNMENT_T + where worker_id in ( + select worker_id + from WORKER_T + where external_id in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ) ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'DELETE', 17, + 'Delete existing test entries from PHYSICAL_WORKPLACE_T'); + begin + delete PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ); + + delete PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30 ); + + TEST_TS.ok; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', 'DELETE', 18, + 'Delete existing test entries from WORKER_T'); + begin + delete WORKER_T + where external_id in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2 ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + commit; + TEST_TS.set_test('PHYSICAL_ASSIGNMENT_TS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end PHYSICAL_ASSIGNMENT_TS; +/ +@be.sql PHYSICAL_ASSIGNMENT_TS diff --git a/Chapter10/physical_assignment_ts.pks b/Chapter10/physical_assignment_ts.pks new file mode 100644 index 0000000..a70f463 --- /dev/null +++ b/Chapter10/physical_assignment_ts.pks @@ -0,0 +1,92 @@ +create or replace PACKAGE PHYSICAL_ASSIGNMENT_TS as +/* +physical_assignment_ts.pks +Copyright by Donald J. Bales on 12/15/2006 +Table PHYSICAL_ASSIGNMENT_T's methods +*/ + +-- GLOBAL VARIABLES +-- Keep track of the number of inserts and updates to made by set_row(). +n_inserted number := 0; +n_updated number := 0; + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return PHYSICAL_ASSIGNMENT_T.id%TYPE; + +/* +Returns a the PHYSICAL_WORKPLACE row for the specified worker_id and on the specified date. +*/ +FUNCTION get_physical_workplace( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in PHYSICAL_ASSIGNMENT_T.active_date%TYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE; + +/* +Returns a the current PHYSICAL_WORKPLACE row for the specified worker_id. +*/ +FUNCTION get_physical_workplace( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE; + +/* +Returns a PHYSICAL_ASSIGNMENT row for the specified criteria. +
+There are two sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the woker_id and active_date
+
+If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_physical_assignment in PHYSICAL_ASSIGNMENT_T%ROWTYPE) +return PHYSICAL_ASSIGNMENT_T%ROWTYPE; + +/* + Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + +/* +Returns TRUE if the worker has a physical assignment on the specified date, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE, +aid_on in date) +return boolean; + +/* +Returns TRUE if the worker currently has a physical assignment, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in PHYSICAL_ASSIGNMENT_T.worker_id%TYPE) +return boolean; + +/* +Updates or inserts a row matching the passed row into table PHYSICAL_WORKPLACE_T. +
+First, set_row( ) calls get_row( ) to try to find a matching row that already +exists in the database. So you need to set the id, or worked_id +and active_date appropriately in order to properly detect an existing row.
+
+Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise a new row is inserted, including the allocation of +a new primary key value. Upon inserting a new value, the id +value is updated in the passed row.
+See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_physical_assignment in out PHYSICAL_ASSIGNMENT_T%ROWTYPE); + +/* +The test unit for this package. +*/ +PROCEDURE test; + + +end PHYSICAL_ASSIGNMENT_TS; +/ +@be.sql PHYSICAL_ASSIGNMENT_TS diff --git a/Chapter10/physical_workplace_t.ins b/Chapter10/physical_workplace_t.ins new file mode 100644 index 0000000..8aef046 --- /dev/null +++ b/Chapter10/physical_workplace_t.ins @@ -0,0 +1,228 @@ +rem physical_workplace_t.ins +rem by Donald J. Bales on 12/15/2006 +rem Seed the PHYSICAL_WORKPLACE_T table + +declare + +-- S=Site, L=Line, M=Machine +n_WT_line WORKPLACE_TYPE_T.id%TYPE; +n_WT_machine WORKPLACE_TYPE_T.id%TYPE; +n_WT_site WORKPLACE_TYPE_T.id%TYPE; + +n_parent_id_line PHYSICAL_WORKPLACE_T.parent_id%TYPE; +n_parent_id_site PHYSICAL_WORKPLACE_T.parent_id%TYPE; + +r_physical_workplace PHYSICAL_WORKPLACE_T%ROWTYPE; + +begin + n_WT_line := WORKPLACE_TYPE_TS.get_id('L'); + n_WT_machine := WORKPLACE_TYPE_TS.get_id('M'); + n_WT_site := WORKPLACE_TYPE_TS.get_id('S'); + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_site; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := NULL; + r_physical_workplace.code := 'NNJ'; + r_physical_workplace.name := 'NEWARK, NJ, USA'; + r_physical_workplace.active_date := to_date('19600101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + + n_parent_id_site := r_physical_workplace.id; + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_line; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_site; + r_physical_workplace.code := 'CHEM'; + r_physical_workplace.name := 'CHEMICALS'; + r_physical_workplace.active_date := to_date('19600101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + + n_parent_id_line := r_physical_workplace.id; + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_machine; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_line; + r_physical_workplace.code := 'MIX1'; + r_physical_workplace.name := 'MIXER 1'; + r_physical_workplace.active_date := to_date('19600101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_machine; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_line; + r_physical_workplace.code := 'DIS1'; + r_physical_workplace.name := 'DISTILLER 1'; + r_physical_workplace.active_date := to_date('19600101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_line; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_site; + r_physical_workplace.code := 'METL'; + r_physical_workplace.name := 'METALS'; + r_physical_workplace.active_date := to_date('19600101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + n_parent_id_line := r_physical_workplace.id; + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_machine; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_line; + r_physical_workplace.code := 'SEP1'; + r_physical_workplace.name := 'SEPERATOR 1'; + r_physical_workplace.active_date := to_date('19600101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_machine; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_line; + r_physical_workplace.code := 'CRS1'; + r_physical_workplace.name := 'CRUSHER 1'; + r_physical_workplace.active_date := to_date('19600101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_site; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := NULL; + r_physical_workplace.code := 'GIN'; + r_physical_workplace.name := 'GARY, IN, USA'; + r_physical_workplace.active_date := to_date('19640101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + + n_parent_id_site := r_physical_workplace.id; + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_line; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_site; + r_physical_workplace.code := 'DISP'; + r_physical_workplace.name := 'DISPOSABLES'; + r_physical_workplace.active_date := to_date('19640101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + + n_parent_id_line := r_physical_workplace.id; + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_machine; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_line; + r_physical_workplace.code := 'SEP2'; + r_physical_workplace.name := 'SEPERATOR 2'; + r_physical_workplace.active_date := to_date('19640101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_machine; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_line; + r_physical_workplace.code := 'CRS2'; + r_physical_workplace.name := 'CRUSHER 2'; + r_physical_workplace.active_date := to_date('19640101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_line; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_site; + r_physical_workplace.code := 'RUSE'; + r_physical_workplace.name := 'REUSABLES'; + r_physical_workplace.active_date := to_date('19640101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + n_parent_id_line := r_physical_workplace.id; + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_machine; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_line; + r_physical_workplace.code := 'SEP3'; + r_physical_workplace.name := 'SEPERATOR 3'; + r_physical_workplace.active_date := to_date('19640101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_machine; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_line; + r_physical_workplace.code := 'CRS3'; + r_physical_workplace.name := 'CRUSHER 3'; + r_physical_workplace.active_date := to_date('19640101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_site; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := NULL; + r_physical_workplace.code := 'LCA'; + r_physical_workplace.name := 'LOS ANGELES, CA, USA'; + r_physical_workplace.active_date := to_date('19680101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + n_parent_id_line := r_physical_workplace.id; + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_machine; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_line; + r_physical_workplace.code := 'GRV1'; + r_physical_workplace.name := 'GRAVITRON 1'; + r_physical_workplace.active_date := to_date('19720101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_machine; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_line; + r_physical_workplace.code := 'DST2'; + r_physical_workplace.name := 'DISTILLER 2'; + r_physical_workplace.active_date := to_date('19720101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + r_physical_workplace.id := NULL; + r_physical_workplace.workplace_type_id := n_WT_machine; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := n_parent_id_line; + r_physical_workplace.code := 'INC1'; + r_physical_workplace.name := 'INCINERATOR 1'; + r_physical_workplace.active_date := to_date('19640101', 'YYYYMMDD'); + r_physical_workplace.inactive_date := NULL; + PHYSICAL_WORKPLACE_TS.set_row(r_physical_workplace); + + commit; +end; +/ + \ No newline at end of file diff --git a/Chapter10/physical_workplace_ts.pkb b/Chapter10/physical_workplace_ts.pkb new file mode 100644 index 0000000..1f74e5f --- /dev/null +++ b/Chapter10/physical_workplace_ts.pkb @@ -0,0 +1,566 @@ +create or replace PACKAGE BODY PHYSICAL_WORKPLACE_TS as +/* +physical_workplace_ts.pkb +by Donald J. Bales on 12/15/2006 +Table PHYSICAL_WORKPLACE_T's methods +*/ + + +FUNCTION create_id_context( +ain_parent_id in PHYSICAL_WORKPLACE_T.parent_id%TYPE, +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +v_id_context PHYSICAL_WORKPLACE_T.id_context%TYPE; + +begin + v_id_context := get_id_context(ain_parent_id); + + if v_id_context is not NULL then + return substr(v_id_context||'.'||to_char(ain_id), 1, 2000); + else + return to_char(ain_id); + end if; +end create_id_context; + + +FUNCTION get_code_context( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +cursor c_code_context( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) is +select upper(code) code +from PHYSICAL_WORKPLACE_T +connect by prior parent_id = id +start with id = ain_id +order by level desc; + +v_code_context varchar2(2000); + +begin + for r_code_context in c_code_context(ain_id) loop + v_code_context := substr(v_code_context||'.'||r_code_context.code, 1, 2000); + end loop; + return v_code_context; +end get_code_context; + + +FUNCTION get_id +return PHYSICAL_WORKPLACE_T.id%TYPE is + +n_id PHYSICAL_WORKPLACE_T.id%TYPE; + +begin + select PHYSICAL_WORKPLACE_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_id_context( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +v_id_context PHYSICAL_WORKPLACE_T.id_context%TYPE; + +begin + if ain_id is not NULL then + select id_context + into v_id_context + from PHYSICAL_WORKPLACE_T + where id = ain_id; + end if; + + return v_id_context; +end get_id_context; + + +FUNCTION get_name_context( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2 is + +cursor c_name_context( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) is +select initcap(name) name +from PHYSICAL_WORKPLACE_T +connect by prior parent_id = id +start with id = ain_id +order by level desc; + +v_name_context varchar2(2000); + +begin + for r_name_context in c_name_context(ain_id) loop + v_name_context := substr(v_name_context||'.'||r_name_context.name, 1, 2000); + end loop; + return v_name_context; +end get_name_context; + + +FUNCTION get_row( +air_physical_workplace in PHYSICAL_WORKPLACE_T%ROWTYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE is + +r_physical_workplace PHYSICAL_WORKPLACE_T%ROWTYPE; + +begin + if air_physical_workplace.id is not NULL then + --pl('retrieve the row by the primary key'); + select * + into r_physical_workplace + from PHYSICAL_WORKPLACE_T + where id = air_physical_workplace.id; + elsif air_physical_workplace.id_context is not NULL then + --pl('retrieve the row by the id_context unique key'); + select * + into r_physical_workplace + from PHYSICAL_WORKPLACE_T + where id_context = air_physical_workplace.id_context; + else + --pl('retrieve the row by the code, name, and active_date'); + select * + into r_physical_workplace + from PHYSICAL_WORKPLACE_T + where code = air_physical_workplace.code + and name = air_physical_workplace.name + and active_date = air_physical_workplace.active_date; + end if; + return r_physical_workplace; +exception + when NO_DATA_FOUND then + raise; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select PHYSICAL_WORKPLACE_T'|| + ' in PHYSICAL_WORKPLACE_TS.get_row()'); +end get_row; + + +PROCEDURE inactivate( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE, +aid_inactive_date in PHYSICAL_WORKPLACE_T.inactive_date%TYPE) is + +begin + update PHYSICAL_WORKPLACE_T + set inactive_date = aid_inactive_date + where id = ain_id; +end inactivate; + + +FUNCTION is_duplicate( +aiv_code in PHYSICAL_WORKPLACE_T.code%TYPE, +aiv_name in PHYSICAL_WORKPLACE_T.name%TYPE, +aid_active_date in PHYSICAL_WORKPLACE_T.active_date%TYPE) +return boolean is + +n_count number; + +begin + --pl('retrieve the row by the code, name, and active_date'); + select count(1) + into n_count + from PHYSICAL_WORKPLACE_T + where code = aiv_code + and name = aiv_name + and trunc(active_date) = trunc(aid_active_date); + + if nvl(n_count, 0) > 0 then + return TRUE; + else + return FALSE; + end if; +end is_duplicate; + + +FUNCTION set_row( +ain_parent_id in PHYSICAL_WORKPLACE_T.parent_id%TYPE, +ain_workplace_type_id in PHYSICAL_WORKPLACE_T.workplace_type_id%TYPE, +aiv_code in PHYSICAL_WORKPLACE_T.code%TYPE, +aiv_name in PHYSICAL_WORKPLACE_T.name%TYPE, +aid_active_date in PHYSICAL_WORKPLACE_T.active_date%TYPE) +return PHYSICAL_WORKPLACE_T.id%TYPE is + +r_physical_workplace PHYSICAL_WORKPLACE_T%ROWTYPE; + +begin + r_physical_workplace.id := NULL; + r_physical_workplace.id_context := NULL; + r_physical_workplace.parent_id := ain_parent_id; + r_physical_workplace.workplace_type_id := ain_workplace_type_id; + r_physical_workplace.code := aiv_code; + r_physical_workplace.name := aiv_name; + r_physical_workplace.active_date := aid_active_date; + set_row(r_physical_workplace); + + return r_physical_workplace.id; +end set_row; + + +-- PROCEDURES + +PROCEDURE help is + +begin + TEXT_HELP.process('PHYSICAL_WORKPLACE_TS'); +end help; + + +PROCEDURE set_row( +aior_physical_workplace in out PHYSICAL_WORKPLACE_T%ROWTYPE) is + +d_null constant date := DATES.d_MIN; +n_null constant number := 0; +v_null constant varchar2(1) := ' '; +r_physical_workplace PHYSICAL_WORKPLACE_T%ROWTYPE; + +begin + -- get the existing row + begin + r_physical_workplace := get_row(aior_physical_workplace); + exception + when NO_DATA_FOUND then + r_physical_workplace := NULL; + end; + -- if a row exists, update it if needed + if r_physical_workplace.id is not NULL then + aior_physical_workplace.id := r_physical_workplace.id; + aior_physical_workplace.parent_id := r_physical_workplace.parent_id; + aior_physical_workplace.id_context := r_physical_workplace.id_context; + if nvl(r_physical_workplace.workplace_type_id, n_null) <> nvl(aior_physical_workplace.workplace_type_id, n_null) or + nvl(r_physical_workplace.code, v_null) <> nvl(aior_physical_workplace.code, v_null) or + nvl(r_physical_workplace.name, v_null) <> nvl(aior_physical_workplace.name, v_null) or + nvl(r_physical_workplace.active_date, d_null) <> nvl(aior_physical_workplace.active_date, d_null) or + nvl(r_physical_workplace.inactive_date, d_null) <> nvl(aior_physical_workplace.inactive_date, d_null) then + begin + update PHYSICAL_WORKPLACE_T + set workplace_type_id = aior_physical_workplace.workplace_type_id, + code = aior_physical_workplace.code, + name = aior_physical_workplace.name, + active_date = aior_physical_workplace.active_date, + inactive_date = aior_physical_workplace.inactive_date + where id = aior_physical_workplace.id; + + n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20002, SQLERRM|| + ' on update PHYSICAL_WORKPLACE_T'|| + ' in PHYSICAL_WORKPLACE_TS.set_row()' ); + end; + end if; + else + -- add the row if it does not exist + begin + if aior_physical_workplace.id is NULL then + aior_physical_workplace.id := get_id(); + end if; + aior_physical_workplace.id_context := + create_id_context( + aior_physical_workplace.parent_id, + aior_physical_workplace.id ); + insert into PHYSICAL_WORKPLACE_T ( + id, + parent_id, + id_context, + workplace_type_id, + code, + name, + active_date, + inactive_date ) + values ( + aior_physical_workplace.id, + aior_physical_workplace.parent_id, + aior_physical_workplace.id_context, + aior_physical_workplace.workplace_type_id, + aior_physical_workplace.code, + aior_physical_workplace.name, + aior_physical_workplace.active_date, + aior_physical_workplace.inactive_date ); + + n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20003, SQLERRM|| + ' on insert PHYSICAL_WORKPLACE_T'|| + ' in PHYSICAL_WORKPLACE_TS.set_row()' ); + end; + end if; +end set_row; + + +PROCEDURE test is + +v_id_context PHYSICAL_WORKPLACE_T.id_context%TYPE; +r_physical_workplace PHYSICAL_WORKPLACE_T%ROWTYPE; + +begin + pl('PHYSICAL_WORKPLACE_TS.test()'); + + TEST_TS.clear('PHYSICAL_WORKPLACE_TS'); + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'DELETE', 0, + 'Delete existing test entries'); + begin + delete PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + + delete PHYSICAL_WORKPLACE_T + where code = TEST_TS.v_TEST_30; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'get_id()', 1, + 'Allocate the next primary key value'); + begin + r_physical_workplace.id := get_id(); + + if r_physical_workplace.id > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', + 'create_id_context()', 2, 'Create an ID context value'); + begin + r_physical_workplace.parent_id := NULL; + r_physical_workplace.id_context := + create_id_context( + r_physical_workplace.parent_id, + r_physical_workplace.id); + + if r_physical_workplace.id_context = + to_char(r_physical_workplace.id) then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'set_row()', 3, + 'Insert parent test entry'); + begin + r_physical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('C'); + r_physical_workplace.code := + TEST_TS.v_TEST_30; + r_physical_workplace.name := + TEST_TS.v_TEST_80; + r_physical_workplace.active_date := + TEST_TS.d_TEST_19000101; + r_physical_workplace.inactive_date := NULL; + set_row(r_physical_workplace); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'set_row()', 4, + 'Insert child entries'); + begin + r_physical_workplace.parent_id := + r_physical_workplace.id; + r_physical_workplace.id := get_id(); + r_physical_workplace.id_context := + create_id_context( + r_physical_workplace.parent_id, + r_physical_workplace.id); + -- save this value for testing get_row() + v_id_context := + r_physical_workplace.id_context; + r_physical_workplace.workplace_type_id := + WORKPLACE_TYPE_TS.get_id('B'); + r_physical_workplace.code := + TEST_TS.v_TEST_30_1; + r_physical_workplace.name := + TEST_TS.v_TEST_80; + set_row(r_physical_workplace); + + + r_physical_workplace.id := get_id(); + r_physical_workplace.id_context := + create_id_context( + r_physical_workplace.parent_id, + r_physical_workplace.id); + r_physical_workplace.code := + TEST_TS.v_TEST_30_2; + set_row(r_physical_workplace); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'get_code_context()', 5, + 'Get the code context for v_TEST_30_2'); + begin + pl(get_code_context( + r_physical_workplace.id)); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'get_name_context()', 6, + 'Get the name context for v_TEST_30_2'); + begin + pl(get_name_context( + r_physical_workplace.id)); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'get_row()', 7, + 'Get the row using the id for v_TEST_30_2'); + begin +-- r_physical_workplace.id := NULL; + r_physical_workplace.parent_id := NULL; + r_physical_workplace.id_context := NULL; + r_physical_workplace.workplace_type_id := NULL; + r_physical_workplace.code := NULL; + r_physical_workplace.name := NULL; + r_physical_workplace.active_date := NULL; + r_physical_workplace.inactive_date := NULL; + + r_physical_workplace := get_row(r_physical_workplace); + + if r_physical_workplace.id_context is not NULL then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'get_row()', 8, + 'Get the row using the id_context for v_TEST_30_1'); + begin + r_physical_workplace.id := NULL; + r_physical_workplace.parent_id := NULL; + r_physical_workplace.id_context := + v_id_context; + r_physical_workplace.workplace_type_id := NULL; + r_physical_workplace.code := NULL; + r_physical_workplace.name := NULL; + r_physical_workplace.active_date := NULL; + r_physical_workplace.inactive_date := NULL; + + r_physical_workplace := get_row(r_physical_workplace); + + if r_physical_workplace.id is not NULL then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + pl('v_id_context="'||v_id_context||'"'); + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'get_row()', 9, + 'Get the row using the code for v_TEST_30'); + begin + r_physical_workplace.id := NULL; + r_physical_workplace.parent_id := NULL; + r_physical_workplace.id_context := NULL; + r_physical_workplace.workplace_type_id := NULL; + r_physical_workplace.code := + TEST_TS.v_TEST_30; + r_physical_workplace.name := + TEST_TS.v_TEST_80; + r_physical_workplace.active_date := + TEST_TS.d_TEST_19000101; + r_physical_workplace.inactive_date := NULL; + + r_physical_workplace := get_row(r_physical_workplace); + + if r_physical_workplace.id is not NULL then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'help()', 10, + 'Display the help text'); + begin + help(); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'is_duplicate()', 11, + 'Is this a duplicate? It should be!'); + begin + if is_duplicate( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101) then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', 'DELETE', 12, + 'Delete test entries'); + begin + delete PHYSICAL_WORKPLACE_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + + delete PHYSICAL_WORKPLACE_T + where code = TEST_TS.v_TEST_30; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + commit; + TEST_TS.set_test('PHYSICAL_WORKPLACE_TS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end PHYSICAL_WORKPLACE_TS; +/ +@be.sql PHYSICAL_WORKPLACE_TS diff --git a/Chapter10/physical_workplace_ts.pks b/Chapter10/physical_workplace_ts.pks new file mode 100644 index 0000000..d30c857 --- /dev/null +++ b/Chapter10/physical_workplace_ts.pks @@ -0,0 +1,114 @@ +create or replace PACKAGE PHYSICAL_WORKPLACE_TS as +/* +physical_workplace_ts.pks
+Copyright by Don Bales on 12/15/2006
+Table PHYSICAL_WORKPLACE_T's methods. Contains all the supporting service +methods (functions and procedures) for table PHYSICAL_WORKPLACE_T. +*/ + +-- GLOBAL VARIABLES + +-- Keep track of the number of inserts and updates to made by set_row( ). +n_inserted number := 0; +n_updated number := 0; + + +/* +Returns an id_context for the specified parent_id and id. +Whatever creates a new row must also call this mehtod to create an appropriate +id_context value. Method set_row() does this for you. +*/ +FUNCTION create_id_context( +ain_parent_id in PHYSICAL_WORKPLACE_T.parent_id%TYPE, +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns the value of a context for the code values in the physical workplace assignment. +*/ +FUNCTION get_code_context( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return PHYSICAL_WORKPLACE_T.id%TYPE; + +/* +Returns the value of a context for the id values in the logical workplace assignment. +*/ +FUNCTION get_id_context( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns the value of a context for the name values in the physical workplace assignment. +*/ +FUNCTION get_name_context( +ain_id in PHYSICAL_WORKPLACE_T.id%TYPE) +return varchar2; + +/* +Returns a PHYSICAL_WORKPLACE row for the specified criteria. + +There are three sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the unique id_context
+3. the code, name, and active_date
+ +If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_physical_workplace in PHYSICAL_WORKPLACE_T%ROWTYPE) +return PHYSICAL_WORKPLACE_T%ROWTYPE; + + +/* +Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + + +/* +Updates or inserts a row matching the passed parameters into table PHYSICAL_WORKPLACE_T. +See PROCEDURE set_row( ). +*/ +FUNCTION set_row( +ain_parent_id in PHYSICAL_WORKPLACE_T.parent_id%TYPE, +ain_workplace_type_id in PHYSICAL_WORKPLACE_T.workplace_type_id%TYPE, +aiv_code in PHYSICAL_WORKPLACE_T.code%TYPE, +aiv_name in PHYSICAL_WORKPLACE_T.name%TYPE, +aid_active_date in PHYSICAL_WORKPLACE_T.active_date%TYPE) +return PHYSICAL_WORKPLACE_T.id%TYPE; + + +/* +Updates or inserts a row matching the passed row into table PHYSICAL_WORKPLACE_T. + +First, set_row() calls get row to try to find a matching row that already +exists in the database. So you need to set the id, id_context, +and code, name and active_date appropriately in order to prperly detect an +existing row. + +Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise, and new row is inserted, including the allocation of +a new primary key and id_context value. Upon inserting a new value, the +id and id_context values are updated in the passed row. +See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_physical_workplace in out PHYSICAL_WORKPLACE_T%ROWTYPE); + + +/* +Performs unit tests for this package. +*/ +PROCEDURE test; + + +end PHYSICAL_WORKPLACE_TS; +/ +@se.sql PHYSICAL_WORKPLACE_TS diff --git a/Chapter10/pl.prc b/Chapter10/pl.prc new file mode 100644 index 0000000..10b8e34 --- /dev/null +++ b/Chapter10/pl.prc @@ -0,0 +1,14 @@ +create or replace PROCEDURE pl( +aiv_text in varchar2 ) is +/* +pl.prc +by Donald J. Bales on 12/15/2006 +A wrapper procedure for SYS.DBMS_OUTPUT.put_line() +for the lazy typist. +*/ + +begin + SYS.DBMS_OUTPUT.put_line(aiv_text); +end pl; +/ +@pe.sql pl diff --git a/Chapter10/polling_process.pkb b/Chapter10/polling_process.pkb new file mode 100644 index 0000000..a833de1 --- /dev/null +++ b/Chapter10/polling_process.pkb @@ -0,0 +1,94 @@ +create or replace package body POLLING_PROCESS as +/* +polling_process.pkb +by Donald J. Bales on 12/15/2006 +An example of a polling data processing package +*/ + + +PROCEDURE disable is + +begin + POLLING_PROCESS_QUEUES.disable(); +end disable; + + +PROCEDURE enable is + +begin + POLLING_PROCESS_QUEUES.enable(); +end enable; + + +PROCEDURE process is + +r_polling_process_queue POLLING_PROCESS_QUEUE%ROWTYPE; + +begin + DEBUG_TS.set_text('POLLING_PROCESS', 'Starting'); + + -- perform a manual loop until it recieves a command to quit + loop + DEBUG_TS.set_text('POLLING_PROCESS', 'Getting next command'); + + -- Get the next command from the queue + r_polling_process_queue := + POLLING_PROCESS_QUEUES.get_next(r_polling_process_queue); + + -- If it's time to quit, pool the queue once more to delete + -- the quit command, and then exit + if r_polling_process_queue.command = + POLLING_PROCESS_QUEUES.v_QUIT then + + POLLING_PROCESS_STATUSS.set_status('Quiting'); + + DEBUG_TS.set_text('POLLING_PROCESS', 'Quiting'); + + r_polling_process_queue := + POLLING_PROCESS_QUEUES.get_next(r_polling_process_queue); + exit; + elsif r_polling_process_queue.command = 'DISABLE' then + DEBUG_TS.disable('POLLING_PROCESS'); + elsif r_polling_process_queue.command = 'ENABLE' then + DEBUG_TS.enable('POLLING_PROCESS'); + end if; + + -- *** Now do all your groovy data processing here! *** + + POLLING_PROCESS_STATUSS.set_status('Processing'); + + DEBUG_TS.set_text('POLLING_PROCESS', + 'I''m doing some groovy data processing at '|| + to_char(SYSDATE, 'HH:MI:SS')); + + -- *** End of your groovy data processing section. *** + + POLLING_PROCESS_STATUSS.set_status('Sleeping'); + + DEBUG_TS.set_text('POLLING_PROCESS', 'Sleeping'); + + -- Sleep for 10 seconds + SYS.DBMS_LOCK.sleep(10); + + DEBUG_TS.set_text('POLLING_PROCESS', 'Awake'); + end loop; +end process; + + +PROCEDURE quit is + +begin + POLLING_PROCESS_QUEUES.quit(); +end quit; + + +PROCEDURE status is + +begin + pl(POLLING_PROCESS_STATUSS.get_status); +end status; + + +end POLLING_PROCESS; +/ +@be.sql POLLING_PROCESS diff --git a/Chapter10/polling_process.pks b/Chapter10/polling_process.pks new file mode 100644 index 0000000..cbb6c35 --- /dev/null +++ b/Chapter10/polling_process.pks @@ -0,0 +1,26 @@ +create or replace package POLLING_PROCESS as +/* +polling_process.pks +by Donald J. Bales on 12/15/2006 +An example of a polling data processing package +*/ + + +PROCEDURE enable; + + +PROCEDURE disable; + + +PROCEDURE process; + + +PROCEDURE quit; + + +PROCEDURE status; + + +end POLLING_PROCESS; +/ +@se.sql POLLING_PROCESS diff --git a/Chapter10/polling_process.sql b/Chapter10/polling_process.sql new file mode 100644 index 0000000..939d250 --- /dev/null +++ b/Chapter10/polling_process.sql @@ -0,0 +1,5 @@ +-- Turn the debug log on for this program unit so I can use +-- it to show that this routine actually works. +--execute DEBUG_TS.enable('POLLING_PROCESS'); + +execute POLLING_PROCESS.process; diff --git a/Chapter10/polling_process_queue.tab b/Chapter10/polling_process_queue.tab new file mode 100644 index 0000000..e40d7b6 --- /dev/null +++ b/Chapter10/polling_process_queue.tab @@ -0,0 +1,25 @@ +rem polling_process_queue.tab +rem by Donald J. Bales on 12/15/2006 +rem A table to act as a command queue for a polling process + +execute drop_if_exists('TABLE', 'POLLING_PROCESS_QUEUE'); +create table POLLING_PROCESS_QUEUE ( +id number not null, +command varchar2(256) not null, +insert_user varchar2(30) default USER not null, +insert_date date default SYSDATE not null) +tablespace USERS pctfree 0 +storage (initial 1M next 1M); + +alter table POLLING_PROCESS_QUEUE add +constraint POLLING_PROCESS_QUEUE_PK +primary key(id) +using index +tablespace USERS pctfree 0 +storage (initial 1M next 1M); + +execute drop_if_exists('SEQUENCE', 'POLLING_PROCESS_QUEUE_ID_SEQ'); +create sequence POLLING_PROCESS_QUEUE_ID_SEQ +start with 1 order; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'POLLING_PROCESS_QUEUE'); diff --git a/Chapter10/polling_process_queues.pkb b/Chapter10/polling_process_queues.pkb new file mode 100644 index 0000000..f98d966 --- /dev/null +++ b/Chapter10/polling_process_queues.pkb @@ -0,0 +1,155 @@ +create or replace package body POLLING_PROCESS_QUEUES as +/* +polling_process_queues.pkb +by Donald J. Bales on 12/15/2006 +Table POLLING_PROCESS_QUEUE's routines +*/ + + +FUNCTION get_id +return POLLING_PROCESS_QUEUE.id%TYPE is + +id POLLING_PROCESS_QUEUE.id%TYPE; + +begin + select POLLING_PROCESS_QUEUE_ID_SEQ.nextval + into id + from SYS.DUAL; + + return id; +end get_id; + + +FUNCTION get_next( +air_polling_process_queue in POLLING_PROCESS_QUEUE%ROWTYPE) +return POLLING_PROCESS_QUEUE%ROWTYPE is + +pragma autonomous_transaction; + +r_polling_process_queue POLLING_PROCESS_QUEUE%ROWTYPE; + +begin + delete POLLING_PROCESS_QUEUE + where id = + air_polling_process_queue.id; + + begin + select q.* + into r_polling_process_queue + from POLLING_PROCESS_QUEUE q + where q.id = ( + select min(n.id) + from POLLING_PROCESS_QUEUE n); + exception + when NO_DATA_FOUND then + r_polling_process_queue := NULL; + end; + + commit; + + return r_polling_process_queue; +end get_next; + + +PROCEDURE disable is + +pragma autonomous_transaction; + +begin + begin + insert into POLLING_PROCESS_QUEUE ( + id, + command, + insert_user, + insert_date ) + values ( + -3, + v_DISABLE, + USER, + SYSDATE ); + pl('Queued to disable logging.'); + exception + when DUP_VAL_ON_INDEX then + pl('Already queued to disable logging.'); + end; + + commit; +end disable; + + +PROCEDURE enable is + +pragma autonomous_transaction; + +begin + begin + insert into POLLING_PROCESS_QUEUE ( + id, + command, + insert_user, + insert_date ) + values ( + -2, + v_ENABLE, + USER, + SYSDATE ); + pl('Queued to enable logging.'); + exception + when DUP_VAL_ON_INDEX then + pl('Already queued enable logging.'); + end; + + commit; +end enable; + + +PROCEDURE quit is + +pragma autonomous_transaction; + +begin + begin + insert into POLLING_PROCESS_QUEUE ( + id, + command, + insert_user, + insert_date ) + values ( + -1, + v_QUIT, + USER, + SYSDATE ); + pl('Queued to quit.'); + exception + when DUP_VAL_ON_INDEX then + pl('Already queued to quit.'); + end; + + commit; +end quit; + + +PROCEDURE set_next( +aiv_command in POLLING_PROCESS_QUEUE.command%TYPE) is + +pragma autonomous_transaction; + +begin + insert into POLLING_PROCESS_QUEUE ( + id, + command, + insert_user, + insert_date ) + values ( + get_id(), + aiv_command, + USER, + SYSDATE ); + + commit; +end set_next; + + +end POLLING_PROCESS_QUEUES; +/ +@be.sql POLLING_PROCESS_QUEUES diff --git a/Chapter10/polling_process_queues.pks b/Chapter10/polling_process_queues.pks new file mode 100644 index 0000000..6975f1a --- /dev/null +++ b/Chapter10/polling_process_queues.pks @@ -0,0 +1,37 @@ +create or replace package POLLING_PROCESS_QUEUES as +/* +polling_process_queues.pks +by Donald J. Bales on 12/15/2006 +Table POLLING_PROCESS_QUEUE's routines +*/ + +v_DISABLE constant POLLING_PROCESS_QUEUE.command%TYPE := 'DISABLE'; +v_ENABLE constant POLLING_PROCESS_QUEUE.command%TYPE := 'ENABLE'; +v_QUIT constant POLLING_PROCESS_QUEUE.command%TYPE := 'QUIT'; + + +PROCEDURE disable; + + +PROCEDURE enable; + + +FUNCTION get_id +return POLLING_PROCESS_QUEUE.id%TYPE; + + +FUNCTION get_next( +air_polling_process_queue in POLLING_PROCESS_QUEUE%ROWTYPE) +return POLLING_PROCESS_QUEUE%ROWTYPE; + + +PROCEDURE quit; + + +PROCEDURE set_next( +aiv_command in POLLING_PROCESS_QUEUE.command%TYPE); + + +end POLLING_PROCESS_QUEUES; +/ +@se.sql POLLING_PROCESS_QUEUES diff --git a/Chapter10/polling_process_status.tab b/Chapter10/polling_process_status.tab new file mode 100644 index 0000000..1055eeb --- /dev/null +++ b/Chapter10/polling_process_status.tab @@ -0,0 +1,13 @@ +rem polling_process_status.tab +rem by Donald J. Bales on 12/15/2006 +rem A table to act as a status port for a polling process + +execute drop_if_exists('table', 'POLLING_PROCESS_STATUS'); +create table POLLING_PROCESS_STATUS ( +status varchar2(256) not null, +update_user varchar2(30) default USER not null, +update_date date default SYSDATE not null) +tablespace USERS pctfree 0 +storage (initial 1M next 1M); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'POLLING_PROCESS_STATUS'); diff --git a/Chapter10/polling_process_statuss.pkb b/Chapter10/polling_process_statuss.pkb new file mode 100644 index 0000000..894f582 --- /dev/null +++ b/Chapter10/polling_process_statuss.pkb @@ -0,0 +1,66 @@ +create or replace package body POLLING_PROCESS_STATUSS as +/* +polling_process_statuss.pkb +by Donald J. Bales on 12/15/2006 +Table POLLING_PROCESS_STATUS's routines +*/ + + +FUNCTION get_status +return + POLLING_PROCESS_STATUS.status%TYPE is + +v_status + POLLING_PROCESS_STATUS.status%TYPE; + +begin + select status + into v_status + from POLLING_PROCESS_STATUS; + + return v_status; +exception + when NO_DATA_FOUND then + return 'UNKNOWN'; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select POLLING_PROCESS_STATUS'|| + ' in POLLING_PROCESS_STATUSS.get_status()'); +end get_status; + + +PROCEDURE set_status( +aiv_status in + POLLING_PROCESS_STATUS.status%TYPE) is + +pragma autonomous_transaction; + +begin + update POLLING_PROCESS_STATUS + set status = aiv_status, + update_user = USER, + update_date = SYSDATE; + + if nvl(sql%rowcount, 0) = 0 then + insert into POLLING_PROCESS_STATUS ( + status, + update_user, + update_date ) + values ( + aiv_status, + USER, + SYSDATE ); + end if; + + commit; +exception + when OTHERS then + raise_application_error(-20002, SQLERRM|| + ' on update or insert POLLING_PROCESS_STATUS'|| + ' in POLLING_PROCESS_STATUSS.set_status()'); +end set_status; + + +end POLLING_PROCESS_STATUSS; +/ +@be.sql POLLING_PROCESS_STATUSS diff --git a/Chapter10/polling_process_statuss.pks b/Chapter10/polling_process_statuss.pks new file mode 100644 index 0000000..4fdf54a --- /dev/null +++ b/Chapter10/polling_process_statuss.pks @@ -0,0 +1,19 @@ +create or replace package POLLING_PROCESS_STATUSS as +/* +polling_process_statuss.pks +by Donald J. Bales on 12/15/2006 +Table POLLING_PROCESS_STATUS's routines +*/ + + +FUNCTION get_status +return POLLING_PROCESS_STATUS.status%TYPE; + + +PROCEDURE set_status( +aiv_status in POLLING_PROCESS_STATUS.status%TYPE); + + +end POLLING_PROCESS_STATUSS; +/ +@se.sql POLLING_PROCESS_STATUSS diff --git a/Chapter10/report_staging_table_log.tab b/Chapter10/report_staging_table_log.tab new file mode 100644 index 0000000..c586076 --- /dev/null +++ b/Chapter10/report_staging_table_log.tab @@ -0,0 +1,38 @@ +rem report_staging_table_log.tab +rem by Donald J. Bales on 12/15/2006 +rem Create a log table for on-demand data processing packages + +execute drop_if_exists('TABLE', 'REPORT_STAGING_TABLE_LOG'); +create table REPORT_STAGING_TABLE_LOG ( +id number not null, +object_name varchar2(30) not null, +method_name varchar2(30) not null, +rows_selected number, +rows_inserted number, +rows_updated number, +rows_deleted number, +result varchar2(256), +elapsed_time number, +insert_user varchar2(30) default USER not null, +insert_date date default SYSDATE not null, +update_user varchar2(30) default USER not null, +update_date date default SYSDATE not null) +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +alter table REPORT_STAGING_TABLE_LOG add +constraint REPORT_STAGING_TABLE_LOG_PK +primary key ( +id ) +using index +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +-- 123456789012345678901234567890 +execute drop_if_exists('SEQUENCE', 'REPORT_STAGING_TABLE_LOG_ID_SE'); +create sequence REPORT_STAGING_TABLE_LOG_ID_SE +start with 1 order; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'REPORT_STAGING_TABLE_LOG'); + +grant select on REPORT_STAGING_TABLE_LOG to public; diff --git a/Chapter10/report_staging_table_logs.pkb b/Chapter10/report_staging_table_logs.pkb new file mode 100644 index 0000000..0e03fa8 --- /dev/null +++ b/Chapter10/report_staging_table_logs.pkb @@ -0,0 +1,162 @@ +create or replace package body REPORT_STAGING_TABLE_LOGS as +/* +report_staging_table_logs.pkb +by Donald J. Bales on 12/15/2006 + +Table REPORT_STAGING_TABLE_LOG routines +*/ + + +-- Instance variables to hold log information between start and stop +n_id REPORT_STAGING_TABLE_LOG.id%TYPE; +n_start number; + + +FUNCTION get_id +return REPORT_STAGING_TABLE_LOG.id%TYPE is + +n_id REPORT_STAGING_TABLE_LOG.id%TYPE; + +begin + select REPORT_STAGING_TABLE_LOG_ID_SE.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +PROCEDURE help is + +begin + TEXT_HELP.process('REPORT_STAGING_TABLE_LOGS'); +end help; + + +PROCEDURE start_logging( +aiv_object_name in REPORT_STAGING_TABLE_LOG.object_name%TYPE, +aiv_method_name in REPORT_STAGING_TABLE_LOG.method_name%TYPE) is + +pragma autonomous_transaction; + +begin + n_start := to_number(to_char(SYSDATE, 'SSSSS')); + n_id := get_id(); + + insert into REPORT_STAGING_TABLE_LOG ( + id, + object_name, + method_name ) + values ( + n_id, + upper(aiv_object_name), + upper(aiv_method_name) ); + commit; +end start_logging; + + +PROCEDURE stop_logging( +ain_rows_selected in REPORT_STAGING_TABLE_LOG.rows_selected%TYPE, +ain_rows_inserted in REPORT_STAGING_TABLE_LOG.rows_inserted%TYPE, +ain_rows_updated in REPORT_STAGING_TABLE_LOG.rows_updated%TYPE, +ain_rows_deleted in REPORT_STAGING_TABLE_LOG.rows_deleted%TYPE, +aiv_result in REPORT_STAGING_TABLE_LOG.result%TYPE) is + +pragma autonomous_transaction; + +n_elapsed_time number; + +begin + n_elapsed_time := to_number(to_char(SYSDATE, 'SSSSS')) - n_start; + + update REPORT_STAGING_TABLE_LOG + set rows_selected = ain_rows_selected, + rows_inserted = ain_rows_inserted, + rows_updated = ain_rows_updated, + rows_deleted = ain_rows_deleted, + result = aiv_result, + elapsed_time = n_elapsed_time, + update_user = USER, + update_date = SYSDATE + where id = n_id; + commit; + + n_id := NULL; + + -- Display the results + if ain_rows_selected is not null then + pl(to_char(ain_rows_selected)||' rows selected.'); + end if; + if ain_rows_inserted is not null then + pl(to_char(ain_rows_inserted)||' rows inserted.'); + end if; + if ain_rows_updated is not null then + pl(to_char(ain_rows_updated)||' rows updated.'); + end if; + if ain_rows_deleted is not null then + pl(to_char(ain_rows_deleted)||' rows deleted.'); + end if; + if aiv_result is not null then + pl(aiv_result); + end if; + pl('Elapsed time: '||to_char(n_elapsed_time)||' seconds.'); +end stop_logging; + + +PROCEDURE stop_logging( +aiv_result in REPORT_STAGING_TABLE_LOG.result%TYPE) is + +begin + stop_logging(NULL, NULL, NULL, NULL, aiv_result); +end stop_logging; + + +PROCEDURE stop_logging is + +begin + stop_logging(NULL, NULL, NULL, NULL, NULL); +end stop_logging; + + +PROCEDURE test is + +begin + -- Send feedback that the test ran + pl('REPORT_STAGING_TABLE_LOGS.test()'); + + -- Clear the last set of test results + TEST_TS.clear('REPORT_STAGING_TABLE_LOGS'); + + -- Tests + TEST_TS.set_test('REPORT_STAGING_TABLE_LOGS', 'start_logging()', 0, + 'start logging'); + begin + start_logging('REPORT_STAGING_TABLE_LOGS', 'test'); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('REPORT_STAGING_TABLE_LOGS', 'stop_logging()', 1, + 'stop logging'); + begin + SYS.DBMS_LOCK.sleep(3); + + stop_logging(); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('REPORT_STAGING_TABLE_LOGS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end REPORT_STAGING_TABLE_LOGS; +/ +@be.sql diff --git a/Chapter10/report_staging_table_logs.pks b/Chapter10/report_staging_table_logs.pks new file mode 100644 index 0000000..c417733 --- /dev/null +++ b/Chapter10/report_staging_table_logs.pks @@ -0,0 +1,44 @@ +create or replace package REPORT_STAGING_TABLE_LOGS as +/* +report_staging_table_logs.pks +by Donald J. Bales on 12/15/2006 +Table REPORT_STAGING_TABLE_LOG routines +*/ + + +-- Display this packages help text. + +PROCEDURE help; + +-- Start logging the use of an on-demand data processing process + +PROCEDURE start_logging( +aiv_object_name in REPORT_STAGING_TABLE_LOG.object_name%TYPE, +aiv_method_name in REPORT_STAGING_TABLE_LOG.method_name%TYPE); + +-- Stop logging the use of an on-demand data processing process + +PROCEDURE stop_logging( +ain_rows_selected in REPORT_STAGING_TABLE_LOG.rows_selected%TYPE, +ain_rows_inserted in REPORT_STAGING_TABLE_LOG.rows_inserted%TYPE, +ain_rows_updated in REPORT_STAGING_TABLE_LOG.rows_updated%TYPE, +ain_rows_deleted in REPORT_STAGING_TABLE_LOG.rows_deleted%TYPE, +aiv_result in REPORT_STAGING_TABLE_LOG.result%TYPE); + +-- Stop logging the use of an on-demand data processing process + +PROCEDURE stop_logging( +aiv_result in REPORT_STAGING_TABLE_LOG.result%TYPE); + +-- Stop logging the use of an on-demand data processing process + +PROCEDURE stop_logging; + +-- Test the methods in this package + +PROCEDURE test; + + +end REPORT_STAGING_TABLE_LOGS; +/ +@se.sql diff --git a/Chapter10/report_staging_tables.pkb b/Chapter10/report_staging_tables.pkb new file mode 100644 index 0000000..577ff78 --- /dev/null +++ b/Chapter10/report_staging_tables.pkb @@ -0,0 +1,96 @@ +create or replace package body REPORT_STAGING_TABLES as +/* +report_tables.pkb +by Donald J. Bales on 12/15/2006 + +On-demand Data Processing (ON_DEMAND): +An example of an on-demand data processing package +designed to truncate report staging tables +*/ + +PROCEDURE help is + +begin + TEXT_HELP.process('REPORT_STAGING_TABLES'); +end help; + + +PROCEDURE Process is + +-- Get a list of all the tables that start with REPORT_ in BPS' schema +cursor c_table is +select table_name +from SYS.ALL_TABLES +where owner = 'BPS' +and table_name like 'REPORT\_%' escape '\' +order by 1; + +n_selected number := 0; +n_deleted number := 0; + +begin + -- Start logging + ON_DEMAND_PROCESS_LOGS.start_logging( + 'REPORT_STAGING_TABLES', 'process'); + + -- For each report "staging" table, delete any data over 2 days old + for r_table in c_table loop + n_selected := n_selected + 1; + + execute immediate 'delete '|| + r_table.table_name|| + ' where insert_date < SYSDATE - 2'; + + n_deleted := n_deleted + nvl(sql%rowcount, 0); + end loop; + + -- Stop logging + ON_DEMAND_PROCESS_LOGS.stop_logging( + n_selected, NULL, NULL, n_deleted, NULL); +exception + when OTHERS then + -- Stop logging, but report an error + ON_DEMAND_PROCESS_LOGS.stop_logging( + n_selected, NULL, NULL, n_deleted, SQLERRM); + raise; +end process; + + +PROCEDURE test is + +begin + -- Send feedback that the test ran + pl('REPORT_STAGING_TABLES.test()'); + + -- Clear the last set of test results + TEST_TS.clear('REPORT_STAGING_TABLES'); + + -- Tests + TEST_TS.set_test('REPORT_STAGING_TABLES', 'help', 0, + 'Test help'); + begin + help(); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('REPORT_STAGING_TABLES', 'process', 1, + 'This method cannot be tested by test(), please test it manually.'); + begin + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('REPORT_STAGING_TABLES', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end REPORT_STAGING_TABLES; +/ +@be.sql diff --git a/Chapter10/report_staging_tables.pks b/Chapter10/report_staging_tables.pks new file mode 100644 index 0000000..86d96eb --- /dev/null +++ b/Chapter10/report_staging_tables.pks @@ -0,0 +1,28 @@ +create or replace package REPORT_STAGING_TABLES as +/* +report_staging_tables.pks +by Donald J. Bales on 12/15/2006 + +On-demand Data Processing (ODP): +An example of an on-demand data processing package +designed to truncate report staging tables +*/ + +-- Display this package's help text. + +PROCEDURE help; + + +-- Delete any data more than two days old from the report staging tables. + +PROCEDURE process; + + +-- Test this package's methods. + +PROCEDURE test; + + +end REPORT_STAGING_TABLES; +/ +@be.sql diff --git a/Chapter10/report_wkhst.tab b/Chapter10/report_wkhst.tab new file mode 100644 index 0000000..3ac4977 --- /dev/null +++ b/Chapter10/report_wkhst.tab @@ -0,0 +1,34 @@ +rem report_wkhst.tab +rem by Donald J. Bales +rem Create a staging tabel for a Worker History report + +execute drop_if_exists('TABLE', 'REPORT_WKHST'); +create table REPORT_WKHST ( +report_wkhst_id number not null, +report_wkhst_seq number not null, +worker_id number not null, +worker_name varchar2(100) not null, +active_date date, +logical_workplace_name varchar2(80), +physical_workplace_name varchar2(80), +work_name varchar2(80), +inactive_date date, +insert_user varchar2(30) default USER not null, +insert_date date default SYSDATE not null) +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +alter table REPORT_WKHST add +constraint REPORT_WKHST_PK +primary key ( +report_wkhst_id, +report_wkhst_seq ) +using index +tablespace USERS pctfree 0 +storage (initial 1M next 1M pctincrease 0); + +execute drop_if_exists('SEQUENCE', 'REPORT_WKHST_ID_SEQ'); +create sequence REPORT_WKHST_ID_SEQ +start with 1 order; + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'REPORT_WKHST'); diff --git a/Chapter10/report_wkhsts.get_report.sql b/Chapter10/report_wkhsts.get_report.sql new file mode 100644 index 0000000..9382dfc --- /dev/null +++ b/Chapter10/report_wkhsts.get_report.sql @@ -0,0 +1,22 @@ +rem report_wkhsts.get_report.sql +rem by Donald J. Bales on 12/15/2006 +rem Test Unit for REPORT_WKHST_TS.get_report() + +column worker_name format a21 trunc; +column logical_workplace_name format a11 trunc; +column physical_workplace_name format a11 trunc; +column work_name format a11 trunc; +column active_date format a8; +column inactive_date format a8; + +execute pl('report_wkhst_id='||to_char(REPORT_WKHSTS.get_report(11649889))); + +select worker_name, + logical_workplace_name, + physical_workplace_name, + work_name, + to_char(active_date, 'YYYYMMDD') active_date, + to_char(inactive_date, 'YYYYMMDD') inactive_date +from REPORT_WKHST +where report_wkhst_id = &report_wkhst_id +order by report_wkhst_seq; diff --git a/Chapter10/report_wkhsts.pkb b/Chapter10/report_wkhsts.pkb new file mode 100644 index 0000000..1488236 --- /dev/null +++ b/Chapter10/report_wkhsts.pkb @@ -0,0 +1,290 @@ +create or replace package body REPORT_WKHSTS as +/* +report_wkhsts.pkb +by Donald Bales on 12/15/2006 +Worker History Report +*/ + +-- FORWARD DECLARATION +PROCEDURE set_report( +aior_report_wkhst in out REPORT_WKHST%ROWTYPE); + + +FUNCTION get_id +return REPORT_WKHST.report_wkhst_id%TYPE is + +n_report_wkhst_id REPORT_WKHST.report_wkhst_id%TYPE; + +begin + select REPORT_WKHST_ID_SEQ.nextval + into n_report_wkhst_id + from SYS.DUAL; + + return n_report_wkhst_id; +exception + when OTHERS then + raise_application_error(-20000, SQLERRM|| + ' on select REPORT_WKHST_ID_SEQ.nextval'|| + ' in REPORT_WKHSTS.get_id()'); +end get_id; + + +PROCEDURE get_logical_workplace_name( +ain_worker_id in REPORT_WKHST.worker_id%TYPE, +aid_active_date in REPORT_WKHST.active_date%TYPE, +aov_name out REPORT_WKHST.logical_workplace_name%TYPE, +aod_inactive_date out REPORT_WKHST.inactive_date%TYPE) is + +begin + select w.name, + nvl(a.inactive_date, DATES.d_max) + into aov_name, + aod_inactive_date + from LOGICAL_ASSIGNMENT_T a, + LOGICAL_WORKPLACE_T w + where a.worker_id = ain_worker_id + and aid_active_date between a.active_date + and nvl(a.inactive_date, DATES.d_max) + and a.logical_workplace_id = w.id; +exception + when NO_DATA_FOUND then + aov_name := NULL; + aod_inactive_date := DATES.d_max; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select LOGICAL_ASSIGNMENT_T, LOGICAL_WORKPLACE_T'|| + ' in REPORT_WKHSTS.get_logical_workplace_name()'); +end get_logical_workplace_name; + + +PROCEDURE get_physical_workplace_name( +ain_worker_id in REPORT_WKHST.worker_id%TYPE, +aid_active_date in REPORT_WKHST.active_date%TYPE, +aov_name out REPORT_WKHST.physical_workplace_name%TYPE, +aod_inactive_date out REPORT_WKHST.inactive_date%TYPE) is + +begin + select w.name, + nvl(a.inactive_date, DATES.d_max) + into aov_name, + aod_inactive_date + from PHYSICAL_ASSIGNMENT_T a, + PHYSICAL_WORKPLACE_T w + where a.worker_id = ain_worker_id + and aid_active_date between a.active_date + and nvl(a.inactive_date, DATES.d_max) + and a.physical_workplace_id = w.id; +exception + when NO_DATA_FOUND then + aov_name := NULL; + aod_inactive_date := DATES.d_max; + when OTHERS then + raise_application_error(-20002, SQLERRM|| + ' on select PHYSICAL_ASSIGNMENT_T, PHYSICAL_WORKPLACE_T'|| + ' in REPORT_WKHSTS.get_physical_workplace_name()'); +end get_physical_workplace_name; + + +PROCEDURE get_work_name( +ain_worker_id in REPORT_WKHST.worker_id%TYPE, +aid_active_date in REPORT_WKHST.active_date%TYPE, +aov_name out REPORT_WKHST.work_name%TYPE, +aod_inactive_date out REPORT_WKHST.inactive_date%TYPE) is + +begin + select w.name, + nvl(a.inactive_date, DATES.d_max) + into aov_name, + aod_inactive_date + from WORK_ASSIGNMENT_T a, + WORK_T w + where a.worker_id = ain_worker_id + and aid_active_date between a.active_date + and nvl(a.inactive_date, DATES.d_max) + and a.work_id = w.id; +exception + when NO_DATA_FOUND then + aov_name := NULL; + aod_inactive_date := DATES.d_max; + when OTHERS then + raise_application_error(-20003, SQLERRM|| + ' on select WORK_ASSIGNMENT_T, WORK_T'|| + ' in REPORT_WKHSTS.get_work_name()'); +end get_work_name; + + +FUNCTION get_report( +ain_worker_id in REPORT_WKHST.worker_id%TYPE) +return REPORT_WKHST.report_wkhst_id%TYPE is + +cursor c_date( +ain_worker_id in REPORT_WKHST.worker_id%TYPE) is +select v1.active_date +from ( select active_date + from LOGICAL_ASSIGNMENT_T + where worker_id = ain_worker_id + UNION + select active_date + from PHYSICAL_ASSIGNMENT_T + where worker_id = ain_worker_id + UNION + select active_date + from WORK_ASSIGNMENT_T + where worker_id = ain_worker_id ) v1 +order by 1; + +d_logical_inactive_date REPORT_WKHST.inactive_date%TYPE; +d_physical_inactive_date REPORT_WKHST.inactive_date%TYPE; +d_work_inactive_date REPORT_WKHST.inactive_date%TYPE; + +r_worker WORKER_T%ROWTYPE; + +r_report_wkhst REPORT_WKHST%ROWTYPE; + +begin + r_report_wkhst.report_wkhst_id := get_id(); + r_report_wkhst.report_wkhst_seq := 0; + + r_worker.id := ain_worker_id; + r_worker := WORKER_TS.get_row(r_worker); + + r_report_wkhst.worker_id := r_worker.id; + r_report_wkhst.worker_name := + WORKER_TS.get_formatted_name( + r_worker.first_name, + r_worker.middle_name, + r_worker.last_name); + + for r_date in c_date(ain_worker_id) loop + r_report_wkhst.active_date := r_date.active_date; + + get_logical_workplace_name( + r_report_wkhst.worker_id, + r_report_wkhst.active_date, + r_report_wkhst.logical_workplace_name, + d_logical_inactive_date); + + get_physical_workplace_name( + r_report_wkhst.worker_id, + r_report_wkhst.active_date, + r_report_wkhst.physical_workplace_name, + d_physical_inactive_date); + + get_work_name( + r_report_wkhst.worker_id, + r_report_wkhst.active_date, + r_report_wkhst.work_name, + d_work_inactive_date); + + r_report_wkhst.inactive_date := + least( + d_logical_inactive_date, + d_physical_inactive_date, + d_work_inactive_date); + + set_report(r_report_wkhst); + end loop; + + commit; + + return r_report_wkhst.report_wkhst_id; +end get_report; + + +PROCEDURE report( +ain_worker_id in REPORT_WKHST.worker_id%TYPE, +aiv_to in varchar2) is + +cursor c_report_wkhst( +ain_report_wkhst_id in REPORT_WKHST.report_wkhst_id%TYPE) is +select initcap(worker_name) worker_name, + active_date, + initcap(logical_workplace_name) logical_workplace_name, + initcap(physical_workplace_name) physical_workplace_name, + initcap(work_name) work_name, + inactive_date +from REPORT_WKHST +where report_wkhst_id = ain_report_wkhst_id +order by report_wkhst_seq; + +n_line number; +t_lines EMAILS.LINES; +n_report_wkhst_id REPORT_WKHST.report_wkhst_id%TYPE; +v_worker_name REPORT_WKHST.worker_name%TYPE; + +begin + n_report_wkhst_id := get_report(ain_worker_id); + + t_lines(incr(n_line)) := '
'; + for r_report_wkhst in c_report_wkhst(n_report_wkhst_id) loop + if c_report_wkhst%rowcount = 1 then + v_worker_name := r_report_wkhst.worker_name; + t_lines(incr(n_line)) := ''; + t_lines(incr(n_line)) := ''; + t_lines(incr(n_line)) := ''; + t_lines(incr(n_line)) := ''|| + ''|| + ''|| + ''|| + ''|| + ''|| + ''; + t_lines(incr(n_line)) := ''|| + ''|| + ''|| + ''|| + ''|| + ''|| + ''; + end if; + t_lines(incr(n_line)) := ''|| + ''|| + ''|| + ''|| + ''|| + ''|| + ''; + end loop; + t_lines(incr(n_line)) := '
'|| + 'Work History Report
'|| + 'for '||v_worker_name||'
'|| + '
LogicalPhysicalActiveInactive
WorkplaceWorkplaceWorkDateDate
'|| + r_report_wkhst.logical_workplace_name||''|| + r_report_wkhst.physical_workplace_name||''|| + r_report_wkhst.work_name||''|| + to_char(r_report_wkhst.active_date, 'MM/DD/YYYY')||''|| + to_char(r_report_wkhst.inactive_date, 'MM/DD/YYYY')||'
';
+
+  EMAILS.send(
+    EMAILS.get_username,
+    aiv_to,
+    'Work History Report for '||v_worker_name,
+    t_lines);
+end report;  
+
+
+PROCEDURE set_report(
+aior_report_wkhst              in out REPORT_WKHST%ROWTYPE) is
+
+begin
+  aior_report_wkhst.report_wkhst_seq := aior_report_wkhst.report_wkhst_seq + 1;
+
+  if aior_report_wkhst.inactive_date  = DATES.d_max then
+    aior_report_wkhst.inactive_date  := NULL;
+  end if;
+  
+  aior_report_wkhst.insert_user      := USER;
+  aior_report_wkhst.insert_date      := SYSDATE;
+  
+  insert into REPORT_WKHST values aior_report_wkhst;
+exception
+  when OTHERS then
+    raise_application_error(-20004, SQLERRM||
+      ' on insert REPORT_WKHST'||
+      ' in REPORT_WKHSTS.set_report()');
+end;         
+  
+  
+end REPORT_WKHSTS;
+/
+@be.sql REPORT_WKHSTS
diff --git a/Chapter10/report_wkhsts.pks b/Chapter10/report_wkhsts.pks
new file mode 100644
index 0000000..583dde0
--- /dev/null
+++ b/Chapter10/report_wkhsts.pks
@@ -0,0 +1,20 @@
+create or replace package REPORT_WKHSTS as
+/*
+report_wkhsts.pks
+by Donald Bales on 12/15/2006
+Worker History Report
+*/
+
+FUNCTION get_report(
+ain_worker_id                  in     REPORT_WKHST.worker_id%TYPE)
+return                                REPORT_WKHST.report_wkhst_id%TYPE;
+
+
+PROCEDURE report(
+ain_worker_id                  in     REPORT_WKHST.worker_id%TYPE,
+aiv_to                         in     varchar2);
+
+
+end REPORT_WKHSTS;
+/
+@se.sql REPORT_WKHSTS
diff --git a/Chapter10/report_wkhsts.report.sql b/Chapter10/report_wkhsts.report.sql
new file mode 100644
index 0000000..df203b1
--- /dev/null
+++ b/Chapter10/report_wkhsts.report.sql
@@ -0,0 +1,5 @@
+rem report_wkhsts.report.sql
+rem by Donald J. Bales on 12/15/2006
+rem Test Unit for REPORT_WKHST_TS.report()
+
+execute REPORT_WKHSTS.report(11649889, 'don@donaldbales.com');
diff --git a/Chapter10/se.sql b/Chapter10/se.sql
new file mode 100644
index 0000000..40be076
--- /dev/null
+++ b/Chapter10/se.sql
@@ -0,0 +1 @@
+show errors
diff --git a/Chapter10/seed.sql b/Chapter10/seed.sql
new file mode 100644
index 0000000..fa3c077
--- /dev/null
+++ b/Chapter10/seed.sql
@@ -0,0 +1,46 @@
+delete work_assignment_t;
+commit;
+delete work_t;
+commit;
+delete physical_assignment_t;
+commit;
+delete physical_workplace_t;
+commit;
+delete logical_assignment_t;
+commit;
+delete logical_workplace_t;
+commit;
+
+@logical_workplace_t.ins
+@logical_assignment_t.ins
+@physical_workplace_t.ins
+@physical_assignment_t.ins
+@work_t.ins
+@work_assignment_t.ins
+
+column worker format a18;
+column work   format a18;
+
+select r.worker_id,
+       r.name worker,
+       k.name work,
+       a.active_date,
+       a.inactive_date
+from   WORKER_T r,
+       WORK_T k,
+       WORK_ASSIGNMENT_T a
+where  a.worker_id = r.worker_id
+and    a.work_id   = k.work_id
+and    2 < (
+select count(1)
+from   WORK_ASSIGNMENT_T g
+where  g.worker_id = a.worker_id)
+and exists (
+select 1
+from   WORK_ASSIGNMENT_T x
+where  x.worker_id = a.worker_id
+and    x.inactive_date is NULL)
+and rownum < 21
+order by 1, 3;
+
+
diff --git a/Chapter10/to_boolean_number.fun b/Chapter10/to_boolean_number.fun
new file mode 100644
index 0000000..cac4a7d
--- /dev/null
+++ b/Chapter10/to_boolean_number.fun
@@ -0,0 +1,23 @@
+create or replace FUNCTION to_boolean_number(
+aib_boolean                    in     boolean )
+return                                number is
+/*
+to_boolean_number.fun
+by Donald J. Bales on 12/15/2006
+A method to return a numeric value for false (0) and true (1).
+This is very handy for calling functions that return boolean
+values from JDBC, which can't handle boolean database values.
+*/
+begin
+  if aib_boolean is not null then
+    if aib_boolean then
+      return 1;
+    else
+      return 0;
+    end if;
+  else
+    return NULL;
+  end if;
+end to_boolean_number;
+/
+@fe.sql TO_BOOLEAN_NUMBER
diff --git a/Chapter10/top_100_names.pkb b/Chapter10/top_100_names.pkb
new file mode 100644
index 0000000..200c124
--- /dev/null
+++ b/Chapter10/top_100_names.pkb
@@ -0,0 +1,270 @@
+create or replace package body TOP_100_NAMES as
+/*
+top_100_names.pkb
+by Donald J. Bales on 12/15/2006
+
+Data Migration:
+  Seed the Worker table with the top 100 names
+  100 last x 100 first x 26 middle = 260,000 entries
+*/
+
+
+-- Here, I declare four psuedo-constants to hold the
+-- ID values from the code tables, rather than look
+-- them up repeatedly during the insert process.
+n_G_FEMALE                            GENDER_T.id%TYPE;
+n_G_MALE                              GENDER_T.id%TYPE;
+n_WT_CONTRACTOR                       WORKER_TYPE_T.id%TYPE;
+n_WT_EMPLOYEE                         WORKER_TYPE_T.id%TYPE;
+
+
+
+FUNCTION create_birth_date( 
+aiv_name                       in     WORKER_T.name%TYPE) 
+return                                WORKER_T.birth_date%TYPE is
+
+n_day                                 number;
+n_name                                number := 0;
+n_month                               number;
+n_year                                number;
+
+begin
+  for i in 1..length(aiv_name) loop
+    n_name  := n_name + ascii(substr(aiv_name, i, 1));
+  end loop;
+  n_year    := n_name + 1000;
+  loop
+    if n_year between 1939 and 1990 then
+      exit;
+    end if;
+    n_year  := round(n_year/2, 0);
+    if n_year < 1939 then
+      n_year := n_year * 3;
+    end if;
+  end loop;
+  n_month   := n_name;
+  loop
+    if n_month between 1 and 12 then
+      exit;
+    end if;
+    n_month := round(n_month/2, 0);
+    if n_month < 1 then
+      n_month := 1;
+    end if;
+  end loop;
+  n_day     := n_name;
+  loop
+    if n_day between 1 and 28 then
+      exit;
+    end if;
+    n_day   := round(n_day/2, 0);
+    if n_day < 1 then
+      n_day := 1;
+    end if;
+  end loop;
+  return to_date(
+    to_char(n_month)||'/'||
+    to_char(n_day)||'/'||
+    to_char(n_year), 
+    'MM/DD/YYYY');
+end create_birth_date;
+
+
+PROCEDURE Initialize is
+
+begin
+  -- Get the ID values for these codes
+  n_G_FEMALE      := GENDER_TS.get_id('F');
+  n_G_MALE        := GENDER_TS.get_id('M');
+  n_WT_CONTRACTOR := WORKER_TYPE_TS.get_id('C');
+  n_WT_EMPLOYEE   := WORKER_TYPE_TS.get_id('E');
+exception
+  when OTHERS then
+    raise_application_error(-20000, SQLERRM||
+      ' on initialization'||
+      ' in TOP_100_NAMES.initialize()');
+end Initialize;
+
+
+PROCEDURE help is
+
+begin
+  TEXT_HELP.process('TOP_100_NAMES');
+end help;
+
+
+PROCEDURE Process is
+
+-- This is the cursor for the last names.
+cursor c_last is
+select last_name
+from   TOP_100_LAST_NAME
+order by 1;
+
+-- This is the cursor for the first names.
+cursor c_first is
+select first_name,
+       gender_code
+from   TOP_100_FIRST_NAME
+order by 1;
+
+-- This is the cursor for the middle initials.
+cursor c_middle is
+select letter
+from   A_THRU_Z
+order by 1;
+
+-- This is the number of seconds since midnight
+-- I'll use it to profile my code's performance.
+n_start                               number := 
+  to_number(to_char(SYSDATE, 'SSSSS'));
+
+-- I'll use this to keep track of how many rows were selected
+n_selected                            number := 0;
+
+-- Here, I declare a record anchored to the table so
+-- I can set the column values and then insert using
+-- the record.
+r_worker                              WORKER_T%ROWTYPE;
+
+begin
+  -- Reset the insert/update counters for set_row()
+  WORKER_TS.n_inserted := 0;
+  WORKER_TS.n_updated  := 0;
+  
+  -- Loop through the last names
+  for r_last in c_last loop
+
+    -- While looping through the last names,
+    -- loop through the first names
+    for r_first in c_first loop
+
+      -- While looping through the last and first names
+      -- loop through the 26 letters in the English
+      -- Alphabet in order to get middle initials
+      for r_middle in c_middle loop
+        n_selected                := n_selected + 1;
+        -- Initialize the record
+
+        -- Set the PK to NULL so set_row() determines
+        -- whether or not the entry already exists
+        -- by it's unique keys
+        r_worker.id               := NULL;
+
+        -- Flip flop from contractor to employee and back again
+        if r_worker.worker_type_id = n_WT_CONTRACTOR then
+          r_worker.worker_type_id := n_WT_EMPLOYEE;
+        else  
+          r_worker.worker_type_id := n_WT_CONTRACTOR;
+        end if;
+
+        -- Set the External ID, UK1, to NULL so set_row() determines
+        -- whether or not the entry already exists
+        -- by it's unique keys
+        r_worker.external_id      := NULL;
+
+        -- The first, middle, and last names come from the cursors
+        r_worker.first_name       := r_first.first_name;
+        r_worker.middle_name      := r_middle.letter||'.';
+        r_worker.last_name        := r_last.last_name;
+
+        -- get the name using the table's package
+        r_worker.name             := WORKER_TS.get_formatted_name(
+          r_worker.first_name, r_worker.middle_name, r_worker.last_name);
+
+        -- get the date from determinate function create_birth_date()
+        r_worker.birth_date       := create_birth_date(r_worker.name);
+
+        -- select the corresponding ID value
+        if r_first.gender_code = 'F' then
+          r_worker.gender_id      := n_G_FEMALE;
+        else
+          r_worker.gender_id      := n_G_MALE;
+        end if;
+
+        -- Insert the row into the database
+        begin
+          WORKER_TS.set_row(r_worker);
+        exception
+          when OTHERS then
+            raise_application_error(-20001, SQLERRM||
+              ' on call WORKER_TS.set_row()'||
+              ' in TOP_100_NAMES.process()');
+        end;
+      end loop; -- c_middle
+
+      commit;  -- commit every 26 rows
+    
+    end loop; -- c_first
+    
+  end loop; -- c_last
+
+  -- Display the results
+  pl(to_char(n_selected)||' rows selected');
+  pl(to_char(WORKER_TS.n_inserted)||' rows inserted');
+  pl(to_char(WORKER_TS.n_updated)||' rows updated');
+  pl('in '||to_char(to_number(to_char(SYSDATE, 'SSSSS')) - n_start)||
+    ' seconds.');
+end process;
+
+
+PROCEDURE test is
+
+d_birth_date_1                        date;
+d_birth_date_2                        date;
+
+begin
+  -- Send feedback that the test ran
+  pl('TOP_100_NAMES.test()');
+  
+  -- Clear the last set of test results
+  TEST_TS.clear('TOP_100_NAMES');
+  
+  -- Tests
+  TEST_TS.set_test('TOP_100_NAMES', 'initialize()', 0, 
+    'Package Initialization');
+  begin
+    initialize();
+    
+    TEST_TS.ok();
+  exception
+    when OTHERS then
+      TEST_TS.error(SQLERRM);
+  end;
+  
+  TEST_TS.set_test('TOP_100_NAMES', 'create_birth_date()', 1, 
+    'Is create_birth_date a determinate function?');
+  begin
+    d_birth_date_1 := create_birth_date('Bales, Donald J.');
+    d_birth_date_2 := create_birth_date('Bales, Donald J.');
+    
+    if d_birth_date_1 = d_birth_date_2 then
+      TEST_TS.ok();
+    else
+      TEST_TS.error();
+    end if;
+  exception
+    when OTHERS then
+      TEST_TS.error(SQLERRM);
+  end;
+  
+  TEST_TS.set_test('TOP_100_NAMES', 'process()', 2, 
+    'This method cannot be tested by test(), please test it manually.');
+  begin
+    TEST_TS.ok();
+  exception
+    when OTHERS then
+      TEST_TS.error(SQLERRM);
+  end;
+  
+  TEST_TS.set_test('TOP_100_NAMES', NULL, NULL, NULL);
+  TEST_TS.success();
+end test;
+
+
+begin
+  -- Initialize the package
+  initialize();
+end TOP_100_NAMES;
+/
+@be.sql
diff --git a/Chapter10/top_100_names.pks b/Chapter10/top_100_names.pks
new file mode 100644
index 0000000..db74492
--- /dev/null
+++ b/Chapter10/top_100_names.pks
@@ -0,0 +1,35 @@
+create or replace package TOP_100_NAMES as
+/*
+top_100_names.pks
+by Donald J. Bales on 12/15/2006
+
+Data Migration:
+  Seed the Worker table with the top 100 names
+  100 last x 100 first x 26 middle = 260,000 entries
+*/
+
+/*
+Display the help text for this package.
+*/
+PROCEDURE help;
+
+/*
+Initializes package pseudo-constants, it is called 
+by the package body's initialization section.
+*/
+PROCEDURE Initialize;
+
+/*
+Migrates data (inserts or updates) from tables TOP_100_LAST_NAME,
+TOP_100_FIRST_NAME, and A_THRU_Z to table WORKER_TS
+*/ 
+PROCEDURE Process;
+
+/*
+Test the methods in this package
+*/
+PROCEDURE test;
+
+end TOP_100_NAMES;
+/
+@se.sql
diff --git a/Chapter10/weekly_interface.pkb b/Chapter10/weekly_interface.pkb
new file mode 100644
index 0000000..6e4b121
--- /dev/null
+++ b/Chapter10/weekly_interface.pkb
@@ -0,0 +1,94 @@
+create or replace package body WEEKLY_INTERFACE as
+/*
+weekly_interface.pkb
+by Donald J. Bales on 12/15/2006
+An example of a weekly interface process
+*/
+
+
+PROCEDURE download is
+
+begin
+  pl('Executing download()');
+  -- You can code this procedure to move data between systems
+  -- using an Oracle database link, loaded JDBC driver and class,
+  -- etc.  Or, you can change this message to remind the user
+  -- that this is an asynchronous process handled by an external
+  -- program.
+
+  set_downloaded();
+end download;
+
+
+FUNCTION is_downloaded 
+return                                number is
+
+begin
+  -- A function that returns a 1 or 0 from TRUE and FALSE
+  -- from WEEKLY_INTERFACE_STATUSS.is_downloaded()
+  return to_boolean_number(WEEKLY_INTERFACE_STATUSS.is_downloaded());
+end is_downloaded;
+
+
+PROCEDURE process is
+
+begin
+  if not WEEKLY_INTERFACE_STATUSS.is_downloaded() then
+    download();
+    if not WEEKLY_INTERFACE_STATUSS.is_downloaded() then
+      pl('WARNING: download() did not complete successfully.');
+    end if;
+  end if;
+        
+  if WEEKLY_INTERFACE_STATUSS.is_downloaded() then
+    if not WEEKLY_INTERFACE_STATUSS.is_uploaded() then
+      upload();
+      if not WEEKLY_INTERFACE_STATUSS.is_uploaded() then
+        pl('WARNING: upload() did not complete successfully.');
+      end if;
+    end if;
+  end if;
+
+  pl('process() completed successfully.');
+end process;
+
+
+PROCEDURE set_downloaded is
+
+begin
+  WEEKLY_INTERFACE_STATUSS.set_downloaded();
+end set_downloaded;
+
+
+PROCEDURE upload is
+
+-- Add cursor(s) used to loop through the staging data here.
+
+begin
+  pl('Executing upload()');
+  if is_verified() then
+
+    -- Add your data migration code here.
+
+    WEEKLY_INTERFACE_STATUSS.set_uploaded();
+  end if;
+end upload;
+
+
+FUNCTION is_verified
+return                                boolean is
+
+begin
+  pl('Executing is_verified');
+
+  -- Add your code value mapping verifcation routine here.
+  -- You know! They call it a powtaytow, you call it a potato.
+  -- This method will verify that translation mapping exist,
+  -- where ever they exist, in what ever fashion the exist.
+  return TRUE;
+end is_verified;
+
+
+end WEEKLY_INTERFACE;
+/
+@be.sql WEEKLY_INTERFACE;
diff --git a/Chapter10/weekly_interface.pks b/Chapter10/weekly_interface.pks
new file mode 100644
index 0000000..82fb537
--- /dev/null
+++ b/Chapter10/weekly_interface.pks
@@ -0,0 +1,31 @@
+create or replace package WEEKLY_INTERFACE as
+/*
+weekly_interface.pks
+by Donald J. Bales on 12/15/2006
+An example of a weekly interface process
+*/
+
+
+PROCEDURE download;
+
+
+FUNCTION is_downloaded 
+return                                number;
+
+
+PROCEDURE process;
+
+
+PROCEDURE set_downloaded;
+
+
+PROCEDURE upload;
+
+
+FUNCTION is_verified
+return                                boolean;
+
+
+end WEEKLY_INTERFACE;
+/
+@se.sql WEEKLY_INTERFACE;
diff --git a/Chapter10/weekly_interface_status.tab b/Chapter10/weekly_interface_status.tab
new file mode 100644
index 0000000..17c2ec6
--- /dev/null
+++ b/Chapter10/weekly_interface_status.tab
@@ -0,0 +1,27 @@
+rem weekly_interface_status.tab
+rem by Donald J. Bales on 12/15/2006
+rem A Table to hold the multi-part status for a multi-part process
+
+execute drop_if_exists('TABLE', 'WEEKLY_INTERFACE_STATUS');
+create table WEEKLY_INTERFACE_STATUS (
+weekly_interface_status_id     number                         not null,
+download_date                  date,
+upload_date                    date,
+insert_user                    varchar2(30)  default USER     not null,
+insert_date                    date          default SYSDATE  not null,
+update_user                    varchar2(30)  default USER     not null,
+update_date                    date          default SYSDATE  not null)
+tablespace USERS pctfree 20
+storage (initial 1M next 1M pctincrease 0);
+
+alter  table WEEKLY_INTERFACE_STATUS add
+constraint   WEEKLY_INTERFACE_STATUS_PK
+primary key (
+weekly_interface_status_id )
+using index
+tablespace USERS pctfree 20
+storage (initial 1M next 1M pctincrease 0);
+
+-- A method will be used to calculate the primary key value
+
+execute SYS.DBMS_STATS.gather_table_stats(USER, 'WEEKLY_INTERFACE_STATUS');
diff --git a/Chapter10/weekly_interface_statuss.pkb b/Chapter10/weekly_interface_statuss.pkb
new file mode 100644
index 0000000..3b489b5
--- /dev/null
+++ b/Chapter10/weekly_interface_statuss.pkb
@@ -0,0 +1,127 @@
+create or replace package body WEEKLY_INTERFACE_STATUSS as
+/*
+weekly_interface_statuss.pkb
+by Donald J. Bales on 12/15/2006
+Table WEEKLY_INTERFACE_STATUS' routines
+*/
+
+
+-- This function will be used for the primary key instead of get_id
+
+FUNCTION get_week
+return                                number is
+
+begin
+  return to_char(SYSDATE, 'YYYYWW');
+end get_week;
+
+
+FUNCTION is_downloaded
+return                                boolean is
+
+pragma autonomous_transaction;
+
+d_download_date                       
+  WEEKLY_INTERFACE_STATUS.download_date%TYPE;
+
+begin
+  begin
+    select download_date
+    into   d_download_date
+    from   WEEKLY_INTERFACE_STATUS
+    where  weekly_interface_status_id = 
+      WEEKLY_INTERFACE_STATUSS.get_week();
+  exception
+    when NO_DATA_FOUND then
+      d_download_date := NULL;
+  end;
+  
+  if d_download_date is not NULL then
+    return TRUE;
+  else
+    return FALSE;
+  end if;
+end is_downloaded;
+
+
+FUNCTION is_uploaded
+return                                boolean is
+
+pragma autonomous_transaction;
+
+d_upload_date                         
+  WEEKLY_INTERFACE_STATUS.upload_date%TYPE;
+
+begin
+  begin
+    select upload_date
+    into   d_upload_date
+    from   WEEKLY_INTERFACE_STATUS
+    where  weekly_interface_status_id = 
+      WEEKLY_INTERFACE_STATUSS.get_week();
+  exception
+    when NO_DATA_FOUND then
+      d_upload_date := NULL;
+  end;
+  
+  if d_upload_date is not NULL then
+    return TRUE;
+  else
+    return FALSE;
+  end if;
+end is_uploaded;
+
+
+PROCEDURE set_downloaded is
+
+pragma autonomous_transaction;
+
+begin
+  update WEEKLY_INTERFACE_STATUS
+  set    download_date              = SYSDATE,
+         update_user                = USER,
+         update_date                = SYSDATE
+  where  weekly_interface_status_id = 
+    WEEKLY_INTERFACE_STATUSS.get_week();
+
+  if nvl(sql%rowcount, 0) = 0 then
+    insert into WEEKLY_INTERFACE_STATUS (
+           weekly_interface_status_id,
+           download_date )
+    values (
+           WEEKLY_INTERFACE_STATUSS.get_week(),
+           SYSDATE );
+  end if;
+  
+  commit;
+end set_downloaded;
+
+
+PROCEDURE set_uploaded is
+
+pragma autonomous_transaction;
+
+begin
+  update WEEKLY_INTERFACE_STATUS
+  set    upload_date                = SYSDATE,
+         update_user                = USER,
+         update_date                = SYSDATE
+  where  weekly_interface_status_id = 
+    WEEKLY_INTERFACE_STATUSS.get_week();
+
+  if nvl(sql%rowcount, 0) = 0 then
+    insert into WEEKLY_INTERFACE_STATUS (
+           weekly_interface_status_id,
+           upload_date )
+    values (
+           WEEKLY_INTERFACE_STATUSS.get_week(),
+           SYSDATE );
+  end if;
+  
+  commit;
+end set_uploaded;
+
+
+end WEEKLY_INTERFACE_STATUSS;
+/
+@be.sql WEEKLY_INTERFACE_STATUSS
diff --git a/Chapter10/weekly_interface_statuss.pks b/Chapter10/weekly_interface_statuss.pks
new file mode 100644
index 0000000..c19d2da
--- /dev/null
+++ b/Chapter10/weekly_interface_statuss.pks
@@ -0,0 +1,29 @@
+create or replace package WEEKLY_INTERFACE_STATUSS as
+/*
+weekly_interface_statuss.pks
+by Donald J. Bales on 12/15/2006
+Table WEEKLY_INTERFACE_STATUS' routines
+*/
+
+
+FUNCTION get_week
+return                                number;
+
+
+FUNCTION is_downloaded
+return                                boolean;
+
+
+FUNCTION is_uploaded
+return                                boolean;
+
+
+PROCEDURE set_downloaded;
+
+
+PROCEDURE set_uploaded;
+
+
+end WEEKLY_INTERFACE_STATUSS;
+/
+@se.sql WEEKLY_INTERFACE_STATUSS
diff --git a/Chapter10/work_assignment_t.ins b/Chapter10/work_assignment_t.ins
new file mode 100644
index 0000000..10cf00b
--- /dev/null
+++ b/Chapter10/work_assignment_t.ins
@@ -0,0 +1,355 @@
+declare
+
+-- Add worker history
+
+cursor c_logical_assignment is
+select a.worker_id,
+       a.active_date,
+       a.inactive_date,
+       w.code
+from   LOGICAL_ASSIGNMENT_T a,
+       LOGICAL_WORKPLACE_T w
+where  a.logical_workplace_id = w.id       
+order by 1;
+
+n_random                              number;
+r_work_assignment                     WORK_ASSIGNMENT_T%ROWTYPE;
+
+FUNCTION get_id(
+aiv_code                       in     WORK_T.code%TYPE)
+return                                WORK_T.id%TYPE is
+
+n_work_id                             WORK_T.id%TYPE;
+
+begin
+  select id
+  into   n_work_id
+  from   WORK_T
+  where  code = aiv_code;
+
+  return n_work_id;
+end get_id;
+  
+FUNCTION random(
+ain_min                        in     number,
+ain_max                        in     number )
+return                                number is
+
+begin
+  return round(SYS.DBMS_RANDOM.value(ain_min, ain_max), 0);
+end random;
+  
+begin
+  WORK_ASSIGNMENT_TS.n_inserted := 0;
+  WORK_ASSIGNMENT_TS.n_updated  := 0;
+  
+  for r_logical_assignment in c_logical_assignment loop
+    if    r_logical_assignment.code = 'VDMI' then
+      r_work_assignment.id                 := NULL;
+      r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+      r_work_assignment.work_id            := get_id('P0');
+      r_work_assignment.active_date        := r_logical_assignment.active_date;
+      r_work_assignment.inactive_date      := r_logical_assignment.inactive_date;
+      WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+    elsif r_logical_assignment.code = 'SALE' then
+      r_work_assignment.id                 := NULL;
+      r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+      r_work_assignment.work_id            := get_id('V0');
+      r_work_assignment.active_date        := r_logical_assignment.active_date;
+      r_work_assignment.inactive_date      := r_logical_assignment.inactive_date;
+      WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+    elsif r_logical_assignment.code = 'MKTG' then
+      r_work_assignment.id                 := NULL;
+      r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+      r_work_assignment.work_id            := get_id('V0');
+      r_work_assignment.active_date        := r_logical_assignment.active_date;
+      r_work_assignment.inactive_date      := r_logical_assignment.inactive_date;
+      WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+    elsif r_logical_assignment.code = 'ACCT' then
+      r_work_assignment.id                 := NULL;
+      r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+      r_work_assignment.work_id            := get_id('V0');
+      r_work_assignment.active_date        := r_logical_assignment.active_date;
+      r_work_assignment.inactive_date      := r_logical_assignment.inactive_date;
+      WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+    elsif r_logical_assignment.code = 'PDEV' then
+      r_work_assignment.id                 := NULL;
+      r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+      r_work_assignment.work_id            := get_id('V0');
+      r_work_assignment.active_date        := r_logical_assignment.active_date;
+      r_work_assignment.inactive_date      := r_logical_assignment.inactive_date;
+      WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+    elsif r_logical_assignment.code = 'MFG'  then
+      r_work_assignment.id                 := NULL;
+      r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+      r_work_assignment.work_id            := get_id('V0');
+      r_work_assignment.active_date        := r_logical_assignment.active_date;
+      r_work_assignment.inactive_date      := r_logical_assignment.inactive_date;
+      WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+    elsif r_logical_assignment.code in ('BIO', 'CHEM', 'DISP', 'METL', 'RUSE') then
+      if c_logical_assignment%rowcount > 18 then
+        n_random := random(1, 3);
+        if    n_random = 1 then
+          n_random := random(1, 3);
+          for i in 1..n_random loop
+            r_work_assignment.id := NULL;
+            r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+            if    i = 1 then
+              r_work_assignment.work_id          := get_id('O1');
+              r_work_assignment.active_date      := r_logical_assignment.active_date;
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            elsif i = 2 then
+              r_work_assignment.work_id          := get_id('O2');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            else
+              r_work_assignment.work_id          := get_id('O3');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            end if;
+            WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+          end loop;
+        elsif n_random = 2 then
+          n_random := random(1, 3);
+          for i in 1..n_random loop
+            r_work_assignment.id := NULL;
+            r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+            if    i = 1 then
+              r_work_assignment.work_id          := get_id('E1');
+              r_work_assignment.active_date      := r_logical_assignment.active_date;
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            elsif i = 2 then
+              r_work_assignment.work_id          := get_id('E2');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            else
+              r_work_assignment.work_id          := get_id('E3');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            end if;
+            WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+          end loop;
+        else
+          n_random := random(1, 3);
+          for i in 1..n_random loop
+            r_work_assignment.id := NULL;
+            r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+            if    i = 1 then
+              r_work_assignment.work_id          := get_id('W1');
+              r_work_assignment.active_date      := r_logical_assignment.active_date;
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            elsif i = 2 then
+              r_work_assignment.work_id          := get_id('W2');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            else
+              r_work_assignment.work_id          := get_id('W3');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            end if;
+            WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+          end loop;
+        end if;  
+      else
+        r_work_assignment.id := NULL;
+        r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+        r_work_assignment.work_id            := get_id('D0');
+        r_work_assignment.active_date        := r_logical_assignment.active_date;
+        r_work_assignment.inactive_date      := r_logical_assignment.inactive_date;
+        WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+      end if;
+    elsif r_logical_assignment.code = 'HR'   then
+      if c_logical_assignment%rowcount > 18 then
+        n_random := random(1, 3);
+        if    n_random = 1 then
+          n_random := random(1, 3);
+          for i in 1..n_random loop
+            r_work_assignment.id := NULL;
+            r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+            if    i = 1 then
+              r_work_assignment.work_id          := get_id('A1');
+              r_work_assignment.active_date      := r_logical_assignment.active_date;
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            elsif i = 2 then
+              r_work_assignment.work_id          := get_id('A2');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            else
+              r_work_assignment.work_id          := get_id('A3');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            end if;
+            WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+          end loop;
+        elsif n_random = 2 then
+          n_random := random(1, 3);
+          for i in 1..n_random loop
+            r_work_assignment.id := NULL;
+            r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+            if    i = 1 then
+              r_work_assignment.work_id          := get_id('C1');
+              r_work_assignment.active_date      := r_logical_assignment.active_date;
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            elsif i = 2 then
+              r_work_assignment.work_id          := get_id('C2');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            else
+              r_work_assignment.work_id          := get_id('C3');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            end if;
+            WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+          end loop;
+        else
+          n_random := random(1, 3);
+          for i in 1..n_random loop
+            r_work_assignment.id := NULL;
+            r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+            if    i = 1 then
+              r_work_assignment.work_id          := get_id('M0');
+              r_work_assignment.active_date      := r_logical_assignment.active_date;
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            elsif i = 2 then
+              r_work_assignment.work_id          := get_id('A1');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            else
+              r_work_assignment.work_id          := get_id('C1');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            end if;
+            WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+          end loop;
+        end if;  
+      else
+        r_work_assignment.id := NULL;
+        r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+        r_work_assignment.work_id            := get_id('D0');
+        r_work_assignment.active_date        := r_logical_assignment.active_date;
+        r_work_assignment.inactive_date      := r_logical_assignment.inactive_date;
+        WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+      end if;
+    elsif r_logical_assignment.code = 'IT'   then
+      r_work_assignment.id := NULL;
+      r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+      r_work_assignment.work_id := get_id('D0');
+      r_work_assignment.active_date        := r_logical_assignment.active_date;
+      r_work_assignment.inactive_date      := r_logical_assignment.inactive_date;
+      WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+    elsif r_logical_assignment.code in ('DP', 'HSUP', 'SDEV', 'SINT', 'SSUP') then
+      if c_logical_assignment%rowcount > 18 then
+        n_random := random(1, 3);
+        if    n_random = 1 then
+          n_random := random(1, 3);
+          for i in 1..n_random loop
+            r_work_assignment.id := NULL;
+            r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+            if    i = 1 then
+              r_work_assignment.work_id          := get_id('A1');
+              r_work_assignment.active_date      := r_logical_assignment.active_date;
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            elsif i = 2 then
+              r_work_assignment.work_id          := get_id('A2');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            else
+              r_work_assignment.work_id          := get_id('A3');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            end if;
+            WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+          end loop;
+        elsif n_random = 2 then
+          n_random := random(1, 3);
+          for i in 1..n_random loop
+            r_work_assignment.id := NULL;
+            r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+            if    i = 1 then
+              r_work_assignment.work_id          := get_id('P1');
+              r_work_assignment.active_date      := r_logical_assignment.active_date;
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            elsif i = 2 then
+              r_work_assignment.work_id          := get_id('P2');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            else
+              r_work_assignment.work_id          := get_id('P3');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            end if;
+            WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+          end loop;
+        else
+          n_random := random(1, 3);
+          for i in 1..n_random loop
+            r_work_assignment.id := NULL;
+            r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+            if    i = 1 then
+              r_work_assignment.work_id          := get_id('Y0');
+              r_work_assignment.active_date      := r_logical_assignment.active_date;
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            elsif i = 2 then
+              r_work_assignment.work_id          := get_id('Y1');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            else
+              r_work_assignment.work_id          := get_id('Y1');
+              r_work_assignment.active_date      := trunc(r_work_assignment.inactive_date + 1);
+              r_work_assignment.inactive_date    := DATES.end_of_day(r_work_assignment.active_date + (
+                (nvl(r_logical_assignment.inactive_date, SYSDATE + 1) - r_logical_assignment.active_date)*(1/n_random)));
+            end if;
+            WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+          end loop;
+        end if;  
+      else
+        r_work_assignment.id := NULL;
+        r_work_assignment.worker_id          := r_logical_assignment.worker_id; 
+        r_work_assignment.work_id            := get_id('M0');
+        r_work_assignment.active_date        := r_logical_assignment.active_date;
+        r_work_assignment.inactive_date      := r_logical_assignment.inactive_date;
+        WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+      end if;
+    else
+      raise_application_error(-20000, 'Unsupported code');
+    end if;
+    
+  end loop;
+   
+  update work_assignment_t
+  set    inactive_date = NULL
+  where  inactive_date > SYSDATE;
+
+  commit;
+
+  pl(to_char(WORK_ASSIGNMENT_TS.n_inserted)||' rows inserted.');
+  pl(to_char(WORK_ASSIGNMENT_TS.n_updated)||' rows updated.');
+ end;
+ /
+ 
\ No newline at end of file
diff --git a/Chapter10/work_assignment_ts.pkb b/Chapter10/work_assignment_ts.pkb
new file mode 100644
index 0000000..56aa550
--- /dev/null
+++ b/Chapter10/work_assignment_ts.pkb
@@ -0,0 +1,656 @@
+create or replace PACKAGE BODY WORK_ASSIGNMENT_TS as
+/*
+work_assignment_ts.pkb
+by Donald J. Bales on 12/15/2006
+Table WORK_ASSIGNMENT_T's methods
+*/
+
+
+FUNCTION get_id
+return                                WORK_ASSIGNMENT_T.id%TYPE is
+
+n_id                                  WORK_ASSIGNMENT_T.id%TYPE;
+
+begin
+  select WORK_ASSIGNMENT_ID_SEQ.nextval 
+  into   n_id
+  from   SYS.DUAL;
+
+  return n_id;
+end get_id;
+
+
+FUNCTION get_work(
+ain_worker_id                  in     WORK_ASSIGNMENT_T.worker_id%TYPE,
+aid_on                         in     WORK_ASSIGNMENT_T.active_date%TYPE)
+return                                WORK_T%ROWTYPE is
+
+r_work                                WORK_T%ROWTYPE;
+
+begin
+  select *
+  into   r_work
+  from   WORK_T
+  where  id = (
+  select work_id
+  from   WORK_ASSIGNMENT_T
+  where  worker_id = ain_worker_id
+  and    aid_on between active_date and nvl(inactive_date, DATES.d_MAX) );
+  
+  return r_work;
+end get_work;
+
+
+FUNCTION get_work(
+ain_worker_id                  in     WORK_ASSIGNMENT_T.worker_id%TYPE)
+return                                WORK_T%ROWTYPE is
+
+begin
+  return get_work(ain_worker_id, SYSDATE);
+end get_work;
+
+
+FUNCTION get_row(
+air_work_assignment            in     WORK_ASSIGNMENT_T%ROWTYPE)
+return                                WORK_ASSIGNMENT_T%ROWTYPE is
+
+r_work_assignment                     WORK_ASSIGNMENT_T%ROWTYPE;
+
+begin
+  if    air_work_assignment.id is not NULL then
+    -- retrieve the row by the primary key
+    select *
+    into   r_work_assignment
+    from   WORK_ASSIGNMENT_T
+    where  id = air_work_assignment.id;
+  else
+    -- retrieve the row by the worker_id and active_date
+    select *
+    into   r_work_assignment
+    from   WORK_ASSIGNMENT_T
+    where  worker_id   = air_work_assignment.worker_id
+    and    active_date = air_work_assignment.active_date;
+  end if;  
+  return r_work_assignment;
+exception
+  when NO_DATA_FOUND then
+    raise;
+  when OTHERS then
+    raise_application_error(-20001, SQLERRM||
+      ' on select WORK_ASSIGNMENT_T'||
+      ' in WORK_ASSIGNMENT_TS.get_row()');
+end get_row;  
+
+
+PROCEDURE help is
+
+begin
+  TEXT_HELP.process('WORK_ASSIGNMENT_TS');
+end help;
+
+
+FUNCTION is_active(
+ain_worker_id                  in     WORK_ASSIGNMENT_T.worker_id%TYPE,
+aid_on                         in     date)
+return                                boolean is
+
+n_count                               number;
+
+begin
+ select count(1)
+ into   n_count
+ from   WORK_ASSIGNMENT_T
+ where  worker_id       = ain_worker_id
+ and    aid_on    between active_date 
+                      and nvl(inactive_date, DATES.d_MAX);
+
+ if nvl(n_count,0) > 0 then
+  return TRUE;
+ else
+  return FALSE;
+ end if;
+end is_active;
+
+
+FUNCTION is_active(
+ain_worker_id                  in     WORK_ASSIGNMENT_T.worker_id%TYPE)
+return                                boolean is
+
+begin
+ return is_active(ain_worker_id, SYSDATE);
+end is_active;
+
+
+FUNCTION is_history(
+ain_worker_id                  in     WORK_ASSIGNMENT_T.worker_id%TYPE,
+aid_active_date                in     WORK_ASSIGNMENT_T.active_date%TYPE,
+aid_inactive_date              in     WORK_ASSIGNMENT_T.inactive_date%TYPE)
+return                                boolean is
+
+pragma autonomous_transaction;
+
+n_count                               number;
+
+begin
+  select count(1)
+  into   n_count
+  from   WORK_ASSIGNMENT_T
+  where  worker_id                        = ain_worker_id
+  and    active_date                     <= 
+           nvl(aid_inactive_date, DATES.d_MAX)
+  and    nvl(inactive_date, DATES.d_MAX) >= aid_active_date;
+  commit; 
+
+  if nvl(n_count,0) > 0 then
+    return TRUE;
+  else
+    return FALSE;
+  end if;
+end is_history;
+
+
+PROCEDURE set_row(
+aior_work_assignment           in out WORK_ASSIGNMENT_T%ROWTYPE) is
+
+d_null                       constant date        := DATES.d_MIN;
+n_null                       constant number      := 0;
+v_null                       constant varchar2(1) := ' ';
+r_work_assignment                     WORK_ASSIGNMENT_T%ROWTYPE;
+
+begin
+  -- get the existing row
+  begin
+    r_work_assignment := get_row(aior_work_assignment);
+  exception
+    when NO_DATA_FOUND then
+      r_work_assignment := NULL;
+  end;
+  -- if a row exists, update it if needed
+  if r_work_assignment.id is not NULL then
+    aior_work_assignment.id := r_work_assignment.id;
+    aior_work_assignment.worker_id          := r_work_assignment.worker_id;
+    aior_work_assignment.active_date        := r_work_assignment.active_date;
+    if nvl(r_work_assignment.work_id,       n_null) <> nvl(aior_work_assignment.work_id,       n_null) or
+       nvl(r_work_assignment.inactive_date, d_null) <> nvl(aior_work_assignment.inactive_date, d_null) then
+      begin
+        update WORK_ASSIGNMENT_T
+        set    work_id            = aior_work_assignment.work_id,
+               inactive_date      = aior_work_assignment.inactive_date
+        where  id = aior_work_assignment.id;
+
+        n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0);
+      exception
+        when OTHERS then
+          raise_application_error( -20002, SQLERRM||
+            ' on update WORK_ASSIGNMENT_T'||
+            ' in WORK_ASSIGNMENT_TS.set_row()' );
+      end;
+    end if;
+  else
+  -- add the row if it does not exist
+    begin
+      if aior_work_assignment.id is NULL then
+        aior_work_assignment.id := get_id();
+      end if;
+      insert into WORK_ASSIGNMENT_T (
+             id,
+             worker_id,
+             work_id,
+             active_date,
+             inactive_date )
+      values (
+             aior_work_assignment.id,
+             aior_work_assignment.worker_id,
+             aior_work_assignment.work_id,
+             aior_work_assignment.active_date,
+             aior_work_assignment.inactive_date );
+
+      n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0);
+    exception
+      when OTHERS then
+        raise_application_error( -20003, SQLERRM||
+          ' on insert WORK_ASSIGNMENT_T'||
+          ' in WORK_ASSIGNMENT_TS.set_row()' );
+    end;
+  end if;
+end set_row;
+
+
+PROCEDURE test is
+
+n_work_id                             WORK_T.id%TYPE;
+n_work_id_1                           WORK_T.id%TYPE;
+n_work_id_2                           WORK_T.id%TYPE;
+n_worker_id                           WORKER_T.id%TYPE;
+n_worker_id_1                         WORKER_T.id%TYPE;
+n_worker_id_2                         WORKER_T.id%TYPE;
+r_worker                              WORKER_T%ROWTYPE;
+r_work                                WORK_T%ROWTYPE;
+r_work_assignment                     WORK_ASSIGNMENT_T%ROWTYPE;
+
+begin
+  pl('WORK_ASSIGNMENT_TS.test()');
+  
+  TEST_TS.clear('WORK_ASSIGNMENT_TS');
+  
+  -- In order to make entries into an Intersection table
+  -- you first have to have entries in the two tables
+  -- for which an entry will create an intersection
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'DELETE', 0, 
+    'Delete existing test entries from WORK_ASSIGNMENT_T');
+  begin
+    delete WORK_ASSIGNMENT_T
+    where  work_id in (
+    select work_id
+    from   WORK_T
+    where  code in (
+      TEST_TS.v_TEST_30,
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 ) );
+
+    TEST_TS.ok();
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'DELETE', 1, 
+    'Delete existing test entries from WORK_T');
+  begin
+    delete WORK_T
+    where  code in (
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 );
+  
+    delete WORK_T
+    where  code in (
+      TEST_TS.v_TEST_30 );
+  
+    TEST_TS.ok;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'DELETE', 2, 
+    'Delete existing test entries from WORKER_T');
+  begin
+    delete WORKER_T
+    where  external_id in (  
+      TEST_TS.v_TEST_30,
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 );
+  
+    TEST_TS.ok();
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'INSERT', 3, 
+    'Insert WORKER_T test entries using set_row()');
+  begin
+    r_worker.id             := WORKER_TS.get_id();
+    r_worker.worker_type_id := WORKER_TYPE_TS.get_id('E');
+    r_worker.external_id    := TEST_TS.v_TEST_30;
+    r_worker.first_name     := TEST_TS.v_TEST_30;
+    r_worker.middle_name    := TEST_TS.v_TEST_30;
+    r_worker.last_name      := TEST_TS.v_TEST_30;
+    r_worker.name           := WORKER_TS.get_formatted_name(
+      r_worker.first_name,
+      r_worker.middle_name,
+      r_worker.last_name);
+    r_worker.birth_date     := to_date('19800101', 'YYYYMMDD');   
+    r_worker.gender_id      := GENDER_TS.get_id('M');
+    WORKER_TS.set_row(r_worker);
+    n_worker_id             := r_worker.id;
+
+    r_worker.id             := WORKER_TS.get_id();
+    r_worker.worker_type_id := WORKER_TYPE_TS.get_id('E');
+    r_worker.external_id    := TEST_TS.v_TEST_30_1;
+    r_worker.first_name     := TEST_TS.v_TEST_30_1;
+    r_worker.middle_name    := TEST_TS.v_TEST_30_1;
+    r_worker.last_name      := TEST_TS.v_TEST_30_1;
+    r_worker.name           := WORKER_TS.get_formatted_name(
+      r_worker.first_name,
+      r_worker.middle_name,
+      r_worker.last_name);
+    r_worker.birth_date     := to_date('19700101', 'YYYYMMDD');   
+    r_worker.gender_id      := GENDER_TS.get_id('F');
+    WORKER_TS.set_row(r_worker);
+    n_worker_id_1           := r_worker.id;
+
+    r_worker.id             := WORKER_TS.get_id();
+    r_worker.worker_type_id := WORKER_TYPE_TS.get_id('C');
+    r_worker.external_id    := TEST_TS.v_TEST_30_2;
+    r_worker.first_name     := TEST_TS.v_TEST_30_2;
+    r_worker.middle_name    := TEST_TS.v_TEST_30_2;
+    r_worker.last_name      := TEST_TS.v_TEST_30_2;
+    r_worker.name           := WORKER_TS.get_formatted_name(
+      r_worker.first_name,
+      r_worker.middle_name,
+      r_worker.last_name);
+    r_worker.birth_date     := to_date('19600101', 'YYYYMMDD');   
+    r_worker.gender_id      := GENDER_TS.get_id('M');
+    WORKER_TS.set_row(r_worker);
+    n_worker_id_2           := r_worker.id;
+  
+    TEST_TS.ok();
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'INSERT', 4, 
+    'Insert WORK_T test entries using set_row()');
+  begin
+    r_work.id                   := WORK_TS.get_id();
+    r_work.code                 := TEST_TS.v_TEST_30;
+    r_work.name                 := TEST_TS.v_TEST_80;
+    r_work.active_date          := TEST_TS.d_TEST_19000101;
+    r_work.inactive_date        := NULL;
+    WORK_TS.set_row(r_work);
+    n_work_id                   := r_work.id;
+
+    r_work.id                   := WORK_TS.get_id();
+    r_work.code                 := TEST_TS.v_TEST_30_1;
+    r_work.name                 := TEST_TS.v_TEST_80;
+    r_work.active_date          := TEST_TS.d_TEST_19000101;
+    r_work.inactive_date        := NULL;
+    WORK_TS.set_row(r_work);
+    n_work_id_1                 := r_work.id;
+
+    r_work.id                   := WORK_TS.get_id();
+    r_work.code                 := TEST_TS.v_TEST_30_2;
+    r_work.name                 := TEST_TS.v_TEST_80;
+    r_work.active_date          := TEST_TS.d_TEST_19000101;
+    r_work.inactive_date        := NULL;
+    WORK_TS.set_row(r_work);
+    n_work_id_2                 := r_work.id;
+
+    TEST_TS.ok();
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  -- Now that I have entries in the two tables being intersected
+  -- I can now start testing this package...
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'get_id()', 5, 
+    'Allocate the next primary key value using get_id()');
+  begin
+    r_work_assignment.id := 
+      WORK_ASSIGNMENT_TS.get_id();
+    
+    if nvl(r_work_assignment.id, 0) > 0 then
+      TEST_TS.ok();
+    else
+      TEST_TS.error();
+    end if;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'set_row()', 6, 
+    'Insert history for v_TEST_30 using set_row()');
+  begin
+    r_work_assignment.worker_id            := n_worker_id;
+    r_work_assignment.work_id := 
+      n_work_id_2;
+    r_work_assignment.active_date          := 
+      to_date('20000101', 'YYYYMMDD');
+    r_work_assignment.inactive_date        := NULL;
+    WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+  
+    TEST_TS.ok;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'set_row()', 7, 
+    'Insert history for V_TEST_30_1 using set_row()');
+  begin
+    r_work_assignment.id := 
+      WORK_ASSIGNMENT_TS.get_id();
+    r_work_assignment.worker_id            := n_worker_id_1;
+    r_work_assignment.work_id := 
+      n_work_id_1;
+    r_work_assignment.active_date          := 
+      to_date('19900101', 'YYYYMMDD');
+    r_work_assignment.inactive_date        := 
+      to_date('19991231', 'YYYYMMDD');
+    WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+  
+    r_work_assignment.id := 
+      WORK_ASSIGNMENT_TS.get_id();
+    r_work_assignment.worker_id            := n_worker_id_1;
+    r_work_assignment.work_id := 
+      n_work_id_2;
+    r_work_assignment.active_date          := 
+      to_date('20000101', 'YYYYMMDD');
+    r_work_assignment.inactive_date        := NULL;
+    WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+  
+    TEST_TS.ok;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'set_row()', 8, 
+    'Insert history for V_TEST_30_2 using set_row()');
+  begin
+    r_work_assignment.id := 
+      WORK_ASSIGNMENT_TS.get_id();
+    r_work_assignment.worker_id            := n_worker_id_2;
+    r_work_assignment.work_id := 
+      n_work_id_1;
+    r_work_assignment.active_date          := 
+      to_date('19800101', 'YYYYMMDD');
+    r_work_assignment.inactive_date        := 
+      to_date('19891231', 'YYYYMMDD');
+    WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+  
+    r_work_assignment.id := 
+      WORK_ASSIGNMENT_TS.get_id();
+    r_work_assignment.worker_id            := n_worker_id_2;
+    r_work_assignment.work_id := 
+      n_work_id_2;
+    r_work_assignment.active_date          := 
+      to_date('19900101', 'YYYYMMDD');
+    r_work_assignment.inactive_date        := 
+      to_date('19901231', 'YYYYMMDD');
+    WORK_ASSIGNMENT_TS.set_row(r_work_assignment);
+  
+    TEST_TS.ok;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  -- Commit the deletes and inserts
+  commit;
+  
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 
+    'get_work()', 9, 
+    'Get the current work workplace for v_TEST_30');
+  begin
+    r_work := NULL;
+    r_work := get_work(n_worker_id);
+  
+    if nvl(r_work.id, 0) > 0 then
+      TEST_TS.ok();
+    else
+      TEST_TS.error();
+    end if;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 
+    'get_work()', 10, 
+    'Get the work workplace on 6/30/1995 for v_TEST_30_1');
+  begin
+    r_work := NULL;
+    r_work := get_work(
+      n_worker_id_1,
+      to_date('19950630', 'YYYYMMDD'));
+  
+    if nvl(r_work.id, 0) > 0 then
+      TEST_TS.ok();
+    else
+      TEST_TS.error();
+    end if;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 
+    'get_work()', 11, 
+    'Get the work workplace on 6/30/1995 for v_TEST_30_2');
+  begin
+    -- this should fail
+    r_work := NULL;
+    r_work := get_work(
+      n_worker_id_2,
+      to_date('19950630', 'YYYYMMDD'));
+  
+    if nvl(r_work.id, 0) > 0 then
+      TEST_TS.error();
+    else
+      TEST_TS.ok();
+    end if;
+  exception
+    when NO_DATA_FOUND then
+      TEST_TS.ok();
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'help()', 12, 
+    'Test help()');
+  begin
+    help();  
+  
+    TEST_TS.ok;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'is_active()', 13, 
+    'Is there an active assignment on 6/30/1995 for v_TEST_30?');
+    -- No
+  begin
+    if is_active(n_worker_id, to_date('19950630', 'YYYYMMDD')) then
+      TEST_TS.error();
+    else
+      TEST_TS.ok();
+    end if;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'is_active()', 14, 
+    'Is there an active assignment on 6/30/1995 for v_TEST_30_1?');
+    -- Yes
+  begin
+    if is_active(n_worker_id_1, to_date('19950630', 'YYYYMMDD')) then
+      TEST_TS.ok();
+    else
+      TEST_TS.error();
+    end if;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'is_active()', 15, 
+    'Is there currently an active assignment for v_TEST_30_2?');
+    -- No
+  begin
+    if is_active(n_worker_id_2) then
+      TEST_TS.error();
+    else
+      TEST_TS.ok();
+    end if;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  -- Now clean up after the tests by deleting the test entries
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'DELETE', 16, 
+    'Delete existing test entries from WORK_ASSIGNMENT_T');
+  begin
+    delete WORK_ASSIGNMENT_T
+    where  work_id in (
+    select work_id
+    from   WORK_T
+    where  code in (
+      TEST_TS.v_TEST_30,
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 ) );
+
+    delete WORK_ASSIGNMENT_T
+    where  worker_id in (
+    select worker_id
+    from   WORKER_T
+    where  external_id in (  
+      TEST_TS.v_TEST_30,
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 ) );
+      
+    TEST_TS.ok();
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'DELETE', 17, 
+    'Delete existing test entries from WORK_T');
+  begin
+    delete WORK_T
+    where  code in (
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 );
+  
+    delete WORK_T
+    where  code in (
+      TEST_TS.v_TEST_30 );
+  
+    TEST_TS.ok;
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', 'DELETE', 18, 
+    'Delete existing test entries from WORKER_T');
+  begin
+    delete WORKER_T
+    where  external_id in (  
+      TEST_TS.v_TEST_30,
+      TEST_TS.v_TEST_30_1,
+      TEST_TS.v_TEST_30_2 );
+  
+    TEST_TS.ok();
+  exception
+    when OTHERS then 
+      TEST_TS.error(SQLERRM);
+  end;
+
+  commit;
+  TEST_TS.set_test('WORK_ASSIGNMENT_TS', NULL, NULL, NULL);
+  TEST_TS.success();
+end test;
+
+
+end WORK_ASSIGNMENT_TS;
+/
+@be.sql WORK_ASSIGNMENT_TS
diff --git a/Chapter10/work_assignment_ts.pks b/Chapter10/work_assignment_ts.pks
new file mode 100644
index 0000000..6592554
--- /dev/null
+++ b/Chapter10/work_assignment_ts.pks
@@ -0,0 +1,92 @@
+create or replace PACKAGE WORK_ASSIGNMENT_TS as
+/*
+work_assignment_ts.pks
+by Donald J. Bales on 12/15/2006
+Table WORK_ASSIGNMENT_T's methods
+*/
+
+-- GLOBAL VARIABLES
+-- Keep track of the number of inserts and updates to made by set_row().
+n_inserted                            number := 0;
+n_updated                             number := 0;
+
+/*
+Returns a new primary key id value for a row.
+*/
+FUNCTION get_id
+return                                WORK_ASSIGNMENT_T.id%TYPE;
+
+/*
+Returns a the WORK row for the specified worker_id and on the specified date.
+*/
+FUNCTION get_work(
+ain_worker_id                  in     WORK_ASSIGNMENT_T.worker_id%TYPE,
+aid_on                         in     WORK_ASSIGNMENT_T.active_date%TYPE)
+return                                WORK_T%ROWTYPE;
+
+/*
+Returns a the current WORK row for the specified worker_id.
+*/
+FUNCTION get_work(
+ain_worker_id                  in     WORK_ASSIGNMENT_T.worker_id%TYPE)
+return                                WORK_T%ROWTYPE;
+
+/* 
+Returns a WORK_ASSIGNMENT row for the specified criteria.
+
+There are two sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the woker_id and active_date
+
+If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_work_assignment in WORK_ASSIGNMENT_T%ROWTYPE) +return WORK_ASSIGNMENT_T%ROWTYPE; + +/* + Test-based help for this package. "set serveroutput on" in SQL*Plus. +*/ +PROCEDURE help; + +/* +Returns TRUE if the worker has a work assignment on the specified date, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in WORK_ASSIGNMENT_T.worker_id%TYPE, +aid_on in date) +return boolean; + +/* +Returns TRUE if the worker currently has a work assignment, otherwise FALSE. +*/ +FUNCTION is_active( +ain_worker_id in WORK_ASSIGNMENT_T.worker_id%TYPE) +return boolean; + +/* +Updates or inserts a row matching the passed row into table WORK_WORKPLACE_T. +
+First, set_row( ) calls get_row( ) to try to find a matching row that already +exists in the database. So you need to set the id, or worked_id +and active_date appropriately in order to properly detect an existing row.
+
+Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise a new row is inserted, including the allocation of +a new primary key value. Upon inserting a new value, the id +value is updated in the passed row.
+See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_work_assignment in out WORK_ASSIGNMENT_T%ROWTYPE); + +/* +The test unit for this package. +*/ +PROCEDURE test; + + +end WORK_ASSIGNMENT_TS; +/ +@be.sql WORK_ASSIGNMENT_TS diff --git a/Chapter10/work_t.ins b/Chapter10/work_t.ins new file mode 100644 index 0000000..b1c69e8 --- /dev/null +++ b/Chapter10/work_t.ins @@ -0,0 +1,36 @@ +rem work_ts.ins +rem by Donald J. Bales on 12/15/2006 +rem Seed the WORK_T table + +declare + +begin + WORK_TS.set_row('P0', 'PRESIDENT', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('V0', 'VICE PRESIDENT', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('D0', 'DIRECTOR', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('M0', 'MANAGER', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('E1', 'ENGINEER 1', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('E2', 'ENGINEER 2', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('E3', 'ENGINEER 3', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('O1', 'OPERATOR 1', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('O2', 'OPERATOR 2', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('O3', 'OPERATOR 3', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('W1', 'WELDER 1', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('W2', 'WELDER 2', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('W3', 'WELDER 3', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('A1', 'ADMINISTRATOR 1', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('A2', 'ADMINISTRATOR 2', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('A3', 'ADMINISTRATOR 3', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('C1', 'CLERK 1', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('C2', 'CLERK 2', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('C3', 'CLERK 3', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('P1', 'PROGRAMMER 1', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('P2', 'PROGRAMMER 2', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('P3', 'PROGRAMMER 3', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('Y1', 'ANALYST 1', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('Y2', 'ANALYST 2', to_date('19600101', 'YYYYMMDD'), NULL); + WORK_TS.set_row('Y3', 'ANALYST 3', to_date('19600101', 'YYYYMMDD'), NULL); + + commit; +end; +/ diff --git a/Chapter10/work_ts.pkb b/Chapter10/work_ts.pkb new file mode 100644 index 0000000..dfbcc71 --- /dev/null +++ b/Chapter10/work_ts.pkb @@ -0,0 +1,358 @@ +create or replace PACKAGE BODY WORK_TS as +/* +work_ts.pkb +by Donald J. Bales on 12/15/2006 +Table WORK_T's methods +*/ + + +FUNCTION get_id +return WORK_T.id%TYPE is + +n_id WORK_T.id%TYPE; + +begin + select WORK_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_row( +air_work in WORK_T%ROWTYPE) +return WORK_T%ROWTYPE is + +r_work WORK_T%ROWTYPE; + +begin + if air_work.id is not NULL then + --pl('retrieve the row by the primary key'); + select * + into r_work + from WORK_T + where id = air_work.id; + else + --pl('retrieve the row by the code, name, and active_date'); + select * + into r_work + from WORK_T + where code = air_work.code + and name = air_work.name + and active_date = air_work.active_date; + end if; + return r_work; +exception + when NO_DATA_FOUND then + raise; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select WORK_T'|| + ' in WORK_TS.get_row()'); +end get_row; + + +PROCEDURE inactivate( +ain_id in WORK_T.id%TYPE, +aid_inactive_date in WORK_T.inactive_date%TYPE) is + +begin + update WORK_T + set inactive_date = aid_inactive_date + where id = ain_id; +end inactivate; + + +FUNCTION is_duplicate( +aiv_code in WORK_T.code%TYPE, +aiv_name in WORK_T.name%TYPE, +aid_active_date in WORK_T.active_date%TYPE) +return boolean is + +n_count number; + +begin + --pl('retrieve the row by the code, name, and active_date'); + select count(1) + into n_count + from WORK_T + where code = aiv_code + and name = aiv_name + and trunc(active_date) = trunc(aid_active_date); + + if nvl(n_count, 0) > 0 then + return TRUE; + else + return FALSE; + end if; +end is_duplicate; + + +PROCEDURE help is + +begin + TEXT_HELP.process('WORK_TS'); +end help; + + +PROCEDURE set_row( +aior_work in out WORK_T%ROWTYPE) is + +d_null constant date := DATES.d_MIN; +n_null constant number := 0; +v_null constant varchar2(1) := ' '; +r_work WORK_T%ROWTYPE; + +begin + -- get the existing row + begin + r_work := get_row(aior_work); + exception + when NO_DATA_FOUND then + r_work := NULL; + end; + -- if a row exists, update it if needed + if r_work.id is not NULL then + aior_work.id := r_work.id; + if nvl(r_work.code, v_null) <> nvl(aior_work.code, v_null) or + nvl(r_work.name, v_null) <> nvl(aior_work.name, v_null) or + nvl(r_work.active_date, d_null) <> nvl(aior_work.active_date, d_null) or + nvl(r_work.inactive_date, d_null) <> nvl(aior_work.inactive_date, d_null) then + begin + update WORK_T + set code = aior_work.code, + name = aior_work.name, + active_date = aior_work.active_date, + inactive_date = aior_work.inactive_date + where id = aior_work.id; + + n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20002, SQLERRM|| + ' on update WORK_T'|| + ' in WORK_TS.set_row()' ); + end; + end if; + else + -- add the row if it does not exist + begin + if aior_work.id is NULL then + aior_work.id := get_id(); + end if; + insert into WORK_T ( + id, + code, + name, + active_date, + inactive_date ) + values ( + aior_work.id, + aior_work.code, + aior_work.name, + aior_work.active_date, + aior_work.inactive_date ); + + n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20003, SQLERRM|| + ' on insert WORK_T'|| + ' in WORK_TS.set_row()' ); + end; + end if; +end set_row; + + +PROCEDURE set_row( +aiv_code in WORK_T.code%TYPE, +aiv_name in WORK_T.name%TYPE, +aid_active_date in WORK_T.active_date%TYPE, +aid_inactive_date in WORK_T.inactive_date%TYPE) is + +r_work WORK_T%ROWTYPE; + +begin + r_work.id := NULL; + r_work.code := aiv_code; + r_work.name := aiv_name; + r_work.active_date := aid_active_date; + r_work.inactive_date := aid_inactive_date; + + set_row(r_work); +end set_row; + + +PROCEDURE test is + +r_work WORK_T%ROWTYPE; + +begin + pl('WORK_TS.test()'); + + TEST_TS.clear('WORK_TS'); + + TEST_TS.set_test('WORK_TS', 'DELETE', 0, + 'Delete existing test entries'); + begin + delete WORK_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + + delete WORK_T + where code = TEST_TS.v_TEST_30; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORK_TS', 'get_id()', 1, + 'Allocate the next primary key value'); + begin + r_work.id := get_id(); + + if r_work.id > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORK_TS', 'set_row()', 2, + 'Insert a test entry'); + begin + r_work.code := TEST_TS.v_TEST_30; + r_work.name := TEST_TS.v_TEST_80; + r_work.active_date := TEST_TS.d_TEST_19000101; + r_work.inactive_date := NULL; + + set_row(r_work); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORK_TS', 'set_row()', 3, + 'Insert addistional entries'); + begin + r_work.id := get_id(); + r_work.code := TEST_TS.v_TEST_30_1; + r_work.name := TEST_TS.v_TEST_80; + + set_row(r_work); + + r_work.id := get_id(); + r_work.code := TEST_TS.v_TEST_30_2; + + set_row(r_work); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORK_TS', 'get_row()', 4, + 'Get the row using the id for v_TEST_30_2'); + begin +-- r_work.id := NULL; + r_work.code := NULL; + r_work.name := NULL; + r_work.active_date := NULL; + r_work.inactive_date := NULL; + + r_work := get_row(r_work); + + if r_work.code is not NULL then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORK_TS', 'get_row()', 5, + 'Get the row using the code for v_TEST_30'); + begin + r_work.id := NULL; + r_work.code := TEST_TS.v_TEST_30; + r_work.name := TEST_TS.v_TEST_80; + r_work.active_date := TEST_TS.d_TEST_19000101; + r_work.inactive_date := NULL; + + r_work := get_row(r_work); + + if r_work.id is not NULL then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORK_TS', 'help()', 6, + 'Display the help text'); + begin + help(); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORK_TS', 'is_duplicate()', 7, + 'Is this a duplicate? It should be!'); + begin + if is_duplicate( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101) then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORK_TS', 'DELETE', 8, + 'Delete test entries'); + begin + delete WORK_T + where code in ( + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + + delete WORK_T + where code = TEST_TS.v_TEST_30; + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + commit; + TEST_TS.set_test('WORK_TS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end WORK_TS; +/ +@be.sql WORK_TS diff --git a/Chapter10/work_ts.pks b/Chapter10/work_ts.pks new file mode 100644 index 0000000..eae739e --- /dev/null +++ b/Chapter10/work_ts.pks @@ -0,0 +1,75 @@ +create or replace PACKAGE WORK_TS as +/* +work_ts.pks
+by Donald Bales on 12/15/2006
+Table WORK_T's methods. Contains all the supporting service +methods (functions and procedures) for table WORK_T. +*/ + +-- GLOBAL VARIABLES + +-- Keep track of the number of inserts and updates to made by set_row( ). +n_inserted number := 0; +n_updated number := 0; + +/* +Returns a new primary key id value for a row. +*/ +FUNCTION get_id +return WORK_T.id%TYPE; + +/* +Returns a WORK row for the specified criteria. + +There are three sets of criteria. You can retrieve a row by specifying:
+1. the primary key: id
+2. the unique id_context
+3. the code, name, and active_date
+ +If a match is found the function returns the corresponding row, otherwise +it returns NULL. It will raise any exceptions except NO_DATA_FOUND. +*/ +FUNCTION get_row( +air_work in WORK_T%ROWTYPE) +return WORK_T%ROWTYPE; + +/* +Text-based help for this package. +*/ +PROCEDURE help; + +/* +Updates or inserts a row matching the passed row into table WORK_T. + +First, set_row() calls get row to try to find a matching row that already +exists in the database. So you need to set the id, id_context, +and code, name and active_date appropriately in order to prperly detect an +existing row. + +Next, if an existing row is found, any non-key data items are updated to match +the passed row. Otherwise, and new row is inserted, including the allocation of +a new primary key and id_context value. Upon inserting a new value, the +id and id_context values are updated in the passed row. +See PROCEDURE get_row( ); +*/ +PROCEDURE set_row( +aior_work in out WORK_T%ROWTYPE); + +/* +Parametric version of set_row() +*/ +PROCEDURE set_row( +aiv_code in WORK_T.code%TYPE, +aiv_name in WORK_T.name%TYPE, +aid_active_date in WORK_T.active_date%TYPE, +aid_inactive_date in WORK_T.inactive_date%TYPE); + +/* +Performs unit tests for this package. +*/ +PROCEDURE test; + + +end WORK_TS; +/ +@se.sql WORK_TS diff --git a/Chapter10/worker_ts.pkb b/Chapter10/worker_ts.pkb new file mode 100644 index 0000000..2d6d7c0 --- /dev/null +++ b/Chapter10/worker_ts.pkb @@ -0,0 +1,406 @@ +create or replace PACKAGE BODY WORKER_TS as +/* +worker_ts.pkb +Copyright by Don Bales on 12/15/2006 +Table WORKER_T's methods +*/ + + +-- FUNCTIONS + +FUNCTION get_age( +aid_birth_date in WORKER_T.birth_date%TYPE, +aid_on in date) +return number is + +begin + if aid_birth_date is not NULL and + aid_on is not NULL then + return trunc(months_between(aid_on, aid_birth_date) / 12); + else + return NULL; + end if; +exception + when OTHERS then + return NULL; +end get_age; + + +FUNCTION get_age( +aid_birth_date in WORKER_T.birth_date%TYPE) +return number is + +begin + return get_age(aid_birth_date, SYSDATE); +end get_age; + + +FUNCTION get_age( +ain_id in WORKER_T.id%TYPE, +aid_on in date) +return number is + +begin + return get_age(get_birth_date(ain_id), aid_on); +end get_age; + + +FUNCTION get_age( +ain_id in WORKER_T.id%TYPE) +return number is + +begin + return get_age(get_birth_date(ain_id)); +end get_age; + + +FUNCTION get_birth_date( +ain_id in WORKER_T.id%TYPE) +return WORKER_T.birth_date%TYPE is + +d_birth_date WORKER_T.birth_date%TYPE; + +begin + select birth_date + into d_birth_date + from WORKER_T + where id = ain_id; + + return d_birth_date; +end get_birth_date; + + +FUNCTION get_external_id +return WORKER_T.external_id%TYPE is + +v_external_id WORKER_T.external_id%TYPE; + +begin + select lpad(to_char(EXTERNAL_ID_SEQ.nextval), 9, '0') + into v_external_id + from SYS.DUAL; + + return v_external_id; +end get_external_id; + + +FUNCTION get_id +return WORKER_T.id%TYPE is + +n_id WORKER_T.id%TYPE; + +begin + select WORKER_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_id( +aiv_external_id in WORKER_T.external_id%TYPE) +return WORKER_T.id%TYPE is + +n_id WORKER_T.id%TYPE; + +begin + select id + into n_id + from WORKER_T + where external_id = aiv_external_id; + + return n_id; +end get_id; + + +FUNCTION get_formatted_name( +aiv_first_name in WORKER_T.first_name%TYPE, +aiv_middle_name in WORKER_T.middle_name%TYPE, +aiv_last_name in WORKER_T.last_name%TYPE) +return WORKER_T.name%TYPE is + +begin + return aiv_last_name||', '||aiv_first_name||' '||aiv_middle_name; +end get_formatted_name; + + +FUNCTION get_formatted_name( +ain_id in WORKER_T.id%TYPE) +return WORKER_T.name%TYPE is + +v_first_name WORKER_T.first_name%TYPE; +v_middle_name WORKER_T.middle_name%TYPE; +v_last_name WORKER_T.last_name%TYPE; + +begin + select first_name, + middle_name, + last_name + into v_first_name, + v_middle_name, + v_last_name + from WORKER_T + where id = ain_id; + + return get_formatted_name( + v_first_name, + v_middle_name, + v_last_name); +end get_formatted_name; + + +FUNCTION get_row( +air_worker in WORKER_T%ROWTYPE) +return WORKER_T%ROWTYPE is + +r_worker WORKER_T%ROWTYPE; + +begin + if air_worker.id is not NULL then + -- retrieve the row by the primary key + select * + into r_worker + from WORKER_T + where id = air_worker.id; + elsif air_worker.external_id is not NULL then + -- retrieve the row by the external unique key + select * + into r_worker + from WORKER_T + where external_id = air_worker.external_id; + else + -- retrieve the row by the name, birth_date, and gender + select * + into r_worker + from WORKER_T + where name = get_unformatted_name( + air_worker.first_name, + air_worker.middle_name, + air_worker.last_name) + and birth_date = air_worker.birth_date + and gender_id = air_worker.gender_id; + end if; + return r_worker; +exception + when NO_DATA_FOUND then + raise; + when OTHERS then + raise_application_error(-20001, SQLERRM|| + ' on select WORKER_T'|| + ' in WORKER_TS.get_row()'); +end get_row; + + +FUNCTION get_unformatted_name( +aiv_first_name in WORKER_T.first_name%TYPE, +aiv_middle_name in WORKER_T.middle_name%TYPE, +aiv_last_name in WORKER_T.last_name%TYPE) +return WORKER_T.name%TYPE is + +begin + return upper(replace(replace(replace(replace(replace( + aiv_last_name||aiv_first_name||aiv_middle_name, + '''', NULL), ',', NULL), '-', NULL), '.', NULL), ' ', NULL)); +end get_unformatted_name; + + +FUNCTION is_duplicate( +aiv_name in WORKER_T.name%TYPE, +aid_birth_date in WORKER_T.birth_date%TYPE, +ain_gender_id in WORKER_T.gender_id%TYPE) +return boolean is + +n_selected number; + +begin + select count(1) + into n_selected + from WORKER_T + where name = aiv_name + and birth_date = aid_birth_date + and gender_id = ain_gender_id; + + if nvl(n_selected, 0) > 0 then + return TRUE; + else + return FALSE; + end if; +end is_duplicate; + + +-- PROCEDURES + +PROCEDURE help is + +begin +-- 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('WORKER_TS'); + pl(chr(9)); + pl('----------------------------------- FUNCTIONS ----------------------------------'); + pl(chr(9)); + pl('YOU GOTTA CODE THIS BUDDY WORKER_TS.get_id'); + pl('return WORKER_T.id%TYPE;'); + pl(chr(9)||'Returns a newly allocated sequence value for id.'); + pl(chr(9)); + pl('WORKER_TS.get_id('); + pl('aiv_external_id in WORKER_T.external_id%TYPE )'); + pl('return WORKER_T.id%TYPE;'); + pl(chr(9)||'Returns the corresponding id for the specified external_id.'); + pl(chr(9)); + pl('----------------------------------- PROCEDURES ---------------------------------'); + pl(chr(9)); + pl('WORKER_TS.get_external_id_descr('); + pl('ain_id in WORKER_T.id%TYPE,'); + pl('aov_external_id out WORKER_T.external_id%TYPE,'); + pl('aov_description out WORKER_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding external_id and description for the specified'); + pl(chr(9)||'id.'); + pl(chr(9)); + pl('WORKER_TS.get_external_id_id_descr('); + pl('aiov_external_id in out WORKER_T.external_id%TYPE,'); + pl('aon_id out WORKER_T.id%TYPE,'); + pl('aov_description out WORKER_T.description%TYPE,'); + pl('aid_on in WORKER_T.active%TYPE );'); + pl(chr(9)||'Gets the corresponding external_id, id, and description for'); + pl(chr(9)||'the specified external_id. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified external_id and point in time.'); + pl(chr(9)); + pl('WORKER_TS.get_external_id_id_descr('); + pl('aiov_external_id in out WORKER_T.external_id%TYPE,'); + pl('aon_id out WORKER_T.id%TYPE,'); + pl('aov_description out WORKER_T.description%TYPE );'); + pl(chr(9)||'Gets the corresponding external_id, id, and description for'); + pl(chr(9)||'the specified external_id. First it trys to find an exact match. If one'); + pl(chr(9)||'cannot be found, it trys to find a like match. It may throw a'); + pl(chr(9)||'NO_DATA_FOUND or a TOO_MANY_ROWS exception if a match cannot be'); + pl(chr(9)||'found for the specified external_id at the current point in time.'); + pl(chr(9)); + pl('WORKER_TS.help( );'); + pl(chr(9)||'Displays this help text if set serveroutput is on.'); + pl(chr(9)); + pl('WORKER_TS.test( );'); + pl(chr(9)||'Built-in test unit. It will report success or error for each test if set'); + pl(chr(9)||'serveroutput is on.'); + pl(chr(9)); +end help; + + +PROCEDURE set_row( +aior_worker in out WORKER_T%ROWTYPE) is + +d_null constant date := DATES.d_MIN; +n_null constant number := 0; +v_null constant varchar2(1) := ' '; +r_worker WORKER_T%ROWTYPE; + +begin + -- set the unformatted name + aior_worker.name := get_unformatted_name( + aior_worker.first_name, + aior_worker.middle_name, + aior_worker.last_name); + -- get the existing row + begin + r_worker := get_row(aior_worker); + exception + when NO_DATA_FOUND then + r_worker := NULL; + end; + -- if a row exists, update it if needed + if r_worker.id is not NULL then + aior_worker.id := r_worker.id; + aior_worker.external_id := r_worker.external_id; + if nvl(r_worker.worker_type_id, n_null) <> nvl(aior_worker.worker_type_id, n_null) or + nvl(r_worker.external_id, n_null) <> nvl(aior_worker.external_id, n_null) or + nvl(r_worker.first_name, v_null) <> nvl(aior_worker.first_name, v_null) or + nvl(r_worker.middle_name, v_null) <> nvl(aior_worker.middle_name, v_null) or + nvl(r_worker.last_name, v_null) <> nvl(aior_worker.last_name, v_null) or + nvl(r_worker.birth_date, d_null) <> nvl(aior_worker.birth_date, d_null) or + nvl(r_worker.gender_id, n_null) <> nvl(aior_worker.gender_id, n_null) then + begin + update WORKER_T + set worker_type_id = aior_worker.worker_type_id, + external_id = aior_worker.external_id, + first_name = aior_worker.first_name, + middle_name = aior_worker.middle_name, + last_name = aior_worker.last_name, + name = aior_worker.name, + birth_date = aior_worker.birth_date, + gender_id = aior_worker.gender_id + where id = aior_worker.id; + + n_updated := nvl(n_updated, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20002, SQLERRM|| + ' on update WORKER_T'|| + ' in WORKER_TS.set_row()' ); + end; + end if; + else + -- add the row if it does not exist + begin + if aior_worker.id is NULL then + aior_worker.id := get_id(); + end if; + if aior_worker.external_id is NULL then + aior_worker.external_id := get_external_id(); + end if; + insert into WORKER_T ( + id, + worker_type_id, + external_id, + first_name, + middle_name, + last_name, + name, + birth_date, + gender_id ) + values ( + aior_worker.id, + aior_worker.worker_type_id, + aior_worker.external_id, + aior_worker.first_name, + aior_worker.middle_name, + aior_worker.last_name, + aior_worker.name, + aior_worker.birth_date, + aior_worker.gender_id ); + + n_inserted := nvl(n_inserted, 0) + nvl(sql%rowcount, 0); + exception + when OTHERS then + raise_application_error( -20003, SQLERRM|| + ' on insert WORKER_T'|| + ' in WORKER_TS.set_row()' ); + end; + end if; +end set_row; + + +PROCEDURE test is + +begin + pl('=================================== PACKAGE ===================================='); + pl(chr(9)); + pl('WORKER_TS'); + pl(chr(9)); +-- pl('1. Testing constants d_MIN and d_MAX'); +-- if d_MIN < d_MAX then +-- pl('SUCCESS'); +-- else +-- pl('ERROR: d_MIN is not less than d_MAX'); +-- end if; + pl(chr(9)||'No tests for WORKER_TS at this time'); +end test; + + +end WORKER_TS; +/ +@be.sql WORKER_TS + diff --git a/Chapter10/worker_type_t.tab b/Chapter10/worker_type_t.tab new file mode 100644 index 0000000..ca77b6d --- /dev/null +++ b/Chapter10/worker_type_t.tab @@ -0,0 +1,33 @@ +rem worker_type_t.tab +rem copyright by Donald J. Bales on 12/15/2006 +rem + +execute drop_if_exists('TABLE', 'WORKER_TYPE_T'); +create table WORKER_TYPE_T ( +id number not null, +code varchar2(30) not null, +description varchar2(80) not null, +active_date date default SYSDATE not null, +inactive_date date ) +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute drop_if_exists('SEQUENCE', 'WORKER_TYPE_ID_SEQ'); +create sequence WORKER_TYPE_ID_SEQ +start with 1; + +alter table WORKER_TYPE_T add +constraint WORKER_TYPE_T_PK +primary key ( id ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +alter table WORKER_TYPE_T add +constraint WORKER_TYPE_UK +unique ( code ) +using index +tablespace USERS pctfree 20 +storage (initial 10K next 10K pctincrease 0); + +execute SYS.DBMS_STATS.gather_table_stats(USER, 'WORKER_TYPE_T'); diff --git a/Chapter10/worker_type_ts.pkb b/Chapter10/worker_type_ts.pkb new file mode 100644 index 0000000..cb8d93b --- /dev/null +++ b/Chapter10/worker_type_ts.pkb @@ -0,0 +1,299 @@ +create or replace PACKAGE BODY WORKER_TYPE_TS as +/* +worker_type_ts.pkb +by Don Bales on 12/15/2006 +Table WORKER_TYPE_T's methods +*/ + + +PROCEDURE get_code_descr( +ain_id in WORKER_TYPE_T.id%TYPE, +aov_code out WORKER_TYPE_T.code%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE ) is + +begin + select code, + description + into aov_code, + aov_description + from WORKER_TYPE_T + where id = ain_id; +end get_code_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out WORKER_TYPE_T.code%TYPE, +aon_id out WORKER_TYPE_T.id%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE, +aid_on in WORKER_TYPE_T.active_date%TYPE ) is + +v_code WORKER_TYPE_T.code%TYPE; + +begin + select id, + description + into aon_id, + aov_description + from WORKER_TYPE_T + where code = aiov_code + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); +exception + when NO_DATA_FOUND then + select id, + code, + description + into aon_id, + v_code, + aov_description + from WORKER_TYPE_T + where code like aiov_code||'%' + and aid_on between active_date and nvl(inactive_date, DATES.d_MAX); + + aiov_code := v_code; +end get_code_id_descr; + + +PROCEDURE get_code_id_descr( +aiov_code in out WORKER_TYPE_T.code%TYPE, +aon_id out WORKER_TYPE_T.id%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE ) is + +begin + get_code_id_descr( + aiov_code, + aon_id, + aov_description, + SYSDATE ); +end get_code_id_descr; + + +FUNCTION get_id +return WORKER_TYPE_T.id%TYPE is + +n_id WORKER_TYPE_T.id%TYPE; + +begin + select WORKER_TYPE_ID_SEQ.nextval + into n_id + from SYS.DUAL; + + return n_id; +end get_id; + + +FUNCTION get_id( +aiv_code in WORKER_TYPE_T.code%TYPE ) +return WORKER_TYPE_T.id%TYPE is + +n_id WORKER_TYPE_T.id%TYPE; + +begin + select id + into n_id + from WORKER_TYPE_T + where code = aiv_code; + + return n_id; +end get_id; + + +PROCEDURE help is + +begin + TEXT_HELP.process('WORKER_TYPE_TS'); +end help; + + +PROCEDURE test is + +n_id WORKER_TYPE_T.id%TYPE; +v_code WORKER_TYPE_T.code%TYPE; +v_description WORKER_TYPE_T.description%TYPE; + +begin + -- Send feedback that the test ran + pl('WORKER_TYPE_TS.test()'); + + -- Clear the last set of test results + TEST_TS.clear('WORKER_TYPE_TS'); + + -- First, we need some test values + + -- Let's make sure they don't already exist: DELETE + TEST_TS.set_test('WORKER_TYPE_TS', 'DELETE', 0, + 'Delete test entries'); + begin + delete WORKER_TYPE_T + where code in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Now let's add three test codes: INSERT + TEST_TS.set_test('WORKER_TYPE_TS', 'INSERT', 1, + 'Insert 3 test entries'); + begin + insert into WORKER_TYPE_T ( + id, + code, + description, + active_date, + inactive_date ) + values ( + get_id(), + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101, + NULL ); + + insert into WORKER_TYPE_T ( + id, + code, + description, + active_date, + inactive_date ) + values ( + get_id(), + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101, + TEST_TS.d_TEST_19991231 ); + + insert into WORKER_TYPE_T ( + id, + code, + description, + active_date, + inactive_date ) + values ( + get_id(), + TEST_TS.v_TEST_30_2, + TEST_TS.v_TEST_80, + TEST_TS.d_TEST_19000101, + TEST_TS.d_TEST_19991231 ); + + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Now that we have test entries, + -- let's test the package methods + TEST_TS.set_test('WORKER_TYPE_TS', 'get_id()', 2, + 'Get the ID for the specified code'); + begin + n_id := get_id(TEST_TS.v_TEST_30); + + if n_id > 0 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORKER_TYPE_TS', 'get_code_descr()', 3, + 'Get the code and description for the specified ID'); + begin + get_code_descr( + n_id, + v_code, + v_description); + if v_code = TEST_TS.v_TEST_30 and + v_description = TEST_TS.v_TEST_80 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORKER_TYPE_TS', 'get_code_id_descr()', 4, + 'Get the code, ID, and description for the specified code'); + begin + v_code := 'TEST'; + get_code_id_descr( + v_code, + n_id, + v_description); + if v_code = TEST_TS.v_TEST_30 and + n_id > 0 and + v_description = TEST_TS.v_TEST_80 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORKER_TYPE_TS', 'get_code_id_descr()', 5, + 'Get the code, ID, and description for the specified date'); + begin + v_code := 'TEST'; + -- This test should raise a TOO_MANY_ROWS exception + -- because at least three duplicate values will + -- on the date specified + get_code_id_descr( + v_code, + n_id, + v_description, + TEST_TS.d_TEST_19991231); + if v_code = TEST_TS.v_TEST_30 and + n_id > 0 and + v_description = TEST_TS.v_TEST_80 then + TEST_TS.ok(); + else + TEST_TS.error(); + end if; + exception + when TOO_MANY_ROWS then + TEST_TS.ok(); + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORKER_TYPE_TS', 'help()', 6, + 'Display help'); + begin + help(); + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + -- Let's make sure they don't already exist: DELETE + TEST_TS.set_test('WORKER_TYPE_TS', 'DELETE', 7, + 'Delete test entries'); + begin + delete WORKER_TYPE_T + where code in ( + TEST_TS.v_TEST_30, + TEST_TS.v_TEST_30_1, + TEST_TS.v_TEST_30_2); + TEST_TS.ok(); + exception + when OTHERS then + TEST_TS.error(SQLERRM); + end; + + TEST_TS.set_test('WORKER_TYPE_TS', NULL, NULL, NULL); + TEST_TS.success(); +end test; + + +end WORKER_TYPE_TS; +/ +@be.sql WORKER_TYPE_TS diff --git a/Chapter10/worker_type_ts.pks b/Chapter10/worker_type_ts.pks new file mode 100644 index 0000000..8d3d579 --- /dev/null +++ b/Chapter10/worker_type_ts.pks @@ -0,0 +1,61 @@ +create or replace PACKAGE WORKER_TYPE_TS as +/* +worker_type_ts.pks +by Don Bales on 12/15/2006 +Code Table WORKER_TYPE_T's methods. +*/ + + +-- Gets the code and decription values for the specified work_type_id. + +PROCEDURE get_code_descr( +ain_id in WORKER_TYPE_T.id%TYPE, +aov_code out WORKER_TYPE_T.code%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE ); + + +-- Verifies the passed aiov_code value is an exact or like match on the date specified. + +PROCEDURE get_code_id_descr( +aiov_code in out WORKER_TYPE_T.code%TYPE, +aon_id out WORKER_TYPE_T.id%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE, +aid_on in WORKER_TYPE_T.active_date%TYPE ); + + +-- Verifies the passed aiov_code value is currently an exact or like match. + +PROCEDURE get_code_id_descr( +aiov_code in out WORKER_TYPE_T.code%TYPE, +aon_id out WORKER_TYPE_T.id%TYPE, +aov_description out WORKER_TYPE_T.description%TYPE ); + + +-- Returns a newly allocated id value. + +FUNCTION get_id +return WORKER_TYPE_T.id%TYPE; + + +-- Returns the id for the specified code value. + +FUNCTION get_id( +aiv_code in WORKER_TYPE_T.code%TYPE ) +return WORKER_TYPE_T.id%TYPE; + + + +-- Test-based help for this package. "set serveroutput on" in SQL*Plus. + +PROCEDURE help; + + +-- Test units for this package. + +PROCEDURE test; + + +end WORKER_TYPE_TS; +/ +@se.sql WORKER_TYPE_TS + diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..cbd442a --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,27 @@ +Freeware License, some rights reserved + +Copyright (c) 2007 Donald Bales + +Permission is hereby granted, free of charge, to anyone obtaining a copy +of this software and associated documentation files (the "Software"), +to work with the Software within the limits of freeware distribution and fair use. +This includes the rights to use, copy, and modify the Software for personal use. +Users are also allowed and encouraged to submit corrections and modifications +to the Software for the benefit of other users. + +It is not allowed to reuse, modify, or redistribute the Software for +commercial use in any way, or for a user’s educational materials such as books +or blog articles without prior permission from the copyright holder. + +The above copyright notice and this permission notice need to be included +in all copies or substantial portions of the software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..dce53e2 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +#Apress Source Code + +This repository accompanies [*Beginning PL/SQL*](http://www.apress.com/9781590598825) by Donald Bales (Apress, 2007). + +![Cover image](9781590598825.jpg) + +Download the files as a zip using the green button, or clone the repository to your machine using Git. + +##Releases + +Release v1.0 corresponds to the code in the published book, without corrections or updates. + +##Contributions + +See the file Contributing.md for more information on how you can contribute to this repository. diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..f6005ad --- /dev/null +++ b/contributing.md @@ -0,0 +1,14 @@ +# Contributing to Apress Source Code + +Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. + +## How to Contribute + +1. Make sure you have a GitHub account. +2. Fork the repository for the relevant book. +3. Create a new branch on which to make your change, e.g. +`git checkout -b my_code_contribution` +4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. +5. Submit a pull request. + +Thank you for your contribution! \ No newline at end of file