Instruction
Great! Let's wrap up the INTO syntax with some additional info. This syntax allows us to get a result from INSERT, UPDATE, or DELETE statements. Take a look:
UPDATE post INTO score SET thumbs_down = thumbs_down + 1 WHERE id = post_id RETURNING thumbs_down;
There are two things happening here: a regular update (which adds a downvote to a given post), and an assignment.
UPDATE (like both INSERT and DELETE) in PostgreSQL has an optional RETURNING clause that allows it to return a result from this statement. Here, we return the number of downvotes after the update. You can use the INTO variable syntax to store this result in a variable.
Exercise
Let's take a break from writing functions. Just play around with RETURNING clause. Click whenever you're ready.
Pssst... You may return many columns, or even all of them (*) – it works just like SELECT 😉



