// Первый просмотр
CREATE VIEW WEB_VOY_SEARCH_CT_DETAILS_VIEW
AS
WITH W1
AS (SELECT TRIM (TD.WEB_ITIN_CODE) AS WEB_ITIN_CODE,
TRIM (TD.TOUR_ID) AS TOUR_ID,
TRIM (TD.VOYAGE_ID) AS VOYAGE_ID,
TD.DURATION AS TEMP_DURATION,
TD.TOUR_START_DATE,
TD.TOUR_END_DATE,
TRIM (ALT_TOUR_ID) AS ALT_TOUR_ID,
ALT_TOUR_START_DATE,
TD.ON_REQUEST_DAYS
FROM TTURDEPT TD),
W2
AS (SELECT W1.WEB_ITIN_CODE,
W1.TOUR_ID,
W1.VOYAGE_ID,
V.WEB_ITIN_CODE AS VOY_ITIN_CODE,
V.SHIPBOARD_CURRENCY,
V.VOYAGE_STATUS,
V.VOYAGE_ATTR,
V.PRODUCT_CODE,
V.DURATION,
(W1.TEMP_DURATION - V.DURATION) AS TOUR_DURATION,
V.DEPARTURE_DATE,
W1.TOUR_START_DATE AS CRUISE_START_DATE,
W1.TOUR_END_DATE AS CRUISE_END_DATE,
V.INCLUDE_EXCLUDE_FLAG,
TRIM (V.FROM_PORT) AS FROM_PORT,
TRIM (V.TO_PORT) AS TO_PORT,
V.SHIP_VERSION,
V.ZONE_DECK_FLAG,
TRIM (V.SHIP_CODE) AS SHIP_CODE,
W1.ALT_TOUR_ID,
W1.ALT_TOUR_START_DATE,
W1.ON_REQUEST_DAYS,
TRIM (V.TOUR_UPSELL1) AS TOUR_UPSELL1,
TRIM (V.TOUR_UPSELL2) AS TOUR_UPSELL2,
TRIM (V.TOUR_UPSELL3) AS TOUR_UPSELL3,
TRIM (V.TOUR_UPSELL4) AS TOUR_UPSELL4,
TRIM (V.TOUR_UPSELL5) AS TOUR_UPSELL5,
TRIM (OCEAN_FLAG) AS OCEAN_FLAG,
V.KIDS_ALONE_CABIN_AGE,
V.PAX_MINIMUM_AGE,
V.ESC_TWID_MINIMUM_AGE,
V.MIN_DRINKING_AGE,
V.MIN_GAMBLING_AGE,
V.MIN_WAYFIND_AGE,
V.MIN_SMOKING_AGE,
V.WEB_FEATURED_CRUISE,
V.SAILED_FLAG
FROM W1 INNER JOIN TVOYLST V ON (W1.VOYAGE_ID = V.VOYAGE_ID)),
W3
AS (SELECT W2.*,
TRIM (T.TOUR_TITLE) AS TOUR_TITLE,
TRIM (T.TOUR_DESC) AS TOUR_DESC,
T.TOUR_MINIMUM_AGE,
TRIM (T.TOUR_SUB_PRODUCT) AS SUBTRADE_CODE
FROM W2 INNER JOIN TTURLST T ON (W2.TOUR_ID = T.TOUR_ID)),
W4
AS (SELECT W3.*,
TRIM (S.STRING_1) AS ITIN_DESC,
TRIM (S.STRING_5) AS TRADE_CODE,
TRIM (S.STRING_5) AS ITIN_TRADE_CODE
FROM W3
LEFT OUTER JOIN
TSYSDATA S
ON ( S.SYSDATA_TYPE = 'ICT'
AND W3.VOY_ITIN_CODE = S.SYSDATA_CODE)),
W5
AS (SELECT W4.*,
TL.LOCATION_CODE,
TL.WEB_DISPLAY_FLAG AS TOUR_WEB_DISPLAY_FLAG,
TL.PON_DISPLAY_FLAG AS TOUR_PON_DISPLAY_FLAG,
TL.WAITLIST_FLAG AS TOUR_WAITLIST_FLAG,
TL.RES_DISPLAY_FLAG AS TOUR_RES_DISPLAY_FLAG
FROM W4 INNER JOIN TTURLOC TL ON (W4.TOUR_ID = TL.TOUR_ID)),
W6
AS (SELECT W5.*,
VL.WEB_DISPLAY_FLAG,
VL.PON_DISPLAY_FLAG,
VL.EZAIR_FLAG,
VL.AIR_AVAL_FLAG,
VL.AIR_AVAL_TO_BOOK_DAYS,
FULL_ROUTE_DISPLAY_FLAG
FROM W5
INNER JOIN
TVOYLOC VL
ON ( W5.VOYAGE_ID = VL.VOYAGE_ID
AND VL.LOCATION_CODE = W5.LOCATION_CODE)),
W7
AS (SELECT W6.*, SHIP_NAME
FROM W6 INNER JOIN TSHIPLST SH ON (W6.SHIP_CODE = SH.SHIP_CODE))
SELECT *
FROM W7
WHERE TRADE_CODE != '';
// Второй просмотр
CREATE VIEW WEB_VOY_SEARCH_CRZ_DETAILS_VIEW
AS
WITH W1
AS (SELECT TRIM (V.WEB_ITIN_CODE) AS WEB_ITIN_CODE,
V.SHIPBOARD_CURRENCY,
TRIM (V.VOYAGE_ID) AS VOYAGE_ID,
V.VOYAGE_STATUS,
V.VOYAGE_ATTR,
TRIM (V.PRODUCT_CODE) AS PRODUCT_CODE,
V.DURATION,
V.DEPARTURE_DATE,
V.DEPARTURE_DATE AS CRUISE_START_DATE,
V.INCLUDE_EXCLUDE_FLAG,
trim (V.FROM_PORT) AS FROM_PORT,
trim (V.TO_PORT) AS TO_PORT,
V.SHIP_VERSION,
V.ZONE_DECK_FLAG,
TRIM (V.SHIP_CODE) AS SHIP_CODE,
TRIM (V.TOUR_UPSELL1) AS TOUR_UPSELL1,
TRIM (V.TOUR_UPSELL2) AS TOUR_UPSELL2,
TRIM (V.TOUR_UPSELL3) AS TOUR_UPSELL3,
TRIM (V.TOUR_UPSELL4) AS TOUR_UPSELL4,
TRIM (V.TOUR_UPSELL5) AS TOUR_UPSELL5,
TRIM (OCEAN_FLAG) AS OCEAN_FLAG,
V.KIDS_ALONE_CABIN_AGE,
V.PAX_MINIMUM_AGE,
V.ESC_TWID_MINIMUM_AGE,
V.MIN_DRINKING_AGE,
V.MIN_GAMBLING_AGE,
V.MIN_WAYFIND_AGE,
V.MIN_SMOKING_AGE,
V.WEB_FEATURED_CRUISE,
V.SAILED_FLAG
FROM TVOYLST V),
W2
AS (SELECT W1.*,
CONCAT (RTRIM (S.STRING_1), RTRIM (S.STRING_2))
AS ITIN_DESC,
TRIM (S.STRING_5) AS TRADE_CODE,
TRIM (S.STRING_5) AS ITIN_TRADE_CODE,
TRIM (S.STRING_6) AS SUBTRADE_CODE
FROM W1
LEFT OUTER JOIN
TSYSDATA S
ON ( S.SYSDATA_TYPE = 'ICT'
AND W1.WEB_ITIN_CODE = S.SYSDATA_CODE)),
W3
AS (SELECT W2.*,
VL.LOCATION_CODE,
VL.WEB_DISPLAY_FLAG,
VL.PON_DISPLAY_FLAG,
VL.EZAIR_FLAG,
VL.AIR_AVAL_FLAG,
VL.AIR_AVAL_TO_BOOK_DAYS,
FULL_ROUTE_DISPLAY_FLAG
FROM W2
INNER JOIN TVOYLOC VL
ON (W2.VOYAGE_ID = VL.VOYAGE_ID)),
W4
AS (SELECT W3.*, SHIP_NAME
FROM W3
INNER JOIN TSHIPLST SH
ON (W3.SHIP_CODE = SH.SHIP_CODE))
SELECT *
FROM W4
WHERE TRADE_CODE != '';