Re: PL/pgsql declaration of string / bit / number with given (variable!) length

From: Richard Huxton <dev(at)archonet(dot)com>
To: sneumann <sneumann(at)ipb-halle(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: PL/pgsql declaration of string / bit / number with given (variable!) length
Date: 2007-02-06 09:45:11
Message-ID: 45C84E27.2070406@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2007-02-06 13:16:29 Re: Index ANDing & Index ORing
Previous Message Richard Huxton 2007-02-06 09:39:36 Re: Compilation errors