Re: returning results from plsql function to plpythonu function

From: c k <shreeseva(dot)learning(at)gmail(dot)com>
To: Lou Picciano <loupicciano(at)comcast(dot)net>
Cc: pgsql-admin(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: returning results from plsql function to plpythonu function
Date: 2011-12-03 19:32:45
Message-ID: CAN2Y=uPRZ=VrR9kEgC9L03J1DfHxgN1Xb27bTSy_-KycEjDKHQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

thanks.
it solved my problem.

C P Kulkarni

On Sun, Dec 4, 2011 at 12:21 AM, Lou Picciano <loupicciano(at)comcast(dot)net>wrote:

> # Assuming your query here returns col1, col2, etc.:
>
> results = plpy.execute("select * from software.func1();")
>
> # these lines will return the results ----------
> # - (where the first member of the array is the 'row number' of the
> result:)
>
> value1 = results[0][ "col1" ]
> value2 = results[0][ "col2" ]
>
> # --- Wanna see?
>
> plpy.notice("-- value1: ",value1)
> plpy.notice("-- value2: ",value2)
>
>
> can you please give me the example
> I am not a python programmer.
>
> Nor am I!
> Looks like your example, btw, is attempting string operations on something
> not yet quite a string!
>
> Pythons are dangerous. Be careful!
>
>
> Lou Picciano
>
> ------------------------------
> *From: *"c k" <shreeseva(dot)learning(at)gmail(dot)com>
> *To: *"Lou Picciano" <loupicciano(at)comcast(dot)net>
> *Cc: *"pgsql-admin" <pgsql-admin(at)postgresql(dot)org>,
> pgsql-general(at)postgresql(dot)org
> *Sent: *Saturday, December 3, 2011 1:01:39 PM
> *Subject: *Re: [ADMIN] returning results from plsql function to plpythonu
> function
>
>
> can you please give me the example
> I am not a python programmer.
>
> C P Kulkarni
>
>
> On Sat, Dec 3, 2011 at 11:25 PM, Lou Picciano <loupicciano(at)comcast(dot)net>wrote:
>
>> CP - You're missing a line in the middle; one which will extract specific
>> content(s) from $results.
>>
>> Because, yes, without such a line, python will only return the object
>> reference.
>>
>> Lou Picciano
>>
>> ------------------------------
>> *From: *"c k" <shreeseva(dot)learning(at)gmail(dot)com>
>> *To: *"pgsql-admin" <pgsql-admin(at)postgresql(dot)org>,
>> pgsql-general(at)postgresql(dot)org
>> *Sent: *Saturday, December 3, 2011 12:50:16 PM
>> *Subject: *[ADMIN] returning results from plsql function to plpythonu
>> function
>>
>>
>> Hello friends,
>> I am checking some logic which includes two functions. One is plsql
>> function which returns text. Second function is plpythonu and contains one
>> statement which outputs notice
>>
>> e.g.
>> results = plpy.execute("select * from software.func1();")
>> plpy.notice("%s" % col for col in results[0])
>>
>> The same result is returned as a final return as notice. But it does not
>> outputs the correct result which is returned from func1 (text in this
>> case). Rather it outputs notice as
>> NOTICE: <generator object <genexpr> at 0xb578cb6c>
>> It doesn't prints the correct notice even by using
>> plpy.notice("%s" %results)
>>
>> What can be the problem here?
>> Thanks for help.
>>
>>
>> C P Kulkarni
>>
>
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message ashok raj 2011-12-04 01:18:24 Re: Read Only Role
Previous Message Lou Picciano 2011-12-03 18:51:31 Re: returning results from plsql function to plpythonu function

Browse pgsql-general by date

  From Date Subject
Next Message Josh Kupershmidt 2011-12-03 20:15:41 Re: How to get Place Names from Lat Lon
Previous Message Christoph Zwerschke 2011-12-03 19:31:23 Re: Shared memory usage in PostgreSQL 9.1