@@ -2,117 +2,119 @@ SELECT * FROM bitemporal_internal.ll_create_bitemporal_table(
22 ' bt_tutorial' ,
33 ' staff_bt' ,
44 $$staff_id int ,
5- staff_name TEXT NOT NULL ,
6- staff_location TEXT NOT NULL
5+ staff_name text not null ,
6+ staff_location text not null
77 $$,
88 ' staff_id' );
99
1010 SELECT * FROM bitemporal_internal .ll_create_bitemporal_table (
1111 ' bt_tutorial' ,
1212 ' cust_bt' ,
13- $$cust_id int NOT NULL ,
14- cust_name TEXT NOT NULL ,
15- phone TEXT
13+ $$cust_id int not null ,
14+ cust_name text not null ,
15+ phone text
1616 $$,
1717 ' cust_id' );
1818
1919 SELECT * FROM bitemporal_internal .ll_create_bitemporal_table (
2020 ' bt_tutorial' ,
2121 ' product_bt' ,
22- $$product_id INT ,
23- product_name text NOT NULL ,
24- weight INTEGER NOT NULL DEFAULT (0 ),
25- price INTEGER NOT NULL DEFAULT (0 )
22+ $$product_id int ,
23+ product_name text not null ,
24+ weight integer not null default (0 ),
25+ price integer not null default (0 )
2626 $$,
2727 ' product_id' );
2828
2929 SELECT * FROM bitemporal_internal .ll_create_bitemporal_table (
3030 ' bt_tutorial' ,
3131 ' order_bt' ,
32- $$order_id INT NOT NULL ,
33- staff_id INT NOT NULL ,
34- cust_id INT NOT NULL ,
32+ $$order_id int not null ,
33+ staff_id int not null ,
34+ cust_id int not null ,
3535 order_created_at timestamptz
3636 $$,
3737 ' order_id' );
3838
3939 SELECT * FROM bitemporal_internal .ll_create_bitemporal_table (
4040 ' bt_tutorial' ,
4141 ' order_line_bt' ,
42- $$order_line_id INT NOT NULL ,
43- order_id INT NOT NULL ,
44- product_id INT NOT NULL ,
45- qty int NOT NULL ,
46- order_line_created_at timestamptz
42+ $$order_line_id int not null ,
43+ order_id int not null ,
44+ product_id int not null ,
45+ qty int not null ,
46+ order_line_created_at timestamptz
4747 $$,
4848 ' order_id,order_line_id' );
4949
5050
5151
52- drop SEQUENCE if exists bt_tutorial .staff_id_seq ;
52+ DROP SEQUENCE if exists bt_tutorial .staff_id_seq ;
5353CREATE SEQUENCE bt_tutorial .staff_id_seq;
54- drop SEQUENCE if exists bt_tutorial .cust_id_seq ;
54+ DROP SEQUENCE if exists bt_tutorial .cust_id_seq ;
5555CREATE SEQUENCE bt_tutorial .cust_id_seq;
56- drop SEQUENCE if exists bt_tutorial .product_id_seq ;
56+ DROP SEQUENCE if exists bt_tutorial .product_id_seq ;
5757CREATE SEQUENCE bt_tutorial .product_id_seq;
58- drop SEQUENCE if exists bt_tutorial .order_id_seq ;
58+ DROP SEQUENCE if exists bt_tutorial .order_id_seq ;
5959CREATE SEQUENCE bt_tutorial .order_id_seq;
60- drop SEQUENCE if exists bt_tutorial .order_line_id_seq ;
60+ DROP SEQUENCE if exists bt_tutorial .order_line_id_seq ;
6161CREATE SEQUENCE bt_tutorial .order_line_id_seq;
6262
6363
64- select * from bitemporal_internal .ll_bitemporal_insert (' bt_tutorial.staff_bt'
64+ SELECT * FROM bitemporal_internal .ll_bitemporal_insert (' bt_tutorial.staff_bt'
6565,$$staff_id, staff_name, staff_location$$
66- ,quote_literal(nextval(' staff_id_seq' ))|| $$,
66+ ,quote_literal(nextval(' bt_tutorial. staff_id_seq' ))|| $$,
6767' mystaff' , ' mylocation' $$
6868,temporal_relationships .timeperiod (now(), ' infinity' ) -- effective
6969,temporal_relationships .timeperiod (now(), ' infinity' ) -- asserted
7070);
7171
72- select * from bitemporal_internal .ll_bitemporal_insert (' bt_tutorial.cust_bt'
72+ SELECT * FROM bt_tutorial .staff ;
73+
74+ SELECT * FROM bitemporal_internal .ll_bitemporal_insert (' bt_tutorial.cust_bt'
7375,$$cust_id, cust_name, phone$$
74- ,quote_literal(nextval(' cust_id_seq' ))|| $$,
76+ ,quote_literal(nextval(' bt_tutorial. cust_id_seq' ))|| $$,
7577' mycust' , ' +6281197889890' $$
7678,temporal_relationships .timeperiod (now(), ' infinity' ) -- effective
7779,temporal_relationships .timeperiod (now(), ' infinity' ) -- asserted
7880);
7981
80- select * from bitemporal_internal .ll_bitemporal_insert (' bt_tutorial.product_bt'
82+ SELECT * FROM bitemporal_internal .ll_bitemporal_insert (' bt_tutorial.product_bt'
8183,$$product_id, product_name,weight,price$$
82- ,quote_literal(nextval(' product_id_seq' ))|| $$,
84+ ,quote_literal(nextval(' bt_tutorial. product_id_seq' ))|| $$,
8385' myproduct' , 100 ,200 $$
8486,temporal_relationships .timeperiod (now(), ' infinity' ) -- effective
8587,temporal_relationships .timeperiod (now(), ' infinity' ) -- asserted
8688);
8789
88- select * from bitemporal_internal .ll_bitemporal_insert (' bt_tutorial.product_bt'
90+ SELECT * FROM bitemporal_internal .ll_bitemporal_insert (' bt_tutorial.product_bt'
8991,$$product_id, product_name,weight,price$$
90- ,quote_literal(nextval(' product_id_seq' ))|| $$,
92+ ,quote_literal(nextval(' bt_tutorial. product_id_seq' ))|| $$,
9193' myproduct2' , 200 ,250 $$
9294,temporal_relationships .timeperiod (now(), ' infinity' ) -- effective
9395,temporal_relationships .timeperiod (now(), ' infinity' ) -- asserted
9496);
9597
96- select * from bitemporal_internal .ll_bitemporal_insert (' bt_tutorial.order_bt'
98+ SELECT * FROM bitemporal_internal .ll_bitemporal_insert (' bt_tutorial.order_bt'
9799,$$order_id, staff_id,cust_id,order_created_at$$
98- ,quote_literal(nextval(' order_id_seq' ))|| $$,
100+ ,quote_literal(nextval(' bt_tutorial. order_id_seq' ))|| $$,
991011 ,1 ,$$|| quote_literal(now())
100102,temporal_relationships .timeperiod (now(), ' infinity' ) -- effective
101103,temporal_relationships .timeperiod (now(), ' infinity' ) -- asserted
102104);
103105
104- select * from bitemporal_internal .ll_bitemporal_insert (' bt_tutorial.order_line_bt'
105- ,$$order_line_id,order_id, product_id,qty$$
106- ,quote_literal(nextval(' order_line_id_seq' ))|| $$,
107- 1 ,1 ,10 $$
106+ SELECT * FROM bitemporal_internal .ll_bitemporal_insert (' bt_tutorial.order_line_bt'
107+ ,$$order_line_id,order_id, product_id,qty, order_line_created_at $$
108+ ,quote_literal(nextval(' bt_tutorial. order_line_id_seq' ))|| $$,
109+ 1 ,1 ,10 $$|| quote_literal(now())
108110,temporal_relationships .timeperiod (now(), ' infinity' ) -- effective
109111,temporal_relationships .timeperiod (now(), ' infinity' ) -- asserted
110112);
111113
112- select * from bitemporal_internal .ll_bitemporal_insert (' bt_tutorial.order_line_bt'
113- ,$$order_line_id,order_id, product_id,qty$$
114- ,quote_literal(nextval(' order_line_id_seq' ))|| $$,
115- 1 ,2 ,15 $$
114+ SELECT * FROM bitemporal_internal .ll_bitemporal_insert (' bt_tutorial.order_line_bt'
115+ ,$$order_line_id,order_id, product_id,qty, order_line_created_at $$
116+ ,quote_literal(nextval(' bt_tutorial. order_line_id_seq' ))|| $$,
117+ 1 ,2 ,15 $$|| quote_literal(now())
116118,temporal_relationships .timeperiod (now(), ' infinity' ) -- effective
117119,temporal_relationships .timeperiod (now(), ' infinity' ) -- asserted
118120);
@@ -127,7 +129,7 @@ SELECT * FROM bitemporal_internal.ll_bitemporal_update('bt_tutorial'
127129,temporal_relationships .timeperiod (now(), ' infinity' )
128130) ;
129131
130- select
132+ SELECT
131133o .order_id ,
132134staff_name,
133135staff_location,
@@ -136,11 +138,11 @@ c.phone AS cust_phone,
136138p .product_name ,
137139p .price ,
138140l .qty
139- FROM order_line_bt l
140- JOIN order_bt o ON o .order_id = l .order_id
141- JOIN product_bt p ON p .product_id = l .product_id
142- JOIN staff_bt s ON s .staff_id = o .staff_id
143- JOIN cust_bt c ON c .cust_id = o .cust_id
141+ FROM bt_tutorial . order_line_bt l
142+ JOIN bt_tutorial . order_bt o ON o .order_id = l .order_id
143+ JOIN bt_tutorial . product_bt p ON p .product_id = l .product_id
144+ JOIN bt_tutorial . staff_bt s ON s .staff_id = o .staff_id
145+ JOIN bt_tutorial . cust_bt c ON c .cust_id = o .cust_id
144146WHERE l .order_id = 1
145147AND order_line_created_at< @l .effective AND now()< @l .asserted
146148AND order_created_at< @o .effective AND now()< @o .asserted
@@ -151,16 +153,16 @@ AND order_created_at<@s.effective AND now()<@s.asserted;
151153
152154SELECT * FROM bitemporal_internal .ll_bitemporal_correction (
153155 ' bt_tutorial' ,
154- ' product_bt' ,
156+ ' product_bt' ,
155157 ' price' ,
156- ' 275' ,
158+ ' 275' ,
157159 ' product_id' ,
158160 ' 2' ,
159161 temporal_relationships .timeperiod (' 2020-10-11 18:33:26.816311-05' ::timestamptz ,' infinity' ),
160162 now() );
161163
162164 -- -corrected price
163- select
165+ SELECT
164166o .order_id ,
165167staff_name,
166168staff_location,
@@ -169,21 +171,21 @@ c.phone AS cust_phone,
169171p .product_name ,
170172p .price ,
171173l .qty
172- FROM order_line_bt l
173- JOIN order_bt o ON o .order_id = l .order_id
174- JOIN product_bt p ON p .product_id = l .product_id
175- JOIN staff_bt s ON s .staff_id = o .staff_id
176- JOIN cust_bt c ON c .cust_id = o .cust_id
174+ FROM bt_tutorialo . rder_line_bt l
175+ JOIN bt_tutorial . order_bt o ON o .order_id = l .order_id
176+ JOIN bt_tutorial . product_bt p ON p .product_id = l .product_id
177+ JOIN bt_tutorial . staff_bt s ON s .staff_id = o .staff_id
178+ JOIN bt_tutorial . cust_bt c ON c .cust_id = o .cust_id
177179WHERE l .order_id = 1
178180AND order_line_created_at< @l .effective AND now()< @l .asserted
179181AND order_created_at< @o .effective AND now()< @o .asserted
180182AND order_created_at< @c .effective AND now()< @c .asserted
181183AND order_created_at< @p .effective AND now()< @p .asserted
182- AND order_created_at< @s .effective AND now()< @s .asserted ;
184+ and order_created_at< @s .effective AND now()< @s .asserted ;
183185
184186-- original price
185187
186- select
188+ SELECT
187189o .order_id ,
188190staff_name,
189191staff_location,
@@ -192,11 +194,11 @@ c.phone AS cust_phone,
192194p .product_name ,
193195p .price ,
194196l .qty
195- FROM order_line_bt l
196- JOIN order_bt o ON o .order_id = l .order_id
197- JOIN product_bt p ON p .product_id = l .product_id
198- JOIN staff_bt s ON s .staff_id = o .staff_id
199- JOIN cust_bt c ON c .cust_id = o .cust_id
197+ FROM bt_tutorial . order_line_bt l
198+ JOIN bt_tutorial . order_bt o ON o .order_id = l .order_id
199+ JOIN bt_tutorial . product_bt p ON p .product_id = l .product_id
200+ JOIN bt_tutorial . staff_bt s ON s .staff_id = o .staff_id
201+ JOIN bt_tutorial . cust_bt c ON c .cust_id = o .cust_id
200202WHERE l .order_id = 1
201203AND order_line_created_at< @l .effective AND order_line_created_at< @l .asserted
202204AND order_created_at< @o .effective AND order_created_at< @o .asserted
0 commit comments