Lists: | 사설 토토 : 사설 토토 메일 링리스트 : 2015-02-12 이후 ECPUG |
---|
From: | Alcides Rivera <alcides(dot)rivera84(at)gmail(dot)com> |
---|---|
To: | Foros Postgre Ecuador <ecpug(at)postgresql(dot)org> |
Subject: | Actualización Masiva Identificadores en PostgreSQL |
Date: | 2015-02-12 21:19:16 |
Message-ID: | CAMV_z1jCAubxzT5=yftC4vg2wZFtRZruAESpwKA686ZOe1mt_A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | 사설 토토 : 사설 토토 메일 링리스트 : 2015-02-12 이후 ECPUG |
Compañeros,
Tengo el siguiente inconveniente en PostgreSQL deseo hacer un update masivo
que modifique el numero interno de la tabla de facturas, pero que no haya
saltos en la serie es decir que quede de la siguiente manera:
ID NUMERO
1 DV/000001
3 DV/000002
4 DV/000003
5 DV/000004
6 DV/000005
8 DV/000006
9 DV/000007
estaba intentadole con el siguiente script pero no me funciona:
update account_invoice
set number = trim('DV/' ltrim(to_char(row_number() over(), '000000')))
where type = 'out_invoice'
Alguna sugerencia,
Saludos,
From: | Jaime Casanova <jaime(dot)casanova(at)2ndquadrant(dot)com> |
---|---|
To: | Alcides Rivera <alcides(dot)rivera84(at)gmail(dot)com> |
Cc: | Foros Postgre Ecuador <ecpug(at)postgresql(dot)org> |
Subject: | Re: [ecpug] Actualización Masiva Identificadores en PostgreSQL |
Date: | 2015-02-13 17:25:43 |
Message-ID: | CAJKUy5gr4pdgHYba9BnGOYE2MQinRAo4+70SEvLOvg8tpAxkpw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | 스포츠 토토 사이트 : 스포츠 토토 사이트 메일 링리스트 : 2015-02-13 이후 ECPUG 17:25 |
2015-02-12 16:19 GMT-05:00 Alcides Rivera <alcides(dot)rivera84(at)gmail(dot)com>:
> Compañeros,
>
> Tengo el siguiente inconveniente en PostgreSQL deseo hacer un update masivo
> que modifique el numero interno de la tabla de facturas, pero que no haya
> saltos en la serie es decir que quede de la siguiente manera:
>
> ID NUMERO
> 1 DV/000001
> 3 DV/000002
> 4 DV/000003
> 5 DV/000004
> 6 DV/000005
> 8 DV/000006
> 9 DV/000007
>
¿Qué versión de PostgreSQL es esta? Prueba con esto:
with q as (select 'DV/' || trim(to_char(row_number() over (),
'000000')) row_number, * from account_invoice where type =
'out_invoice')
update account_invoice set number = row_number from q where
account_invoice.id = q.id;
--
Jaime Casanova www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitación