Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id F34459FB321 for ; Tue, 6 Feb 2007 06:17:11 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 24536-10 for ; Tue, 6 Feb 2007 06:17:04 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id CA6AF9FB31A for ; Tue, 6 Feb 2007 06:17:07 -0400 (AST) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id C5366143E80; Tue, 6 Feb 2007 09:45:11 +0000 (GMT) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 6E0502741A2; Tue, 6 Feb 2007 09:45:11 +0000 (GMT) Message-ID: <45C84E27.2070406@archonet.com> Date: Tue, 06 Feb 2007 09:45:11 +0000 From: Richard Huxton User-Agent: IceDove 1.5.0.9 (X11/20061220) MIME-Version: 1.0 To: sneumann Cc: pgsql-sql@postgresql.org Subject: Re: PL/pgsql declaration of string / bit / number with given (variable!) length References: <1170691341.14733.147.camel@lathan.ipb-sub.ipb-halle.de> In-Reply-To: <1170691341.14733.147.camel@lathan.ipb-sub.ipb-halle.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/51 X-Sequence-Number: 27385 sneumann wrote: > Hi, > > I have a PL/pgsql function that creates a certain bit string > based on the parameters. Things work fine if I use bit(10) > throughout the function. Now I'd like to return a bit string > with the given size "len", but that breaks with a syntax error: > > ret := B'0'::bit(len); > LINE 1: SELECT B'0'::bit( $1 ) > ^ > > Any suggestion how to return a (bit) string > of user-defined length ? Hmm - not sure it's possible (even theoretically) for a function to have multiple return types. Could you return a "bit varying" and cast it when received? -- Richard Huxton Archonet Ltd