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 929E59DC88E for ; Sun, 29 Jan 2006 18:40:45 -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 16724-07 for ; Sun, 29 Jan 2006 18:40:47 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by postgresql.org (Postfix) with ESMTP id 7D5229DC805 for ; Sun, 29 Jan 2006 18:40:43 -0400 (AST) Received: from lythanhphu ([66.130.233.129]) by VL-MO-MR002.ip.videotron.ca (Sun Java System Messaging Server 6.2-2.05 (built Apr 28 2005)) with ESMTP id <0ITV00K43LNX4C10@VL-MO-MR002.ip.videotron.ca> for pgsql-sql@postgresql.org; Sun, 29 Jan 2006 17:40:46 -0500 (EST) Date: Sun, 29 Jan 2006 22:40:46 -0500 From: Daniel CAUNE Subject: Re: Function with default value? In-reply-to: <1793.1138549677@sss.pgh.pa.us> To: 'Tom Lane' Cc: pgsql-sql@postgresql.org Message-id: <0ITV00K44LNX4C10@VL-MO-MR002.ip.videotron.ca> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Mailer: Microsoft Office Outlook, Build 11.0.6353 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: quoted-printable Thread-index: AcYk62EAP70KjRJkRPWkrKI7ZHP/FwAKjWuA X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.625 required=5 tests=[AWL=-0.382, DATE_IN_FUTURE_03_06=2.007] X-Spam-Score: 1.625 X-Spam-Level: * X-Archive-Number: 200601/207 X-Sequence-Number: 23996 > -----Message d'origine----- > De : Tom Lane [mailto:tgl@sss.pgh.pa.us] > Envoy=C3=A9 : dimanche 29 janvier 2006 10:48 > =C3=80 : Daniel CAUNE > Cc : pgsql-sql@postgresql.org > Objet : Re: [SQL] Function with default value? >=20 > 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 :=3D 1) >=20 > No. But you can fake many versions of this with a family of = functions: >=20 > CREATE OR REPLACE FUNCTION foo(i IN int, j IN int) ... >=20 > CREATE OR REPLACE FUNCTION foo(i IN int) ... return foo(i, 1) ... >=20 > Remember that PG lets you "overload" a function name by using the same > name with different parameter lists. >=20 > regards, tom lane Yes, thanks Tom, for the second time.