create or replace function schema.insert_function(_schema text, _table text) returns integer as $BODY$ declare _affected integer; begin set search_path to _schema; insert into _table (columns) values(vals); return 0; end; $BODY$ language plpgsql; is there any whay to get the functionality of above to work with out have to build a string and use the execute function?