a query question - Mailing list pgsql-sql

From Jaime Casanova
Subject a query question
Date
Msg-id BAY8-F34WnHg4UeaCYP00068c0b@hotmail.com
Whole thread Raw
List pgsql-sql
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



pgsql-sql by date:

Previous
From: Michelle Murrain
Date:
Subject: simple addition of constraints problem
Next
From: Stephan Szabo
Date:
Subject: Re: simple addition of constraints problem