pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: How to write such a query
Date: Fri, 18 Sep 2020 14:25:37 -0500
Message-ID: <f3ac3c95-4935-6662-27ad-a025093b5af3@gmail.com> (raw)
In-Reply-To: <CA+FnnTwPFb2ru4JkJdbyGo9+9U+bOPRTAt991qhqSMx7adrbEQ@mail.gmail.com>
References: <CA+FnnTzwZv4x8cuLWYBoOJecaXS1qFOaLPrkopF-LWkKoBNP1w@mail.gmail.com>
	<CAK8Y=HV826Qw-1tPNOZwCnz+sNqYio8tvGDFW+4jPwL4NRDfKg@mail.gmail.com>
	<CA+FnnTw9om1qTBSpzb9tsZWqj0r6ebpENj-jCtxmvhDAoRBdEA@mail.gmail.com>
	<912dd33c-c837-a226-111f-413fcb7321c1@aklaver.com>
	<CA+FnnTwPFb2ru4JkJdbyGo9+9U+bOPRTAt991qhqSMx7adrbEQ@mail.gmail.com>

On 9/18/20 1:49 PM, Igor Korot wrote:
> Hi, Adrian,
>
> On Fri, Sep 18, 2020 at 12:58 PM Adrian Klaver
> <adrian.klaver@aklaver.com> wrote:
>> On 9/18/20 10:46 AM, Igor Korot wrote:
>>> Hi, Johnathan,
>>>
>>> On Fri, Sep 18, 2020 at 12:34 PM Jonathan Strong
>>> <jonathanrstrong@gmail.com <mailto:jonathanrstrong@gmail.com>> wrote:
>>>
>>>      Are you looking to arbitrarily update the field in the fifth row, or
>>>      can the row that needs to be updated be isolated by some add'l
>>>      attribute? What's the use case?
>>>
>>>
>>> What do you mean?
>>> I don't have any other attributes.
>>>
>>> I want to understand how to emulate MS Access behavior, where you have a
>>> form
>>> with the arbitrary query, then you can go to any record in that form and
>>> update any field.
>>>
>>> Is it even possible from the "pure SQL" POV? Or Access is doing some
>>> VBA/DB/4GL magic?
>>>
>> When you are updating a record in a form the framework(Access in your
>> case) is using some identifier from that record to UPDATE that
>> particular record in the database. From when I used Access, I seem to
>> remember it would not give you INSERT/UPDATE capability on a form unless
>> you had specified some unique key for the records. So you need to find
>> what the key(generally a PRIMARY KEY) is and use that to do the UPDATE.
> But now the question becomes
>
> How to find what the primary key (or UNIQUE identifier) value is
> for row 5 in the recordset?

You're missing the point: as mentioned before, there is no "row 5". To 
update the 5th record that you've fetched, you increment a counter each time 
you fetch a row, and when you read #5, do an UPDATE X SET field1 = 'blarg' 
WHERE id = <thekeyvalue>;

-- 
Angular momentum makes the world go 'round.





view thread (36+ messages)  latest in thread

Message-ID: <f3ac3c95-4935-6662-27ad-a025093b5af3@gmail.com>
Permalink:  ../f3ac3c95-4935-6662-27ad-a025093b5af3@gmail.com/
Also on:    postgresql.org/message-id/f3ac3c95-4935-6662-27ad-a025093b5af3@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: How to write such a query
  In-Reply-To: <f3ac3c95-4935-6662-27ad-a025093b5af3@gmail.com>
  References: <CA+FnnTzwZv4x8cuLWYBoOJecaXS1qFOaLPrkopF-LWkKoBNP1w@mail.gmail.com> <CAK8Y=HV826Qw-1tPNOZwCnz+sNqYio8tvGDFW+4jPwL4NRDfKg@mail.gmail.com> <CA+FnnTw9om1qTBSpzb9tsZWqj0r6ebpENj-jCtxmvhDAoRBdEA@mail.gmail.com> <912dd33c-c837-a226-111f-413fcb7321c1@aklaver.com> <CA+FnnTwPFb2ru4JkJdbyGo9+9U+bOPRTAt991qhqSMx7adrbEQ@mail.gmail.com> <f3ac3c95-4935-6662-27ad-a025093b5af3@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox