```sql -- currently like this priority smallint de...
# sql
s
Copy code
sql
-- currently like this
priority smallint default 0

-- I want to change it to something like this
priority smallint generated always as (if x is not null and y is not null then 1 else 0 end) stored;
s
I don't believe you can do it directly like this (at least, I can't find any examples doing it in this way). I think the correct approach would be to use a dedicated function and pass params into it. Alternatively, a trigger that runs after insert would be able to do it.
s
Yeah maybe a trigger is the go, thanks 🙏
I have a create and update function, may as well add it there actually