Trigger - create folder/folder structure on new row
Hi is there any way to create a folder or folder structure to a specific location on a network drive with postgresql trigger, when a new row added?.
the new row would contains the new folder names in different fields.
One solution for that is to use the (untrusted) procedure language pl/perlu for your trigger, where you can use standard perl commandos for filesystem manipulation. You will have to take care about correct access rights for creating the directories, however.
CREATE LANGUAGE plperlu; CREATE FUNCTION perlfunc(text) RETURNS integer AS $$ mkdir($_); $$ LANGUAGE plperlu
Note that the standard pl/perl, as a trusted language, will catch such attempts and reject access to the system environment, so indeed plperlu must be used.