【发布时间】:2019-09-28 05:06:08
【问题描述】:
我已经定义了这个函数:
SELECT dblink_connect('conne1', 'dbname=bdp3e1');
SELECT dblink_connect('conne2', 'dbname=bdp3e2');
CREATE OR REPLACE FUNCTION insertEditorial(nombre VARCHAR(100), CIF INTEGER, ubicacion VARCHAR(50))
RETURNS void AS
$insertEditorial$
BEGIN
IF ubicacion IS NULL THEN
dblink_exec('conne2', 'INSERT INTO Editorial VALUES (nombre, CIF);');
ELSE
dblink_exec('conne1', 'INSERT INTO Editorial VALUES (nombre, CIF, ubicacion);');
ENDIF;
END;
$insertEditorial$ LANGUAGE plpgsql;
但是在执行时,postgreSQL 会返回以下错误:
psql:PR3_Procedures.sql:14: ERROR: syntax error at or near "dblink_exec"
LINE 6: dblink_exec('conne2', 'INSERT INTO Editorial VALUES ...
这有什么问题?
【问题讨论】:
标签: sql database postgresql if-statement plpgsql