pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jaime Casanova <el_vigia_ec@hotmail.com>
To: pgsql-sql@postgresql.org
Subject: a query question
Date: Tue, 08 Jun 2004 22:05:38 +0000
Message-ID: <BAY8-F34WnHg4UeaCYP00068c0b@hotmail.com> (raw)

hi all,

i was trying to migrate some data into a new structure i created. so i 
execute this exact query:

insert into rec_t_ordenpago("ent_codigo", "sec_codigo", "ani_codigo", 
"orp_numero",
                            "orp_tipopersona", "orp_persona", "cic_codigo",
                            "esp_codigo", "cur_codigo", "cur_paralelo",
                            "rub_codigo", "orp_valor", "orp_fechaemision",
                            "orp_fechavencimiento", "ban_codigo", 
"cta_numero",
                            "est_codigo")
select cua.ent_codigo, cua.sec_codigo, cua.ani_codigo,
       (select (nvl(max(orp_numero), 0) + 1) from rec_t_ordenpago),
       'AL', alcu.alu_codigo, cua.cic_codigo, cua.esp_codigo, 
cua.cur_codigo,
       cua.cur_paralelo, cua.rub_codigo, cua.cpa_valor, current_date,
       cua.cpa_fechavencimiento, null, null, 'PE'
  from rec_m_cuadropagos cua, aca_t_alumnocurso alcu
where cua.ent_codigo    = 1
   and alcu.ent_codigo   = cua.ent_codigo
   and alcu.sec_codigo   = cua.sec_codigo
   and alcu.ani_codigo   = cua.ani_codigo
   and alcu.cic_codigo   = cua.cic_codigo
   and alcu.esp_codigo   = cua.esp_codigo
   and alcu.cur_codigo   = cua.cur_codigo
   and alcu.cur_paralelo = cua.cur_paralelo

but i ended up with duplicate key error then i replace the        (select 
(nvl(max(orp_numero), 0) + 1) from rec_t_ordenpago) part with 
nextval('seq1') and that work.
So my question is, is this a postgreSQL limitation or is the way it have to 
happen? why?


thanx in advance,

Jaime Casanova

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail




Message-ID: <BAY8-F34WnHg4UeaCYP00068c0b@hotmail.com>
Permalink:  ../BAY8-F34WnHg4UeaCYP00068c0b@hotmail.com/
Also on:    postgresql.org/message-id/BAY8-F34WnHg4UeaCYP00068c0b@hotmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: el_vigia_ec@hotmail.com
  Subject: Re: a query question
  In-Reply-To: <BAY8-F34WnHg4UeaCYP00068c0b@hotmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox