create function test(integer) returns integer as ' DECLARE key ALIAS FOR $1; table_data entity%ROWTYPE; BEGIN INSERT INTO mv_name (ent_id, ent_eid, ent_des) select ent_id, ent_eid, ent_des from entity limit 100 return 1;end;' LANGUAGE 'plpgsql';