I found a difficult solution to this problem, but possible. After I looked and read almost everywhere, I tried something, and it worked.
if the error "CREATE DATABASE cannot be executed from a function or a line with several commands", we can force the use of one command line using dblink. And do it to connect to yourself.
Check dblink installation instructions on dblink
PERFORM replication.dblink_connect('myconn','host=127.0.0.1 port=5432 dbname=mydb user=username password=secret'); PERFORM replication.dblink_exec('myconn', 'CREATE DATABASE "DBFROMUSER'||id||'" TEMPLATE "TEMPL'||type||'";',false); PERFORM replication.dblink_disconnect('myconn');
In my case, using different types of patterns.
Hello
Esteban Atenor Sep 04 '12 at 17:20 2012-09-04 17:20
source share