I want to make a flexible function on PL/pgSQL that checks if a row exists on a table. I say 'flexible' because I want it to receive as parameter the row name, table name and the search term.

This is how I tried to do it, but didn't work:

Code:
CREATE OR REPLACE FUNCTION exists_on ( varchar(100), varchar(100), varchar(100) ) RETURNS boolean AS '
  DECLARE
  	search_table ALIAS FOR $1;
  	search_row ALIAS FOR $2;
  	search_name ALIAS FOR $3;
  BEGIN
  	IF ((SELECT search_row FROM search_table WHERE search_row=search_name) != 0) THEN
  		RETURN TRUE;
  	ELSE
  		RETURN FALSE;
  	END IF;
  END'
  LANGUAGE 'plpgsql';
It doesn't substitute the aliases and so it crashes. Any idea?