X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 164A19DC88F for ; Sun, 29 Jan 2006 11:47:57 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 21348-08 for ; Sun, 29 Jan 2006 11:48:01 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id C44B29DC883 for ; Sun, 29 Jan 2006 11:47:54 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k0TFlv99001794; Sun, 29 Jan 2006 10:47:57 -0500 (EST) To: Daniel CAUNE cc: pgsql-sql@postgresql.org Subject: Re: Function with default value? In-reply-to: <0ITV004G911MRG90@VL-MH-MR002.ip.videotron.ca> References: <0ITV004G911MRG90@VL-MH-MR002.ip.videotron.ca> Comments: In-reply-to Daniel CAUNE message dated "Sun, 29 Jan 2006 15:15:21 -0500" Date: Sun, 29 Jan 2006 10:47:57 -0500 Message-ID: <1793.1138549677@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.101 required=5 tests=[AWL=0.101, UPPERCASE_25_50=0] X-Spam-Score: 0.101 X-Spam-Level: X-Archive-Number: 200601/206 X-Sequence-Number: 23995 Daniel CAUNE writes: > Is it possible to define a function with some default values? > CREATE OR REPLACE FUNCTION foo(i IN int, j IN int DEFAULT := 1) No. But you can fake many versions of this with a family of functions: CREATE OR REPLACE FUNCTION foo(i IN int, j IN int) ... CREATE OR REPLACE FUNCTION foo(i IN int) ... return foo(i, 1) ... Remember that PG lets you "overload" a function name by using the same name with different parameter lists. regards, tom lane