From: | "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com> |
---|---|
To: | Peter Fein <pfein(at)pobox(dot)com> |
Cc: | Postgresql-General list <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Return SETOF or array from pl/python |
Date: | 2005-07-15 16:59:40 |
Message-ID: | 42D7EB7C.90301@commandprompt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>>
>>I am not an everyday python programmer but I am pretty sure that you are
>>trying to return a list in arf(). You can't return a list you have to
>>return the array type which is why arf2 works.
>
>
> Ok. How does one convert a python list to a PGSql array then? Is there
> a better way to do it than what I did in arf2?
I don't think you can with plPython at least not without reformatting
the list within the function itself.
>
>
>>The reasons srf works is because you are just returning text in general
>>regardless that it is formatting to a list.
>
>
> How does one return a set then? I want as my output:
You would actually have to have a set. What I believe you are trying to
do is transform a list to a result set. I don't think you can do that
without some additional programming within the function.
Somebody may know of a better way but what I would think would happen is
this:
Break up list, insert each value of list into a temp table as a row,
return set of temp table.
Sincerely,
Joshua D. Drake
>
> SELECT * FROM srf();
>
> srf
> -------------------------
> 'one'
> 'two'
> 'three'
> (3 rows)
>
--
Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240
PostgreSQL Replication, Consulting, Custom Programming, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Andrus | 2005-07-15 17:08:32 | Re: How to create unique constraint on NULL columns |
Previous Message | Dianne Yumul | 2005-07-15 16:57:08 | Re: Postgres for Fedora Core 2 OS **************** |