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 1mSMeZ-0006wh-EC for pgsql-sql@arkaria.postgresql.org; Mon, 20 Sep 2021 17:00:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mSMeY-0003BS-82 for pgsql-sql@arkaria.postgresql.org; Mon, 20 Sep 2021 17:00:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mSMeX-0003BJ-UD for pgsql-sql@lists.postgresql.org; Mon, 20 Sep 2021 17:00:26 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mSMeR-0002xu-8z for pgsql-sql@lists.postgresql.org; Mon, 20 Sep 2021 17:00:25 +0000 Received: by mail-pf1-x429.google.com with SMTP id j6so16852728pfa.4 for ; Mon, 20 Sep 2021 10:00:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=MXluL4x3DFtwGUbAdRFMHz4J1swcxvg7b8nhWSetrZ8=; b=XSMv2+EnTkcp0BUeoyyEJAuL681dvpHiivInFGlclN8licWzsXb5ikT/3ODQ6q8V5W AyxcraFrGHWCaV8OuY1NYJuPZcXj9Ji/JdCBIAJn/sZx1AqGmEsKJGuotqaOyfn/p48z f63cic1oA5jsPKhNhrGuhxycHEJjWbY8PlIQEokL4XHuDRrpiV6pQGEPaMmVW9kirKDJ 0tF42wNmKVBrtPIsejNpsMPrRQFlqttggiXs5aBlFWCTAkikCPm7JdyL1HsNc3fZspOi JsdRSPbr4qImYob+VzDiddXbH3v36yTFM25VfXJMV62snFvGDKaORBrssjP4Y2zU4sZr bgUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=MXluL4x3DFtwGUbAdRFMHz4J1swcxvg7b8nhWSetrZ8=; b=EKG6Jf6cKzoFBIldvoBo2cxVSuukCD1p4bmfJGAnMNSsptUoYXk6S3oXJRQSHRSvos EyOnRziY7sVmk9t8ctfDEu2YAOqKu3pJIhuSia2il9a5aDrEzLhDGIDgryoYsMFWvc7x ymAMETkPbpLrDc/FVM0Nu6OjHUJqyyOw2PRvmUs715Jc4jnLc/Oa2M5FWiDzenPbl+5W vol4S2AKAZ7xP06KMXY2wyXStzoR5O7yBChKNaCRc2/tbMtX3TF7loqMOf8L/dX2Mv07 7V/9avkk31BCjaDE7gWELzNFC1SAOLvnAkJokT3PqCuBW7XyuLF2irYXyLd54a+QeEQw saUw== X-Gm-Message-State: AOAM531mcXOrMOHlFlQRBUh7D0VOTKoEipDQkB/inL9FEhr4nouHRpmp O9blUWo0W/S7IRzziRGeAAeGTQrqo58= X-Google-Smtp-Source: ABdhPJzkZYU2Fyv0+aZ1fPqQyT0RNMtISIx5LOTwM/nODZpC+c34wCWlUftFjYdDHGRonlLjnlnztw== X-Received: by 2002:a63:f94c:: with SMTP id q12mr23854934pgk.171.1632157216362; Mon, 20 Sep 2021 10:00:16 -0700 (PDT) Received: from [10.128.48.247] ([155.98.131.7]) by smtp.gmail.com with ESMTPSA id lj7sm44691pjb.18.2021.09.20.10.00.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Sep 2021 10:00:16 -0700 (PDT) Subject: Re: How to sort deleted rows with trigger. Some rows before then some rows after. To: intmail01 Cc: pgsql-sql@lists.postgresql.org References: From: Rob Sargent Message-ID: Date: Mon, 20 Sep 2021 10:58:03 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-CA List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 9/20/21 9:53 AM, intmail01 wrote: > > How to use transaction in a trigger ? It seems there is no possibility > to control transaction within function > > > > You would start a transaction, send two SQL statements.  The trigger is within the transaction (and does not test for negative values). > For each batch of deletes send two delete statements in a single > transaction. The first with negative values. The second with > non-negative values. > > Thank you > > > > > > >