Re: Converting sql anywhere to postgres

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Russell Rose | Passfield Data Systems <russellrose(at)passfield(dot)co(dot)uk>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Converting sql anywhere to postgres
Date: 2023-08-15 15:27:54
Message-ID: 8d88b119-a845-545b-e89c-aac6ba43261a@aklaver.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Erik Wienhold 2023-08-15 16:05:13 Re: Converting sql anywhere to postgres
Previous Message Albrecht Dreß 2023-08-15 15:23:33 Re: PostgreSQL and GUI management