add
This commit is contained in:
@@ -88,8 +88,14 @@ BEGIN
|
|||||||
WHERE table_name = 'exchange_info_view'
|
WHERE table_name = 'exchange_info_view'
|
||||||
) INTO view_exists;
|
) INTO view_exists;
|
||||||
|
|
||||||
-- 创建或更新视图
|
-- 若视图存在,先删除(避免字段名冲突)
|
||||||
CREATE OR REPLACE VIEW exchange_info_view AS
|
IF view_exists THEN
|
||||||
|
DROP VIEW exchange_info_view;
|
||||||
|
RAISE NOTICE '已删除旧视图 exchange_info_view';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- 重新创建视图(无冲突风险)
|
||||||
|
CREATE VIEW exchange_info_view AS
|
||||||
SELECT
|
SELECT
|
||||||
u.id AS exchange_id,
|
u.id AS exchange_id,
|
||||||
n.name AS name,
|
n.name AS name,
|
||||||
@@ -99,17 +105,16 @@ BEGIN
|
|||||||
FROM
|
FROM
|
||||||
exchange u
|
exchange u
|
||||||
JOIN
|
JOIN
|
||||||
exchange_name n ON u.id = n.exchange_id
|
exchange_name n ON u.id = n.exchange_id AND n.deleted = FALSE
|
||||||
JOIN
|
JOIN
|
||||||
exchange_short_name sn ON u.id = sn.exchange_id
|
exchange_short_name sn ON u.id = sn.exchange_id AND sn.deleted = FALSE
|
||||||
JOIN
|
JOIN
|
||||||
exchange_code c ON u.id = c.exchange_id
|
exchange_code c ON u.id = c.exchange_id AND c.deleted = FALSE
|
||||||
WHERE
|
WHERE
|
||||||
u.deleted = FALSE;
|
u.deleted = FALSE;
|
||||||
|
|
||||||
-- 根据视图是否已存在输出不同提示
|
|
||||||
IF view_exists THEN
|
IF view_exists THEN
|
||||||
RAISE NOTICE '视图 exchange_info_view 已更新';
|
RAISE NOTICE '视图 exchange_info_view 已更新(删除旧视图后重建)';
|
||||||
ELSE
|
ELSE
|
||||||
RAISE NOTICE '视图 exchange_info_view 已创建';
|
RAISE NOTICE '视图 exchange_info_view 已创建';
|
||||||
END IF;
|
END IF;
|
||||||
|
|||||||
Reference in New Issue
Block a user