Re: Update condicionados por otras tablas

From: Yosip Abraham Curiel Jiménez <snake77se(at)gmail(dot)com>
To: Miguel Rodríguez Penabad <penabad(at)gmail(dot)com>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Update condicionados por otras tablas
Date: 2007-09-19 16:03:50
Message-ID: d72a0de30709190903x590597cen7e0b6e7ca0e014a6@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

asi fue que lo probe:

update t_temp_edificaciones set
edo = (select edo from ts_edificaciones_puerto_ordaz where id =
t_temp_edificaciones.id and idut = t_temp_edificaciones.idut),
mun = (select mun from ts_edificaciones_puerto_ordaz where id =
t_temp_edificaciones.id and idut = t_temp_edificaciones.idut),
par = (select par from ts_edificaciones_puerto_ordaz where id =
t_temp_edificaciones.id and idut = t_temp_edificaciones.idut),
sec = (select sec from ts_edificaciones_puerto_ordaz where id =
t_temp_edificaciones.id and idut = t_temp_edificaciones.idut),
manz = (select manz from ts_edificaciones_puerto_ordaz where id =
t_temp_edificaciones.id and idut = t_temp_edificaciones.idut),
parcela = (select parcela from ts_edificaciones_puerto_ordaz where id =
t_temp_edificaciones.id and idut = t_temp_edificaciones.idut);

On 9/19/07, Yosip Abraham Curiel Jiménez <snake77se(at)gmail(dot)com> wrote:
>
> mmmm, a mi no me funciona, y creo que mi problema es que mis llaves
> primarias son compuesta por dos campos de las tablas como te puse en el
> ejemplo que encontre, el error que me dice es que el subquery me trae mas de
> un valor.
>
> "ERROR: more than one row returned by a subquery used as an expression
> Estado SQL:21000"
>
>
>
> On 9/19/07, Miguel Rodríguez Penabad <penabad(at)gmail(dot)com> wrote:
> >
> > El 19/09/07, Yosip Abraham Curiel Jiménez < snake77se(at)gmail(dot)com>
> > escribió:
> > > no... me refiero a el ejemplo que me enviaste, algo asi:
> > >
> > > update a
> > > set
> > > f_a=(select f_x from b where id= a.id)
> > , --una coma aquí
> > > f_b=(select f_y from b where id=a.id)
> > , --una coma aquí
> > > f_c=(select f_z from b where id= a.id)
> > , --una coma aquí
> > > f_d=(select f_r from b where id=a.id)
> > > where id in (select id from b)
> >
> > Aparte de poner las comas donde te digo, sí, yo lo haría así, ya que
> > es la opción que permite el estándar.
> > Peeeero... viendo tu otro mensaje, acabo de ver que postgres permite
> > poner
> > una cláusula from en el update, así que
> > update a
> > set f_a=b.f_x,
> > f_b=b.f_y
> > from b
> > where a.id=b.id;
> > debería funcionar.
> > Eso sí, no es estándar (SQL:2003 al menos, no creo que lo sea ni de
> > SQL-92)
> > por lo que no puedo decirte exactamente lo que haría. De todos modos,
> > lo probé y me modificó correctamente sólo las filas que tenían
> > correspondencia en
> > la tabla b.
> >
> >
> > --
> > Miguel Rodríguez Penabad
> >
>
>
>
> --
> Yosip Curiel (Snake77SE)

--
Yosip Curiel (Snake77SE)

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Miguel Rodríguez Penabad 2007-09-19 16:07:39 Re: Update condicionados por otras tablas
Previous Message Yosip Abraham Curiel Jiménez 2007-09-19 16:02:30 Re: Update condicionados por otras tablas