I found a example sql to build time dimension, I get from this link https://gist.github.com/johngrimes/408559
everything is perfect in mysql,
but, when I tried in netezza, the code not work correctly, some error is appear, such as "expecting USING' or
')'' or `',''",etc
I have tried modify
CREATE TABLE numbers_small (number INT);
INSERT INTO numbers_small VALUES (0);
INSERT INTO numbers_small VALUES (1);
INSERT INTO numbers_small VALUES (2);
INSERT INTO numbers_small VALUES (3);
INSERT INTO numbers_small VALUES (4);
INSERT INTO numbers_small VALUES (5);
INSERT INTO numbers_small VALUES (6);
INSERT INTO numbers_small VALUES (7);
INSERT INTO numbers_small VALUES (8);
INSERT INTO numbers_small VALUES (9);
CREATE TABLE numbers (number BIGINT);
INSERT INTO numbers
SELECT thousands.number * 1000 + hundreds.number * 100 + tens.number * 10 + ones.number
FROM numbers_small thousands, numbers_small hundreds, numbers_small tens, numbers_small ones
LIMIT 1000000;
CREATE TABLE D_TIME_DAILY_TES (
TIME_ID BIGINT PRIMARY KEY,
TANGGAL DATE NOT NULL,
TAHUN INT NOT NULL,
BULAN CHAR(10) NOT NULL,
HARI CHAR(10) NOT NULL,
LAST_UPDATE timestamp NOT NULL,
constraint D_TIME_DAILY_TES UNIQUE KEY (TANGGAL)
);
INSERT INTO D_TIME_DAILY_TES (TIME_ID, TANGGAL, LAST_UPDATE)
SELECT number, DATE_ADD( '2010-01-01', INTERVAL number DAY ), CURRENT_TIMESTAMP
FROM numbers
WHERE DATE_ADD( '2010-01-01', INTERVAL number DAY ) BETWEEN '2014-01-01' AND '2014-12-31'
ORDER BY number;
UPDATE D_TIME_DAILY_TES SET
HARI = DATE_FORMAT( TANGGAL, "%W" ),
BULAN = DATE_FORMAT( TANGGAL, "%M"),
TAHUN = DATE_FORMAT( TANGGAL, "%Y" ),
LAST_UPDATE = CURRENT_TIMESTAMP;
but it's still not work :(
how can I fix it?