Complete the code to declare an OUT parameter in a PostgreSQL function.
CREATE FUNCTION get_sum(a integer, b integer, [1] integer) AS $$ BEGIN result := a + b; END; $$ LANGUAGE plpgsql;The OUT keyword declares an output parameter that the function will return.
Complete the code to assign a value to the OUT parameter inside the function body.
CREATE FUNCTION get_product(a integer, b integer, OUT product integer) AS $$ BEGIN [1] := a * b; END; $$ LANGUAGE plpgsql;You assign the calculated value directly to the OUT parameter name inside the function.
Fix the error in the function declaration to correctly use OUT parameters.
CREATE FUNCTION get_difference(a integer, b integer, [1] integer) AS $$ BEGIN diff := a - b; END; $$ LANGUAGE plpgsql;OUT parameters must be declared with the OUT keyword to be used as output variables.
Fill both blanks to declare two OUT parameters and assign values inside the function.
CREATE FUNCTION get_stats(a integer, b integer, [1] integer, [2] integer) AS $$ BEGIN sum := a + b; product := a * b; END; $$ LANGUAGE plpgsql;
Both sum and product are declared as OUT parameters to return two values.
Fill all three blanks to declare OUT parameters and assign values for sum, difference, and product.
CREATE FUNCTION calculate(a integer, b integer, [1] integer, [2] integer, [3] integer) AS $$ BEGIN sum := a + b; diff := a - b; product := a * b; END; $$ LANGUAGE plpgsql;
All three parameters are declared as OUT to return multiple results from the function.