Hola Alvaro...

mmm devolviendo ademas el teléfono desde base... mmm no lo había
considerado.. Mil Gracias

2015-10-06 14:01 GMT-05:00 Alvaro Herrera <alvhe...@2ndquadrant.com>:

> 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
>



-- 
Cordialmente,

Ing. Hellmuth I. Vargas S.
Esp. Telemática y Negocios por Internet
Oracle Database 10g Administrator Certified Associate
EnterpriseDB Certified PostgreSQL 9.3 Associate

Responder a