Search Postgresql Archives

Re: plpgsql default arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pavel Stehule wrote:
CREATE OR REPLACE FUNCTION foo(integer, integer) RETURNS integer AS $$
BEGIN
  RETURN $1 + $2;
END; $$ LANGUAGE plpgsql;

CREATE OR REPLACE FUNCTION foo(integer) RETURNS integer AS $$
BEGIN
  RETURN foo($1,10); -- 10 is "default" value
END; $$ LANGUAGE plpgsql;

Note that if you define the "short cut function" in SQL (the second one above that supplies the default argument), you can take advantage of function inlining. Granted, it's probably not a huge win, but if all the function does is return the result of evaluating another function, it need not be pl/pgsql anyway.


-Neil

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@xxxxxxxxxxxxxx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux