title: Postgres Dynamic Query Function
body: <p>I need to create a function that will run a query and return the results with the table name and the column name being arugments given to the function. I currently have this:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION qa_scf(tname character varying, cname character varying)
  RETURNS SETOF INT AS
  $BODY$
  BEGIN
  RETURN QUERY SELECT * FROM tname WHERE cname !='AK' AND cname!='CK';
  END;
  $BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100
  ROWS 1000;
  </code></pre>
  
  <p>This gives me the error "Relation 'tname' des not exist" when run. I'm new to function creating for Postgres, so any help is appreciated. I feel like the return int is wrong, but I don't know what else to put to make it return all columns for the rows returned. Thanks!</p>