DO $$
DECLARE
_host TEXT := 'localhost';
_port TEXT := '5432';
_user TEXT := 'postgres';
_pass TEXT := 'postgres';
_db TEXT := 'schema';
BEGIN
CREATE OR REPLACE VIEW companies AS
SELECT
id
FROM
dblink(
'postgresql://' || _user || ':' || _pass || '@' || _host || ':' || _port || '/' || _db,
'select id from company'
) AS t1(
id TEXT
);
DROP VIEW IF EXISTS companies CASCADE;
COMMIT;
END $$;
我想从下面的变量创建字符串配置
'postgresql://postgres:postgres@localhost:5432/schema'
我想从下面的变量创建字符串配置
_host TEXT := 'localhost';
_端口文本 := '5432';
_user TEXT := 'postgres';
_pass TEXT := 'postgres';
_db TEXT := '模式';
=> 'postgresql://postgres:postgres@localhost:5432/schema'