On Wed, Aug 2, 2017 at 8:58 AM, Alexander Farber <alexander(dot)farber(at)gmail(dot)com
> wrote:
> However if the user record is not found or the user already has vip_until
> >= CURRENT_TIMESTAMP (i.e. the user has already purchased "vip status") I
> would like to cancel the INSERT.
>
>
You can "join" two DDL commands by using a Common Table Expression (CTE)
(i.e., WITH / SELECT). You would need to make it so the UPDATE happens
first and if there are no results the INSERT simply becomes a no-op.
David J.