title: Error: a column definition list is required for functions in dblink using PostgreSQL 9.3
body: <p>I have the following function:</p>
  
  <p>In which I am updating one database table by joining other database table by using the <code>dblink()</code>.</p>
  
  <p>I have installed:</p>
  
  <pre><code>create extension dblink;
  </code></pre>
  
  <p>The more details as shown below:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION Fun_test
  (
      Table_Name varchar
  ) 
  RETURNS void AS
  
  $BODY$
  
  DECLARE
      dynamic_statement varchar;
  
  BEGIN
      perform dblink_connect('port=5234 dbname=testdb user=postgres password=****');
  
  
      dynamic_statement := 'With CTE AS 
      ( 
          Select HNumber,JoiningDate,Name,Address
          From '|| Table_Name ||'c 
      )
      , Test_A 
      AS 
      ( 
      Select Row_Number() over ( Partition by PNumber order by Date1 Desc,Date2 Desc) AS roNum,
      Name,PNumber,Date1,Address
      From dblink(
              ''Select distinct PNumber,
              (
                  case when fname is null then '' else fname end || '' ||
                  case when lname is null then '' else lname end 
              ) as FullName,
              Address,
              Date1,Date2
              From testdb_Table
              inner join CTE on CTE.HNumber = PNumber''
             )  Num 
      )
      Update CTE
      Set 
      Name = Test_A.FullName
      ,SubAddress_A = Test_A.Address
      ,Date1 = Test_A.Date1
      from CTE 
      left outer join Test_A on 
      CTE.HNumber= Test_A.PNumber 
      where roNum =1';
  
      RAISE INFO '%',dynamic_statement;
  
      EXECUTE dynamic_statement;
  
      perform dblink_disconnect();
  END;
  
  $BODY$
  
  LANGUAGE PLPGSQL;   
  </code></pre>
  
  <p><strong>Calling Function</strong>:</p>
  
  <pre><code>select fun_test('test1');
  </code></pre>
  
  <p>Getting an error:</p>
  
  <pre><code>ERROR:  a column definition list is required for functions returning "record"
  LINE 11:    From dblink
                   ^
  </code></pre>