Обсуждение: How do I do this in plpgsql ?

Поиск
Список
Период
Сортировка

How do I do this in plpgsql ?

От
Dan S
Дата:
Hi !

Is there a way to use plpgsql copy type to get an array of a certain type ?

For example if I have a type sample%TYPE
How can I declare a variable that is an array of sample%TYPE
I can't get it to work, is there a way to do it ?

Best Regards
Dan S

Re: How do I do this in plpgsql ?

От
Merlin Moncure
Дата:
On Fri, Mar 18, 2011 at 2:20 PM, Dan S <strd911@gmail.com> wrote:
> Hi !
>
> Is there a way to use plpgsql copy type to get an array of a certain type ?
>
> For example if I have a type sample%TYPE
> How can I declare a variable that is an array of sample%TYPE
> I can't get it to work, is there a way to do it ?

I don't think it's possible.  Can you give some more detail on what
you are trying to do?

merlin

Re: How do I do this in plpgsql ?

От
Pavel Stehule
Дата:
2011/3/18 Dan S <strd911@gmail.com>:
> Hi !
>
> Is there a way to use plpgsql copy type to get an array of a certain type ?
>
> For example if I have a type sample%TYPE
> How can I declare a variable that is an array of sample%TYPE
> I can't get it to work, is there a way to do it ?

No, it's not supported :(

Regards

Pavel Stehule
>
> Best Regards
> Dan S
>
>

Re: How do I do this in plpgsql ?

От
Dan S
Дата:
Well I had the hope to only define the type used for this column in one place.
Now I needed an array of the same type do some procedural calculations.
I figured that the best way was to get an array of this type by copying the type used to fill the array.

Anyway I will declare the array the usual way then.

Thank you Merlin and Pavel for your quick answers
Dan S

2011/3/18 Merlin Moncure <mmoncure@gmail.com>
On Fri, Mar 18, 2011 at 2:20 PM, Dan S <strd911@gmail.com> wrote:
> Hi !
>
> Is there a way to use plpgsql copy type to get an array of a certain type ?
>
> For example if I have a type sample%TYPE
> How can I declare a variable that is an array of sample%TYPE
> I can't get it to work, is there a way to do it ?

I don't think it's possible.  Can you give some more detail on what
you are trying to do?

merlin

Re: How do I do this in plpgsql ?

От
Vibhor Kumar
Дата:
On Mar 19, 2011, at 12:50 AM, Dan S wrote:

>
> For example if I have a type sample%TYPE
> How can I declare a variable that is an array of sample%TYPE
> I can't get it to work, is there a way to do it ?


Nope, there is no way. However, you can create a userdefined type and can also use array of that
http://www.postgresql.org/docs/8.4/static/sql-createtype.html

Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
vibhor.kumar@enterprisedb.com
Blog:http://vibhork.blogspot.com