Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJM0x-0007XZ-NK for pgsql-general@arkaria.postgresql.org; Fri, 18 Sep 2020 19:25:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kJM0w-0006GN-HQ for pgsql-general@arkaria.postgresql.org; Fri, 18 Sep 2020 19:25:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJM0w-0006GG-7g for pgsql-general@lists.postgresql.org; Fri, 18 Sep 2020 19:25:46 +0000 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kJM0p-0000TF-Rh for pgsql-general@lists.postgresql.org; Fri, 18 Sep 2020 19:25:45 +0000 Received: by mail-ot1-x343.google.com with SMTP id g96so6392200otb.12 for ; Fri, 18 Sep 2020 12:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=dxmBitlQL/m36AZ6pHjOwLYM6ab3BN+TMS/DpZbpmKQ=; b=pV2cka6cUMD+mgg14opJ3wdZxLXjVe96hcZ9st9lz83PNFuPCU2cJLDDmy5Ilbzqma gSVe51/yePRCqWdmnnTFYr8bNH+m3A44i7I9K0djOaN7RsA+Bm1I3d5Z560h9NNytuLK HLmme4qWrqt8lPpcwtHymod5q4ulJa931NMkLzOspftarJ4l55nNvoeSd3DdHxozbsoA hwL237tV7euJCIXryx6TSjK5LHMvPGJWKeX8KxRSc6r3D2/phV/SZx8kKUr67q5ngQUe XWMkfk7T7oKevKfDaLqoDw3pkJOLWJDxu8xg0hGRCpfG8QQSIVQQxDW6nNVSjAyifJjA xDGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=dxmBitlQL/m36AZ6pHjOwLYM6ab3BN+TMS/DpZbpmKQ=; b=UQk0P5XSNZr0/4C0qKSIuhwtXc8jIKnn6O1MoLDUsF4snP469HRy5vcmPuoV2DaRK0 tIhhq3SMrpPWn9a7Hz1KzZLyBFQECp+2H/SymyFXvs8GGF2Nh2N9L6XxSZsdLNNBKLN6 R89NRrwhJbVFV76DZaq3tWNZRBl89QaG9YaiueYiVGr/BIvKbjRaNCqsz/RCVc/R1YIj x7cIUt/RuColUOjJq/alTuhbbUQz380RGFINHEFA169GVP7cyMyR0kRVdd5jiDVSWZ0r ERj2ksH85bXNvmqFw/pjkjpiNZPkJ5w/pejM4vWoGg+NoA8UitP4zw2SfuvIpqUW3QNj 2fDw== X-Gm-Message-State: AOAM531oF32py1pIxRWRfA4J0ATDoz4JcZNJTiTV3uAr42Woq7qKrcBd Zdsl4rmG07JlTGBlY+Y6Bp1j9vNOF7X2UA== X-Google-Smtp-Source: ABdhPJyW2L0KRpVsEud9GwRMcKugY4tnBRVGWtb6TM7KNtObRWqBRsRfBAGF0SUDDtKvNZFNrH+o3w== X-Received: by 2002:a9d:c0a:: with SMTP id 10mr22285555otr.249.1600457138876; Fri, 18 Sep 2020 12:25:38 -0700 (PDT) Received: from [192.168.1.10] (ip174-67-143-111.no.no.cox.net. [174.67.143.111]) by smtp.googlemail.com with ESMTPSA id i5sm3264228otj.19.2020.09.18.12.25.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Sep 2020 12:25:38 -0700 (PDT) Subject: Re: How to write such a query To: pgsql-general@lists.postgresql.org References: <912dd33c-c837-a226-111f-413fcb7321c1@aklaver.com> From: Ron Message-ID: Date: Fri, 18 Sep 2020 14:25:37 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 9/18/20 1:49 PM, Igor Korot wrote: > Hi, Adrian, > > On Fri, Sep 18, 2020 at 12:58 PM Adrian Klaver > wrote: >> On 9/18/20 10:46 AM, Igor Korot wrote: >>> Hi, Johnathan, >>> >>> On Fri, Sep 18, 2020 at 12:34 PM Jonathan Strong >>> > 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 = ; -- Angular momentum makes the world go 'round.