VARIADIC
Example
Section titled “Example”CREATE OR REPLACE FUNCTION total_sum(VARIADIC arr integer[]) RETURNS integer AS $$BEGIN RETURN array_sum(arr);END; $$ LANGUAGE plpgsql;
SELECT total_sum(10, 20, 30, 40);Output
Section titled “Output”100Explanation
Section titled “Explanation”The function total_sum is declared with the VARIADIC keyword, which allows it to take an unspecified number of arguments. In the SELECT statement, four integers are provided as arguments. The result is the sum of these four integers, which is ‘100’.