Using PL/pgSQL in the etl scenario