title: Postgres function using DDL statement
body: <p>I am trying to create function in Postgres which can automate user creation process but it doesn;t accept parameter in DDL statement.</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION AUTOUSER (uname varchar(20))
  RETURNS TEXT AS $$
  DECLARE 
        nm varchar(20);
  BEGIN
      nm=$1;
      CREATE USER nm WITH PASSWORD 'Iash12';
      GRANT ALL ON DATABASE iashdb TO nm;
      GRANT ALL ON  ALL TABLES IN SCHEMA public TO nm;
      RETURN CONCAT(nm,' Created');
  END;
  $$ 
  LANGUAGE plpgsql;
  </code></pre>
  
  <p>Above function create user as 'nm' instead of passed parameter name however RETURN statement showing correct result. Thanks in advance,</p>