Chapter 9
279
How to do it...
1. Create the kabota_date_dim date dimension table in the ADempiere database
(adempiere360) by running the following SQL:
CREATE TABLE kabota_date_dim (
date_id numeric(11,0) NOT NULL,
for_date date,
day_of_year numeric(11,0) DEFAULT NULL::numeric,
year numeric(11,0) DEFAULT NULL::numeric,
month numeric(11,0) DEFAULT NULL::numeric,
year_quarter numeric(11,0) DEFAULT NULL::numeric,
year_and_month numeric(11,0) DEFAULT NULL::numeric,
year_month_week numeric(11,0) DEFAULT NULL::numeric,
year_month_date numeric(11,0) DEFAULT NULL::numeric,
day_of_month numeric(11,0) DEFAULT NULL::numeric,
week_nbr numeric(11,0) DEFAULT NULL::numeric,
quarter_nbr numeric(11,0) DEFAULT NULL::numeric,
day_name character(3) DEFAULT NULL::bpchar,
month_name character(3) DEFAULT NULL::bpchar
);
ALTER TABLE adempiere.kabota_date_dim OWNER TO adempiere;
2. Insert records in the kabota_date_dim table. The following is an example for
INSERT:
INSERT INTO kabota_date_dim VALUES (1, '2009-01-01', 1, 2009, 1,
20091, 200901, 2009011, 20090101, 1, 1, 1, 'THU', 'JAN');
3. Create the va_ana_order_line view in the ADempiere database by running the
following SQL:
CREATE VIEW va_ana_order_line AS
SELECT line.c_orderline_id, line.c_order_id, c_order.issotrx,
CASE WHEN c_order.issotrx='Y' THEN 'Sales'
ELSE 'Purchase'
END as type
,
line.dateordered, order_dim.date_id AS dateordered_id, line.
datepromised, promised_dim.date_id AS datepromised_id, line.
datedelivered, delivered_dim.date_id AS datedelivered_id, line.m_
product_id, line.m_warehouse_id,line.pricecost,line.priceactual,
line.pricelist, line.pricelimit,line.discount, line.qtyordered,
line.qtyreserved, line.qtydelivered FROM (((c_orderline line
JOIN kabota_date_dim order_dim ON (((line.dateordered)::date
= order_dim.for_date)))JOIN c_order ON (line.c_order_id = c_