Re: BUG #2984: Bug Creating or Updating a View - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #2984: Bug Creating or Updating a View
Date
Msg-id 22409.1171256045@sss.pgh.pa.us
Whole thread Raw
In response to BUG #2984: Bug Creating or Updating a View  ("Gabriel Bravo" <gbravo2k@yahoo.com>)
List pgsql-bugs
"Gabriel Bravo" <gbravo2k@yahoo.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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #2983: Nonsense error: "Table has type interval, but query expects interval"
Next
From: Zdenek Kotala
Date:
Subject: Re: BUG #2969: Inaccuracies in Solaris FAQ