AmusedGrape
03/18/2022, 3:34 AMsql
create function commands_inc (x int, row_id text)
returns void as
$$
if exists (select 1 from bot_analytics where id = row_id) then
begin
update bot_analytics
set commands = commands + x
where id = row_id
end
else
begin
insert into bot_analytics (id, commands)
values (row_id, x)
end if
$$
language plpgsql volatile;
Needle
03/18/2022, 3:34 AM/title
command!
We have solved your problem?
Click the button below to archive it.Avin
03/18/2022, 4:21 AMinsert ... on conflict ... do update
statement 🙂Needle
03/18/2022, 4:21 AMAmusedGrape
03/18/2022, 1:21 PMsyntax error at or near "insert"
AmusedGrape
03/18/2022, 1:21 PMsql
create function commands_inc (x int, row_id text)
returns void as
$$
insert into command_logs (id, commands) values (row_id, x) on conflict do update
$$
language plpgsql volatile;
AmusedGrape
03/18/2022, 1:40 PM