Hola señores.
Quisiera saber como establecer parámetros en una consulta sql, yo normalmente uso la siguiente sintaxis:  
 Código HTML:
 -- Function: pr_r_report(codigo text, tabla text)
-- DROP FUNCTION pr_r_report(text, text);
CREATE OR REPLACE FUNCTION pr_r_report(text, text)
  RETURNS SETOF count AS
$BODY$DECLARE
	registros count;
BEGIN
	--execute 'delete from rep_alta';
	FOR registros IN EXECUTE 'select count(*) from ' || quote_literal(tabla) || ' where idalta=' ||  quote_literal(codigo) loop
	return next registros;
end loop;
return;
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION pr_r_report(text, text) OWNER TO postgres;
 Pero al ejecutarse esta función por ejemplo con estos valores  
 Código HTML:
 select * from  pr_r_report1('4','altadetalle')
 La consulta se ejecuta de la siguiente manera  
 Código HTML:
 select count(*) from 'altadetalle' where altadetalle='4'
 Emitiéndose un error. ¿Hay alguna otra manera de establecer los parámetros sin necesidad de utilizar quote_literal? Me sería muy satisfactoria su ayuda, gracias.