我想在PL/pgsql中创建一个目录:
CREATE OR REPLACE FUNCTION getNextId() RETURNS VARCHAR(200) AS
$BODY$
DECLARE
mfId integer;
rootDir varchar(50) := 'mfdata/';
createDir text := 'mkdir --mode=777 -p mfdata';
dir varchar(100);
BEGIN
INSERT INTO copy.history(time) values(now()) RETURNING id INTO mfId;
EXECUTE('COPY (SELECT 1) TO PROGRAM ' || quote_literal('mkdir --mode=777 -p mfdata '));
RETURN 'mfdata' || mfId;
END;
$BODY$
LANGUAGE plpgsql;
但发生如下错误:
问题出在哪里?如何在PL / pgSQL中动态创建目录?