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

Re: select issue with order v8.1

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Terry <td3201(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: select issue with order v8.1
Date: 2010-02-26 21:16:03
Message-ID: dcc563d11002261316j38f0e579tb97d9d5a6e2c3c2b@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-general
On Fri, Feb 26, 2010 at 1:46 PM, Terry <td3201(at)gmail(dot)com> wrote:
> On Thu, Feb 25, 2010 at 9:42 AM, Terry <td3201(at)gmail(dot)com> wrote:
>> On Wed, Feb 24, 2010 at 10:30 PM, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> wrote:
>>> On Wed, Feb 24, 2010 at 8:50 PM, Terry <td3201(at)gmail(dot)com> wrote:
>>>> Hello,
>>>>
>>>> I have an application that is doing something stupid in that it is
>>>> tacking on its own order clause at the end of the statement I am
>>>> providing.
>>>>
>>>> For example, I am putting this statement in:
>>>> select ev_id,type,ev_time,category,error,ev_text,userid,ex_long,client_ex_long,ex_text
>>>> from clients_event_log limit 100
>>>>
>>>> It is tacking on ORDER BY ev_id.  The problem is that isn't per the
>>>> syntax.  Can anyone think of anything clever to get around this stupid
>>>> application doing what it is doing?  For example, anything I can do
>>>> beside limit?
>>>>
>>>> I appreciate the thoughts!
>>>
>>> You could either wrap it in a subselect or make a view.
>>>
>>> select * from (select
>>> ev_id,type,ev_time,category,error,ev_text,userid,ex_long,client_ex_long,ex_text
>>> from clients_event_log limit 100) as a
>>>
>>> and an order by tacked on the end of that is ok.
>>>
>>
>> This and the previous poster's advice both worked.  Thank you.
>> However, I am having another issue where the application is not
>> viewing a 'serial' data type as a number.  Clearly none of this is a
>> postgres issue.  Stupid programming.
>>
>
> Based on my above comment.  Is there a way to create a view or
> something that presents the serial column as an integer?  In the end,
> that's what it is but on the insert side it is incrementing the number
> for the underlying app.  I'm not a SQL guy but that's my understanding
> anyways.  I could even perhaps do a table copy process and simply make
> the destination type an integer rather than a serial?    Just thinking
> out loud.  Anyone have an idea here?

You could alter it to an int, then create a sequence with the same
start as the old sequence and assign it as default for the int.

In response to

Responses

pgsql-general by date

Next:From: Marc G. FournierDate: 2010-02-26 21:52:00
Subject: Cacti + PostgreSQL Graphing
Previous:From: TerryDate: 2010-02-26 20:46:10
Subject: Re: select issue with order v8.1

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