Re: [GENERAL] Using 'WITH SELECT' Results Do Not Match 'SELECT FROM ' Results

Tue, 04 Jul 2017 21:31:34 -0700

Adrian,

Working from my phone wasn't such a good idea!

When I said 'INSERT' I meant 'WITH'. My excuse is that the 'WITH' statement is 
building a temporary table ( at least logically ) so there is at least an 
implicit 'INSERT' there.

/s/jr
Sent from my iPhone

> On Jul 3, 2017, at 23:12, Adrian Klaver <adrian.kla...@aklaver.com> wrote:
> 
>> On 07/03/2017 05:20 PM, Jerry Regan wrote:
>> Adrian,
>> Thank you for your reply!
>> I apologize in advance for not being detailed below. Hard to do from my 
>> phone.
>> I did have to move the 'ORDER BY', but not outside the 'WITH'. My first 
>> workaround parenthesized the select containing the 'ORDER BY', forcing it to 
>> be evaluated before the 'INSERT'. That worked.
> 
> Not sure where the INSERT comes into the picture, but glad you got it working.
> 
>> But I never liked using a sequence for the c_id column. And using the 
>> sequence on my personal workstation was maybe safe, but given that sequences 
>> not are guaranteed to be without gaps, that was not very portable.
> 
> Yeah, that concerned me also, still I figured one problem at a time.
> 
>> So I searched a bit and found I could use 'row_number()' instead. That 
>> approach allowed me to use the 'ORDER BY' required by 'row_number()'.
>> That worked and is far more portable to other postgresql instances.
>> I really do appreciate your response. It is also my nature to continue my 
>> research even after asking for help. However I find my answer, one validates 
>> the other.
> 
> Sometimes it just a matter a little push to get out of the rut:)
> 
>> Thanks again!
>> /s/jr
>> Sent from my iPhone
> 
> 
> -- 
> Adrian Klaver
> adrian.kla...@aklaver.com


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to