Re: [GENERAL] No funciona WITH con mas de 2 sentencias DML

From: Hellmuth Vargas <hivs77(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(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:17:30
Message-ID: CAN3Qy4qysAz9yGwdocPKMPLYOVC7ZfZSWUNAt+KOLc_fLmOn9g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda pgsql-general

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 <alvherre(at)2ndquadrant(dot)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

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Hellmuth Vargas 2015-10-07 13:46:05 Re: ayuda con funcion List
Previous Message Alvaro Herrera 2015-10-06 19:01:27 Re: [GENERAL] No funciona WITH con mas de 2 sentencias DML

Browse pgsql-general by date

  From Date Subject
Next Message Oleksii Kliukin 2015-10-06 20:13:15 dubious optimization of the function in SELECT INTO target list
Previous Message David G. Johnston 2015-10-06 19:07:50 Re: Best practices for aggregate table design