Published fragment Prepared statements for psql operations, on using prepared statements with operational queries to make it easy to replace parameters and save time.
PREPARE add_flag_to_team(text, uuid) AS INSERT INTO flag_team (
flag_id,
team_id
) VALUES (
(SELECT id FROM flag WHERE name = $1),
$2
) ON CONFLICT DO NOTHING;
EXECUTE add_flag_to_team('<flag_name>', '<team_id>');