pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
returning results from plsql function to plpythonu function
6+ messages / 2 participants
[nested] [flat]

* returning results from plsql function to plpythonu function
@ 2011-12-03 17:50 c k <shreeseva.learning@gmail.com>
  2011-12-03 17:55 ` Re: returning results from plsql function to plpythonu function Lou Picciano <loupicciano@comcast.net>
  0 siblings, 1 reply; 6+ messages in thread

From: c k @ 2011-12-03 17:50 UTC (permalink / raw)
  To: pgsql-admin; pgsql-general@postgresql.org

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

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: returning results from plsql function to plpythonu function
  2011-12-03 17:50 returning results from plsql function to plpythonu function c k <shreeseva.learning@gmail.com>
@ 2011-12-03 17:55 ` Lou Picciano <loupicciano@comcast.net>
  2011-12-03 18:01   ` Re: returning results from plsql function to plpythonu function c k <shreeseva.learning@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Lou Picciano @ 2011-12-03 17:55 UTC (permalink / raw)
  To: c k <shreeseva.learning@gmail.com>; +Cc: pgsql-admin; pgsql-general@postgresql.org

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 

----- Original Message -----
From: "c k" <shreeseva.learning@gmail.com> 
To: "pgsql-admin" <pgsql-admin@postgresql.org>, pgsql-general@postgresql.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 

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: returning results from plsql function to plpythonu function
  2011-12-03 17:50 returning results from plsql function to plpythonu function c k <shreeseva.learning@gmail.com>
  2011-12-03 17:55 ` Re: returning results from plsql function to plpythonu function Lou Picciano <loupicciano@comcast.net>
@ 2011-12-03 18:01   ` c k <shreeseva.learning@gmail.com>
  2011-12-03 18:14     ` Re: returning results from plsql function to plpythonu function c k <shreeseva.learning@gmail.com>
  2011-12-03 18:51     ` Re: returning results from plsql function to plpythonu function Lou Picciano <loupicciano@comcast.net>
  0 siblings, 2 replies; 6+ messages in thread

From: c k @ 2011-12-03 18:01 UTC (permalink / raw)
  To: Lou Picciano <loupicciano@comcast.net>; +Cc: pgsql-admin; pgsql-general@postgresql.org

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@comcast.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.learning@gmail.com>
> *To: *"pgsql-admin" <pgsql-admin@postgresql.org>,
> pgsql-general@postgresql.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
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: returning results from plsql function to plpythonu function
  2011-12-03 17:50 returning results from plsql function to plpythonu function c k <shreeseva.learning@gmail.com>
  2011-12-03 17:55 ` Re: returning results from plsql function to plpythonu function Lou Picciano <loupicciano@comcast.net>
  2011-12-03 18:01   ` Re: returning results from plsql function to plpythonu function c k <shreeseva.learning@gmail.com>
@ 2011-12-03 18:14     ` c k <shreeseva.learning@gmail.com>
  1 sibling, 0 replies; 6+ messages in thread

From: c k @ 2011-12-03 18:14 UTC (permalink / raw)
  To: Lou Picciano <loupicciano@comcast.net>; +Cc: pgsql-admin; pgsql-general@postgresql.org

when I modified the notice statement as
plpy.notice('%s' %results[0])

it prints notice as
NOTICE:  {'func1': 'function return text'}

I didn't understand why it is showing 'func1' in the results[0] ?


C P Kulkarni

On Sat, Dec 3, 2011 at 11:31 PM, c k <shreeseva.learning@gmail.com> wrote:

> 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@comcast.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.learning@gmail.com>
>> *To: *"pgsql-admin" <pgsql-admin@postgresql.org>,
>> pgsql-general@postgresql.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
>>
>
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: returning results from plsql function to plpythonu function
  2011-12-03 17:50 returning results from plsql function to plpythonu function c k <shreeseva.learning@gmail.com>
  2011-12-03 17:55 ` Re: returning results from plsql function to plpythonu function Lou Picciano <loupicciano@comcast.net>
  2011-12-03 18:01   ` Re: returning results from plsql function to plpythonu function c k <shreeseva.learning@gmail.com>
@ 2011-12-03 18:51     ` Lou Picciano <loupicciano@comcast.net>
  2011-12-03 19:32       ` Re: returning results from plsql function to plpythonu function c k <shreeseva.learning@gmail.com>
  1 sibling, 1 reply; 6+ messages in thread

From: Lou Picciano @ 2011-12-03 18:51 UTC (permalink / raw)
  To: pgsql-admin; pgsql-general@postgresql.org; +Cc: shreeseva.learning@gmail.com

# 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 

----- Original Message -----
From: "c k" <shreeseva.learning@gmail.com> 
To: "Lou Picciano" <loupicciano@comcast.net> 
Cc: "pgsql-admin" <pgsql-admin@postgresql.org>, pgsql-general@postgresql.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@comcast.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.learning@gmail.com > 
To: "pgsql-admin" < pgsql-admin@postgresql.org >, pgsql-general@postgresql.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 

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: returning results from plsql function to plpythonu function
  2011-12-03 17:50 returning results from plsql function to plpythonu function c k <shreeseva.learning@gmail.com>
  2011-12-03 17:55 ` Re: returning results from plsql function to plpythonu function Lou Picciano <loupicciano@comcast.net>
  2011-12-03 18:01   ` Re: returning results from plsql function to plpythonu function c k <shreeseva.learning@gmail.com>
  2011-12-03 18:51     ` Re: returning results from plsql function to plpythonu function Lou Picciano <loupicciano@comcast.net>
@ 2011-12-03 19:32       ` c k <shreeseva.learning@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: c k @ 2011-12-03 19:32 UTC (permalink / raw)
  To: Lou Picciano <loupicciano@comcast.net>; +Cc: pgsql-admin; pgsql-general@postgresql.org

thanks.
it solved my problem.

C P Kulkarni

On Sun, Dec 4, 2011 at 12:21 AM, Lou Picciano <loupicciano@comcast.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.learning@gmail.com>
> *To: *"Lou Picciano" <loupicciano@comcast.net>
> *Cc: *"pgsql-admin" <pgsql-admin@postgresql.org>,
> pgsql-general@postgresql.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@comcast.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.learning@gmail.com>
>> *To: *"pgsql-admin" <pgsql-admin@postgresql.org>,
>> pgsql-general@postgresql.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
>>
>
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2011-12-03 19:32 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-12-03 17:50 returning results from plsql function to plpythonu function c k <shreeseva.learning@gmail.com>
2011-12-03 17:55 ` Lou Picciano <loupicciano@comcast.net>
2011-12-03 18:01   ` c k <shreeseva.learning@gmail.com>
2011-12-03 18:14     ` c k <shreeseva.learning@gmail.com>
2011-12-03 18:51     ` Lou Picciano <loupicciano@comcast.net>
2011-12-03 19:32       ` c k <shreeseva.learning@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox