Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qVvxn-001crw-5t for pgsql-general@arkaria.postgresql.org; Tue, 15 Aug 2023 15:28:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qVvxl-00FW6U-KP for pgsql-general@arkaria.postgresql.org; Tue, 15 Aug 2023 15:28:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qVvxk-00FW6M-ML for pgsql-general@lists.postgresql.org; Tue, 15 Aug 2023 15:28:05 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qVvxh-000Iuu-DF for pgsql-general@lists.postgresql.org; Tue, 15 Aug 2023 15:28:04 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id E3BCF3200901; Tue, 15 Aug 2023 11:27:56 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 15 Aug 2023 11:27:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1692113276; x=1692199676; bh=jVgivd9/tGgR/pJ8qrjT7bXdUb5up9k6aPc rThP2gZk=; b=iusAN52Nuk86OQ2xQtmiAy5SSvW0udaydXXyW8ZhLNnskoPIgmC dpISjnvx+8TIjW8syY9vq+uIG02phsMuBVFws9XZDbmCq1b38PWOXOccz9cYzTAx tORInE/X3gUS2xNPmOivqjEEI1YZz3N4v8KndJ7M9xXNlG87FwrZWP0lIPT1eVif E6gol9cY+kZ9W6XWeA3Eav15Jh7sfcvpkOMVeMTsh7fQ6V3GXNUgIFmb4OhPUqGZ tjwZe+muVp1rPo/zX3A6/tcLeRQRNZXrDx+fz2ose044/P7MTgSzkmsiigcMwAuz L2BiM4KeKibFey4vwGZL5zC0F7SkK6ijEmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1692113276; x= 1692199676; bh=jVgivd9/tGgR/pJ8qrjT7bXdUb5up9k6aPcrThP2gZk=; b=e 7OwG/kzhYugWHd53ckfD6R4ac4deHl5ar1V5GaRJ2BC+QS3xBG/nnG+bheiCm6ZG y7L8UH6eO8b10DchNI5BzklEhQ9g816q+ehm5SshjSomMFqwebhCe5JMRD/9aF6J cm4GWYLU2Ur2LSa/0W6ASPJoIW1cLiOWdhgvazTOwwDmxhS5LEl1QaQpvy1yFYY8 QklmspFDMQI0JFU6k+MeuqpVYikQ+noguUeaZlh06crECXT3X1Bzo2cq4Ge1EKf1 eJRWtFOh5YG5/eBqbJzUFfG/ny42rr7ZoXYDSsOKeut3ezHsYopmBsTaxvo8wTz0 qO/xsnO/wyJnhDwKSXikw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedruddtjedgkeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpedugfeuleegveffhfegleejhefhtedtgeeileeggfeh fefffeevgeejtdeutefftdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 15 Aug 2023 11:27:55 -0400 (EDT) Message-ID: <8d88b119-a845-545b-e89c-aac6ba43261a@aklaver.com> Date: Tue, 15 Aug 2023 08:27:54 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: Converting sql anywhere to postgres To: Russell Rose | Passfield Data Systems , "pgsql-general@lists.postgresql.org" References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/15/23 08:04, Russell Rose | Passfield Data Systems wrote: > Hi there > > I am trying to convert a SQL Anywhere database to postgres. Within SQL > anywhere a field can have a default value of ‘last user’. This means > that when you perform an update on a table, if the field is not > explicitly set then the current user is used. So for instance if I have > a field called mod_user in a table, but when I do an update on the table > and do not set mod_user then SQL Anywhere sets the field to current_uer. > I have tried to replicate this using a postgres trigger in the before > update. However, if I do not set the value then it automatically picks > up the value that was already in the field. Is there a way to tell the > difference between me setting the value to the same as the previous > value and postgres automatically picking it up. Not that I know of. In Postgres an UPDATE is essentially a DELETE of the OLD tuple and an INSERT of a new tuple. You cannot determine whether the same value in a given field for the OLD/NEW records was explicitly set the same or just carried over. > > If the field myfield contains the word ‘me’. Can I tell the difference > between: > > Update table1 set field1=’something’,myfield=’me’ > > And > > Update table1 set field1=’something’ > -- Adrian Klaver adrian.klaver@aklaver.com