Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 871D16339C4 for ; Fri, 24 Apr 2009 23:47:19 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 36816-04 for ; Fri, 24 Apr 2009 23:47:17 -0300 (ADT) X-Greylist: delayed 00:29:09.844316 by SQLgrey-1.7.6 Received: from que11.charter.net (que11.charter.net [209.225.8.21]) by mail.postgresql.org (Postfix) with ESMTP id 050426332AC for ; Fri, 24 Apr 2009 23:47:17 -0300 (ADT) Received: from imp10 ([10.20.200.10]) by mta11.charter.net (InterMail vM.7.09.01.00 201-2219-108-20080618) with ESMTP id <20090425020456.NBRW22327.mta11.charter.net@imp10> for ; Fri, 24 Apr 2009 22:04:56 -0400 Received: from [192.168.0.3] ([75.131.201.87]) by imp10 with charter.net id je4v1b00L1tedoz05e4vTq; Fri, 24 Apr 2009 22:04:56 -0400 Message-Id: <08F9706F-C603-46A2-8D42-5799D700DCE7@ruprecht.org> From: Chris Ruprecht To: pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Variable number or arguments to a function possible? Date: Fri, 24 Apr 2009 22:04:54 -0400 X-Mailer: Apple Mail (2.930.3) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200904/113 X-Sequence-Number: 32459 Hello everybody, Is it possible to create a function that can take a variable number of =20= arguments? I would like to write a function that creates a new record in the =20 database. Based on what I send it, it should create a record in the =20 appropriate table. Simple pseudo-code example: ... function create_record( varchar [,...] ) returns bigint as if $1 =3D 'state' then insert into state ( $2, $3 ) // $2 being state =20= name, and $3 state code if $1 =3D 'phone' then insert into phone ( $4::bigint, $2, $3 ) // $2 =3D = =20 phone number, $3 =3D phone type, $4 =3D id of person that ownes the = phone and so on. How would I declare that function? Thanks. best regards, chris --=20 chris ruprecht database grunt and bit pusher extraordina=EDre