add
This commit is contained in:
@@ -88,8 +88,14 @@ BEGIN
|
||||
WHERE table_name = 'exchange_info_view'
|
||||
) 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
|
||||
u.id AS exchange_id,
|
||||
n.name AS name,
|
||||
@@ -99,17 +105,16 @@ BEGIN
|
||||
FROM
|
||||
exchange u
|
||||
JOIN
|
||||
exchange_name n ON u.id = n.exchange_id
|
||||
exchange_name n ON u.id = n.exchange_id AND n.deleted = FALSE
|
||||
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
|
||||
exchange_code c ON u.id = c.exchange_id
|
||||
exchange_code c ON u.id = c.exchange_id AND c.deleted = FALSE
|
||||
WHERE
|
||||
u.deleted = FALSE;
|
||||
|
||||
-- 根据视图是否已存在输出不同提示
|
||||
IF view_exists THEN
|
||||
RAISE NOTICE '视图 exchange_info_view 已更新';
|
||||
RAISE NOTICE '视图 exchange_info_view 已更新(删除旧视图后重建)';
|
||||
ELSE
|
||||
RAISE NOTICE '视图 exchange_info_view 已创建';
|
||||
END IF;
|
||||
|
||||
Reference in New Issue
Block a user