Skip site navigation (1) Skip section navigation (2)

Re: BUG #2984: Bug Creating or Updating a View

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Gabriel Bravo" <gbravo2k(at)yahoo(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2984: Bug Creating or Updating a View
Date: 2007-02-12 04:54:05
Message-ID: 22409.1171256045@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"Gabriel Bravo" <gbravo2k(at)yahoo(dot)com> writes:
> I had a view created as:

> CREATE OR REPLACE VIEW vensamblado AS 
>  SELECT DISTINCT cuestionario.idcuestionario,
> cuestionario.nombrecuestionario, riesgo.idriesgo, riesgo.nombreriesgo,
> riesgo.resultado, pregunta.idpregunta, pregunta.nombrepregunta,
> pregunta.tiporespuesta, pregunta.posicionrespuestas, pregunta.tipocontrol,
> contenidocuestionario.ordenpregunta, opcion.idopcion, opcion.nombreopcion,
> opcion.valor
> ...
>   ORDER BY cuestionario.idcuestionario, riesgo.idriesgo,
> pregunta.idpregunta, contenidocuestionario.ordenpregunta,
> opcion.nombreopcion, cuestionario.nombrecuestionario, riesgo.nombreriesgo,
> riesgo.resultado, pregunta.nombrepregunta, pregunta.tiporespuesta,
> pregunta.posicionrespuestas, pregunta.tipocontrol, opcion.idopcion,
> opcion.valor;

> I'm trying to replace that view because the ORDER clause is incorrect and I
> want to change it.

It's not wrong and you can't fix it --- all the elements of the SELECT
DISTINCT list have to be included in the order-by list.  Any you omit
will get added in behind the scenes.

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: Filippo TosoDate: 2007-02-12 10:06:36
Subject: BUG #2993: The program "postgres" is needed by initdb but was not found ...
Previous:From: Tom LaneDate: 2007-02-12 04:09:33
Subject: Re: BUG #2983: Nonsense error: "Table has type interval, but query expects interval"

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group