Search Postgresql Archives

Re: Do not INSERT if UPDATE fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 2, 2017 at 8:58 AM, Alexander Farber <alexander.farber@xxxxxxxxx> 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.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux