From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Hellmuth Vargas <hivs77(at)gmail(dot)com> |
Cc: | Lista Postgres ES <pgsql-es-ayuda(at)postgresql(dot)org>, Francisco Olarte <folarte(at)peoplecall(dot)com> |
Subject: | Re: [GENERAL] No funciona WITH con mas de 2 sentencias DML |
Date: | 2015-10-06 19:01:27 |
Message-ID: | 20151006190127.GD137803@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda pgsql-general |
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(at)postgresql(dot)org)
Para cambiar tu suscripción:
http://www.postgresql.org/mailpref/pgsql-es-ayuda
From | Date | Subject | |
---|---|---|---|
Next Message | Hellmuth Vargas | 2015-10-06 19:17:30 | Re: [GENERAL] No funciona WITH con mas de 2 sentencias DML |
Previous Message | anthony | 2015-10-06 17:58:30 | Re: Auditoría y evaluación |
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2015-10-06 19:07:50 | Re: Best practices for aggregate table design |
Previous Message | droberts | 2015-10-06 18:53:22 | Re: Best practices for aggregate table design |