title: Create procedure to execute query in PostgreSQL
body: <p>Maybe it's not new case, but I'm stack about it. This is the procedure that I use to run query, it run normally in MySQL, but not in PostgreSQL and I don't know how to do that. The procedure(in MySQL) looks like :</p>
  <pre><code>CREATE PROCEDURE runstatement(IN statement TEXT)
  BEGIN 
   set @s = statement; 
   IF LENGTH(@s) &lt;&gt; 0 THEN PREPARE stmt FROM @s; 
   EXECUTE stmt; 
   DEALLOCATE PREPARE stmt; 
   END IF; 
  END
  </code></pre>
  <p>The questions :</p>
  <ol>
  <li><p>How do I convert it to PostgreSQL version?</p>
  </li>
  <li><p>How do I call this procedure(runstatement) when I need it in another procedure? In MySQL I know as <code>CALL runstatement(param)</code>.</p>
  <p>Thanks for each reply. I'm new in database programming especially PostgreSQL.</p>
  </li>
  </ol>