PL/SQL Library
This post contains links to other posts that make up a library of PL/SQL Functions, Procedures and Packages:
This post contains links to other posts that make up a library of PL/SQL Functions, Procedures and Packages:
Pre-Requisites:
...
Code:
Paste this code into a .sql script and run it in SQL*PLUS by the owner of the target schema.
-- ------------------------------------------------------------------------- -- |
Pre-Requisites:
Database Objects:
This template is used as a header for general purpose scripts:
-- ------------------------------------------------------------------------- -- |
This template is used as a header for PL/SQL Functions:
-- ------------------------------------------------------------------------- -- |
This repository consists of a number of components. The schema itself is hand cut, maintained in scripts and deployed to the ctl database.
This repository contains the objects and scripts that record and monitor data movements between data repositories. As such, it contains references to the repositories themselves, all of the mappings and histories of mapping runs.
It also contains information about specific classes of mappings that are placed into generic groups (e.g. the generic HTML components), although the data processing code is placed in the relevant repository.
Process - Initial and Subsequent Load:
Schedule:
Component | Datatype |
DAY_ID | NUMBER |
FMN_ID | NUMBER |
FQT_ID | NUMBER |
FWK_ID | NUMBER |
FYR_ID | NUMBER |
NMN_ID | NUMBER |
NQT_ID | NUMBER |
NWK_ID | NUMBER |
NYR_ID | NUMBER |
DAY_END_DATE | DATE |
DAY_JULIAN_DATE | NUMBER |
DAY_LAST_DAY_IN_MONTH | VARCHAR2(1) |
DAY_LAST_DAY_IN_QUARTER | VARCHAR2(1) |
DAY_NAME | VARCHAR2(10) |
DAY_SHORT_NAME | VARCHAR2(3) |
DAY_START_DATE | DATE |
DAY_WEEKDAY | VARCHAR2(1) |
FMN_FULL_NAME | VARCHAR2(25) |
FMN_MONTH | NUMBER(2) |
FMN_NAME | VARCHAR2(10) |
FMN_ORDERING | NUMBER(6) |
FMN_SHORT_NAME | VARCHAR2(9) |
FQT_FULL_NAME | VARCHAR2(25) |
FQT_NAME | VARCHAR2(3) |
FQT_ORDERING | NUMBER(5) |
FQT_QUARTER | NUMBER(1) |
FQT_SHORT_NAME | VARCHAR2(11) |
FWK_FULL_NAME | VARCHAR2(25) |
FWK_NAME | VARCHAR2(3) |
FWK_ORDERING | NUMBER(6) |
FWK_WEEK | NUMBER(2) |
FYR_DAYS_IN_YEAR | NUMBER(3) |
FYR_FULL_NAME | VARCHAR2(25) |
FYR_NAME | VARCHAR2(9) |
FYR_SHORT_NAME | VARCHAR2(20) |
FYR_YEAR | NUMBER(4) |
NMN_DAYS_IN_MONTH | NUMBER(2) |
NMN_MONTH | NUMBER(2) |
NMN_NAME | VARCHAR2(10) |
NMN_ORDERING | NUMBER(6) |
NMN_SHORT_NAME | VARCHAR2(3) |
NQT_DAYS_IN_QUARTER | NUMBER(2) |
NQT_NAME | VARCHAR2(11) |
NQT_ORDERING | NUMBER(5) |
NQT_QUARTER | NUMBER(1) |
NQT_SHORT_NAME | VARCHAR2(7) |
NWK_NAME | VARCHAR2(3) |
NWK_ORDERING | NUMBER(6) |
NWK_WEEK | NUMBER(2) |
NYR_DAYS_IN_YEAR | NUMBER(3) |
NYR_NAME | VARCHAR2(4) |
NYR_YEAR | NUMBER(4) |
This section describes the process and mappings that populate the dimension. Potentially, data could come from different sources and at different times. In this case all processes and schedules should be described.
Process - Process A:
Schedule:
This section is used to define that data sources for the dimension. The first part of this section is a source object definition (usually a table, view of file). This is followed by the transformation rules.
This post consists of a pick-list of parts. Rarely would a dimension require all of these.
Next - Process
Introduction:
This procedure describes how a dimension definition is entered into OWB. Before this can be entered, it must be designed. Use this template to create the design, here is an example.
Aim:
Create a Dimension definition in OWB.
Requirements:
Access to an OWB Target Module.
Procedure:
Introduction:
An Oracle Module contains all the objects associated with a specific schema on a particular instance. The objects that are created here are deployed as tables, views, sequences, package procedures, etc.
Aim:
Create an Oracle Module and associate it with it's physical schema.
Requirements:
Access to an OWB Project.
Procedure:
Introduction:
The OWB Project is the least granular OBW component and houses all of the object that make up a complete data warehouse.
Aim:
Create a project.
Requirements:
Access to OWB.
Procedure:
Table:
Table | Description |
D_TIME | The Time Dimension (D_TIME) contains several navigable hierarchies relating to time - these represent different ways of viewing the calendar. The two major groups are Natural (i.e. the normal yearly calendar) and Financial (a calendar representing the Australian business year). |
Level | Prefix | Description |
NAT_YEA | NYR | Natural Year. This describes the Natural Calendar Year. |
NAT_QTR | NQT | Natural Quarter. This describes the Natural Calendar Quarter. |
NAT_MTH | NMN | Natural Month. This describes the Natural Calendar Month. |
NAT_WEK | NWK | Natural Week. This describes the Natural Calendar Week. |
FIN_YEA | FYR | Financial Year. This describes the Financial Year. |
FIN_QTR | FQT | Natural Quarter. This describes the Natural Calendar Quarter. |
FIN_MTH | FMN | Financial Month. This describes the Financial Month. |
FIN_WEK | FWK | Financial Week. This describes the Financial Week. |
DAY | DAY | Day. This describes the Calendar Day. The Day description is common to both the Natural and Financial calendars. |
Attribute | Datatype | Description |
ID | NUMBER | OWB assigned. |
YEAR | NUMBER(4) | The year as a number type. e.g. 2005. |
NAME | VARCHAR2(4) | The year as a character type. e.g. '2005'. |
DAYS_IN_YEAR | NUMBER(3) | The number of days in the year. e.g. 365, 366. |
Attribute | Datatype | Description |
ID | NUMBER | OWB assigned. |
QUARTER | NUMBER(1) | The quarter as a number type. e.g. 1, 2, 3, 4. |
NAME | VARCHAR2(11) | The full quarter name as a character type. e.g. '1st Quarter'. |
SHORT_NAME | VARCHAR2(7) | The short quarter name as a character type. e.g. '1st Qtr'. |
ORDERING | NUMBER(5) | A number that allows ordering to span years. e.g. 20054, 20061. |
DAYS_IN_QUARTER | NUMBER(2) | The number of days in the quarter. e.g. 92. |
Attribute | Datatype | Description |
ID | NUMBER | OWB assigned. |
MONTH | NUMBER(2) | The month as a number type. e.g. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12. |
NAME | VARCHAR2(10) | The full month name as a character type. e.g. 'January', 'February', etc. |
SHORT_NAME | VARCHAR2(3) | The short month name as a character type. e.g. 'Jan', 'Feb', etc. |
ORDERING | NUMBER(6) | A number that allows ordering to span years. e.g. 200512, 200601. |
DAYS_IN_MONTH | NUMBER(2) | The number of days in the month. e.g. 31. |
Attribute | Datatype | Description |
ID | NUMBER | OWB assigned. |
WEEK | NUMBER(2) | The week as a number type. e.g. 1, 2, 3, etc. Dates are assigned to weeks as follows: - 1st Jan is assigned to Week 1. - Each Monday, the week is incremented. |
NAME | VARCHAR2(3) | The week name as a character type. e.g. '1st', '2nd', etc. |
ORDERING | NUMBER(6) | A number that allows ordering to span years. e.g. 200552, 200601. |
Attribute | Datatype | Description |
ID | NUMBER | OWB assigned. |
YEAR | NUMBER(4) | The financial year as a number type. e.g. 2006. As the Financial Year spans 2 natural years, this is the number of the later year. e.g. for the financial year 2005/2006, this value is 2006. |
NAME | VARCHAR2(9) | The financial year as a character type. e.g. '2005/2006'. |
SHORT_NAME | VARCHAR2(20) | The financial year as a character type. e.g. '2005/2006 Fin Yr'. |
FULL_NAME | VARCHAR2(25) | The financial year as a character type. e.g. '2005/2006 Financial Year'. |
DAYS_IN_YEAR | NUMBER(3) | The number of days in the financial year. e.g. 365, 366. |
Attribute | Datatype | Description |
ID | NUMBER | OWB assigned. |
QUARTER | NUMBER(1) | The financial quarter as a number type. e.g. 1, 2, 3, 4. |
NAME | VARCHAR2(3) | The financial quarter name as a character type. e.g. '1st'. |
SHORT_NAME | VARCHAR2(11) | The short financial quarter name as a character type. e.g. '1st Fin Qtr'. |
FULL_NAME | VARCHAR2(25) | The financial quarter name as a character type. e.g. '1st Financial Quarter'. |
ORDERING | NUMBER(5) | A number that allows ordering to span years. e.g. 20054, 20061. |
Attribute | Datatype | Description |
ID | NUMBER | OWB assigned. |
MONTH | NUMBER(2) | The financial month as a number type. e.g. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12. |
NAME | VARCHAR2(10) | The financial month name as a character type. e.g. 'January', 'February', etc. |
SHORT_NAME | VARCHAR2(9) | The short financial month name as a character type. e.g. '1st Fin Mth', 2nd Fin Mth', etc. |
FULL_NAME | VARCHAR2(25) | The long month name as a character type. e.g. '1st Financial Month', etc. |
ORDERING | NUMBER(6) | A number that allows ordering to span years. e.g. 200512, 200601. |
Attribute | Datatype | Description |
ID | NUMBER | OWB assigned. |
WEEK | NUMBER(2) | The week as a number type. e.g. 1, 2, 3, etc. Dates are assigned to weeks as follows: - 1st Jul is assigned to Week 1. - Each Monday, the week is incremented. |
NAME | VARCHAR2(3) | The week name as a character type. e.g. '1st', '2nd', etc. |
SHORT_NAME | VARCHAR2(10) | The week name as a character type. e.g. '1st Fin Wk', '2nd Fin Wk', etc. |
FULL_NAME | VARCHAR2(25) | The week name as a character type. e.g. '1st Financial Week', etc. |
ORDERING | NUMBER(6) | A number that allows ordering to span years. e.g. 200552, 200601. |
Attribute | Datatype | Description |
ID | NUMBER | OWB assigned. |
START_DATE | DATE | Timestamp of the start of the day. e.g. '01-JAN-2006 00:00:00'. |
END_DATE | DATE | Timestamp of the end of the day. e.g. '01-JAN-2006 23:59:59'. |
JULIAN_DATE | NUMBER(7) | Days since 1st January 4712 BC. |
NAME | VARCHAR2(10) | The name of the day. e.g. 'Monday', 'Tuesday', etc. |
SHORT_NAME | VARCHAR2(3) | The short name of the day. e.g. 'Mon', 'Tue', etc. |
WEEKDAY | VARCHAR2(1) | Y/N Indicator. |
LAST_DAY_IN_QUARTER | VARCHAR2(1) | Y/N indicator. |
LAST_DAY_IN_MONTH | VARCHAR2(1) | Y/N indicator. |
Attribute | Datatype | Description |
RUN_NO | NUMBER | The Run Number that created this row. |
INS_TSP | DATE | Insert timestamp. |
Hierarchy | Description |
NAT_CAL | A hierarchy that allows navigation from Natural Calendar Year to Day. |
NAT_WEK | A hierarchy that allows navigation from Natural Calendar Week to Day. |
FIN_CAL | A hierarchy that allows navigation from Financial Calendar Year to Day. |
FIN_WEK | A hierarchy that allows navigation from Financial Calendar Week to Day. |
Hierarchy | Level |
NAT_CAL | NAT_YEA NAT_QTR NAT_MTH DAY |
NAT_WEK | NAT_WEK DAY |
FIN_CAL | FIN_YEA FIN_QTR FIN_MTH DAY |
FIN_WEK | FIN_WEK DAY |
This section outlines the total volume of rows for the dimension and the relative granularity of each level.
Volume:
A section that includes the assumptions that the volume calculation is based on, followed by the calculation itself.
Relative Granularity:
Level | Relative Granularity |
Name of the level. | A number. The granularity relative to the lowest granularity in the dimension. For example; the lowest granularity in a time dimension is the Year. Granularities relative to this are; Quarter = 4, Month = 12, Week = 52, and Day = 356. |
This section contains the dimension definition and should contain the following:
Table:
Table | Description |
Name of the database table that implements the dimension. | A description of the dimension. This should be a plain-English description and, as it will end up in the user-accessible data dictionary, should be aimed at the user's understanding of what they are dealing with. |
Level | Prefix | Description |
Name of the level. | Column prefix of the level. This is appended to the attribute name to create the database column name. A 3-character prefix is common. | A description of the level. This should be a plain-English description and, as it will end up in the user-accessible data dictionary, should be aimed at the user's understanding of what they are dealing with. |
Attribute | Datatype | Description |
Name of the Attribute. This must be unique within the level. | Oracle Datatype. e.g. DATE, VARCHAR2(10), NUMBER(7,2), etc. | A description of the attribute. This should be a plain-English description and, as it will end up in the user-accessible data dictionary, should be aimed at the user's understanding of what they are dealing with. |
Hierarchy | Description |
Name of the hierarchy. | A description of the hierarchy. This should be a plain-English description and, as it will end up in the user-accessible data dictionary, should be aimed at the user's understanding of what they are dealing with. |
Hierarchy | Level |
Name of the hierarchy. | A list of levels that are assigned to the hierarchy. These are ordered from the least to most granular. |
This section should be a diagramatic representation of the dimension - one that user can understand and use. I find this to be one of the best tools I have when interacting with users - other than the lart, of course. Often, after a long and difficult requirements gathering process, when I finally get something useful out of the users, I will go back to them with this roadmap. One of the more common responses is; 'Why are you wasting my time telling me something I already know?'. Bingo!
As an example, here is a roadmap for a time dimension:
Next - Granularity
This implementation of the Time Dimension is for use in the Australian business area. It contains four hierarchies: