I using django framework and Postgresql develop my project. But I have a problem when many user requests at the same time. It will double inserted data when server is slow. For this reason, I will try to prevent in SQL. I want to know how to SELECT
, then INSERT
in one command.
Such as
is_created = select created_at,product from payment where created_at=current_date,product_id = '1'
if is_created == False then
insert into table (...) values (....)
postgreSQL supports conditionals you may find this helpful
https://www.postgresql.org/docs/current/functions-conditional.html
example
CASE expression
WHEN value THEN result
[WHEN ...]
[ELSE result]
END
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.