
/* Code Fragment 9.22 Define the state table as a view */

CREATE VIEW P_TT
	(PROJECTION_ID, PROJECTION_NAME, PROJECTION_TYPE, SPHEROID_CODE,
	 PROJECTION_UOM, ZONE_CODE, Start_Date, Stop_Date)
AS
SELECT * 
FROM P_TT_PAST

UNION

SELECT 	PROJECTIONS.PROJECTION_ID, PROJECTION_NAME, PROJECTION_TYPE, SPHEROID_CODE,
	PROJECTION_UOM, ZONE_CODE, Start_Date, GETDATE() AS Stop_Date
FROM PROJECTIONS, P_TT_CURRENT
WHERE PROJECTIONS.PROJECTION_ID = P_TT_CURRENT.PROJECTION_ID
