Hi. I have this rule for inserting in a view: -------------------------------------- te rule v_address_ins as on insert to v_address do instead (insert into address(calle,vía,localidad,provincia) values ( NEW.calle, get_vía(NEW.vía), get_localidad(NEW.localidad), get_provincia(NEW.provincia)); select currval('address_cod_seq');); -------------------------------------- I don't know if this is a good form. When I do an insert into v_address, get automagically cod of tuple inserted in same operation. Problem is that it doesn't work inside a plpgsql function. I get error: ERROR: unexpected SELECT query in exec_stmt_execsql() When trying selecting result of insert, I get parser error. Is there any form of doing this?. Thanks. David ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html