Instruction
Cool! As we just learned, there are a few ways of calling a function:
- Using a
SELECTstatement. You can use a regularSELECTin SQL (not in PL/pgSQL):SELECT add_topic('Quick cakes'); - In PL/pgSQL, you can:
- Use the
SELECT INTOsyntax to save a query result:SELECT thumbs_up, thumbs_down INTO upvotes, downvotes FROM post WHERE id = post_id
- Use assignment to save the query result:
post_id := ( SELECT post_id FROM post WHERE user_id = 17 LIMIT 1 );
- Use assignment to invoke a function:
user_id := get_most_active_user();
-
PERFORMstatement (in PL/pgSQL).PERFORM add_topic('Quick cakes');
- Use the
Exercise
Click to jump to the next part where we're going to continue our adventure with complex functions!




