Hellmuth Vargas escribió: > Realice este pequeño laboratorio para presentar la inquietud:
WITH base AS ( INSERT INTO master (identificacion, nombre, telefono) SELECT a.identificacion, a.nombre, a.telefono FROM carga AS a GROUP BY a.identificacion, a.nombre, a.telefono RETURNING id, telefono, identificacion ), insertadetalle AS ( INSERT INTO detalle (tarjeta, master_id) SELECT a.tarjeta,b.id FROM carga AS a JOIN base as b ON a.identificacion = b.identificacion RETURNING master_id ) INSERT INTO marcadortelefonia ( telefono, master_id ) SELECT b.telefono, b.identificacion::int FROM base b GROUP BY b.telefono, b.identificacion::int; ??? -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services - Enviado a la lista de correo pgsql-es-ayuda (pgsql-es-ayuda@postgresql.org) Para cambiar tu suscripción: http://www.postgresql.org/mailpref/pgsql-es-ayuda