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

From Richard Huxton
Subject Re: PL/pgsql declaration of string / bit / number with given (variable!) length
Date
Msg-id 45C84E27.2070406@archonet.com
Whole thread Raw
In response to PL/pgsql declaration of string / bit / number with given (variable!) length  (sneumann <sneumann@ipb-halle.de>)
List 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


pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Compilation errors
Next
From: Richard Huxton
Date:
Subject: Re: Index ANDing & Index ORing