Complete the code to start creating a function named 'add_numbers'.
CREATE FUNCTION [1](a integer, b integer) RETURNS integer AS $$ BEGIN RETURN a + b; END; $$ LANGUAGE plpgsql;The function name is defined right after CREATE FUNCTION. Here, it should be add_numbers as requested.
Complete the code to specify the language used for the function.
CREATE FUNCTION add_numbers(a integer, b integer) RETURNS integer AS $$ BEGIN RETURN a + b; END; $$ LANGUAGE [1];PostgreSQL procedural language for functions is plpgsql. This must be specified after the LANGUAGE keyword.
Fix the error in the function header by completing the RETURNS clause correctly.
CREATE FUNCTION multiply_numbers(a integer, b integer) RETURNS [1] AS $$ BEGIN RETURN a * b; END; $$ LANGUAGE plpgsql;The function returns the product of two integers, so the return type must be integer.
Fill both blanks to complete the function that returns the length of a text input.
CREATE FUNCTION get_length(input_text text) RETURNS integer AS $$ BEGIN RETURN [1]([2]); END; $$ LANGUAGE plpgsql;
The PostgreSQL function to get string length is length, and it takes the input text variable input_text as argument.
Fill all three blanks to create a function that returns TRUE if a number is positive.
CREATE FUNCTION is_positive(num integer) RETURNS boolean AS $$ BEGIN IF num [1] 0 THEN RETURN [2]; ELSE RETURN [3]; END IF; END; $$ LANGUAGE plpgsql;
The function checks if num is greater than zero, returning TRUE if yes, otherwise FALSE.